localpdb/plugins/Socket.py
def run_socket(inps):
    """
    Runs socket (preceeded by the DSSP run) and writes the output in the plugin directory. Output is written only if
    coiled coil domain was found in the entry. Inputs are wrapped to allow for multiprocessing.
    Order of the inputs is: pdb_id: PDB identifier, fn_biounit: filename of the biounit, cutoffs: socket cutoffs to run,
    fn_out: filename of the output file if there's any., socket_loc: location of the socket binary, dssp2_loc: location
    of the dssp2 binary.
    :param inps: tuple containing (pdb_id, fn_biounit, cutoffs, fn_out, socket_loc, dssp2_loc)
    :return: dict with the job statuses (NaN or pointer to output file) with socket cutoffs as keys
    """
    pdb_id, fn_biounit, cutoffs, fn_out, socket_loc, dssp2_loc = inps
    fh_tmp = get_unzipped_tempfile(fn_biounit) # Unzipped fh to the biounit file
    dssp_tmp = '/tmp/{}'.format(next(tempfile._get_candidate_names()))
    cmd = f'{dssp2_loc} -i {fn_biounit} -o {dssp_tmp}'
    result, _ = os_cmd(cmd)
    codes = [result]
    if os.path.isfile(dssp_tmp) and result == 0: # DSSP run was OK, proceed with socket
        for cutoff in cutoffs: # Run socket for each cutoff and check if CC was found
            socket_tmp = '/tmp/{}'.format(next(tempfile._get_candidate_names()))
            cmd = f'{socket_loc} -f {fh_tmp.name} -s {dssp_tmp} -c {cutoff}'
            code, (stdout, stderr) = os_cmd(cmd)
            has_cc = any(['COILED COILS PRESENT' in line for line in stdout])
            if has_cc and code == 0:
                full_fn_out = f'{fn_out}_{cutoff}'
                fs = open(full_fn_out, 'w')
                for line in stdout:
                    fs.write(f'{line}\n')
                fs.close()
            codes.append(code)
        os.remove(dssp_tmp) # Remove tmp file
    fh_tmp.close() # Close unzipped biounit fh and delete file
    if codes.count(0) == len(codes):
        return 0, None
    else:
        return 1, None

    Runs socket (preceeded by the DSSP run) and writes the output in the plugin directory. Output is written only if
    coiled coil domain was found in the entry. Inputs are wrapped to allow for multiprocessing.
    Order of the inputs is: pdb_id: PDB identifier, fn_biounit: filename of the biounit, cutoffs: socket cutoffs to run,
    fn_out: filename of the output file if there's any., socket_loc: location of the socket binary, dssp2_loc: location
    of the dssp2 binary.
    :param inps: tuple containing (pdb_id, fn_biounit, cutoffs, fn_out, socket_loc, dssp2_loc)
    :return: dict with the job statuses (NaN or pointer to output file) with socket cutoffs as keys
    
Runs socket (preceeded by the DSSP run) and writes the output in the plugin directory. Output is written only if
coiled coil domain was found in the entry. Inputs are wrapped to allow for multiprocessing.
Runs socket ( preceeded by the DSSP run ) and writes the output in the plugin directory . Output is written only if coiled coil domain was found in the entry . Inputs are wrapped to allow for multiprocessing .
def run_socket(inps):
    pdb_id, fn_biounit, cutoffs, fn_out, socket_loc, dssp2_loc = inps
    fh_tmp = get_unzipped_tempfile(fn_biounit) 
    dssp_tmp = '/tmp/{}'.format(next(tempfile._get_candidate_names()))
    cmd = f'{dssp2_loc} -i {fn_biounit} -o {dssp_tmp}'
    result, _ = os_cmd(cmd)
    codes = [result]
    if os.path.isfile(dssp_tmp) and result == 0: 
        for cutoff in cutoffs: 
            socket_tmp = '/tmp/{}'.format(next(tempfile._get_candidate_names()))
            cmd = f'{socket_loc} -f {fh_tmp.name} -s {dssp_tmp} -c {cutoff}'
            code, (stdout, stderr) = os_cmd(cmd)
            has_cc = any(['COILED COILS PRESENT' in line for line in stdout])
            if has_cc and code == 0:
                full_fn_out = f'{fn_out}_{cutoff}'
                fs = open(full_fn_out, 'w')
                for line in stdout:
                    fs.write(f'{line}\n')
                fs.close()
            codes.append(code)
        os.remove(dssp_tmp) 
    fh_tmp.close() 
    if codes.count(0) == len(codes):
        return 0, None
    else:
        return 1, None
def run_socket ( inps ) : pdb_id , fn_biounit , cutoffs , fn_out , socket_loc , dssp2_loc = inps fh_tmp = get_unzipped_tempfile ( fn_biounit ) dssp_tmp = '/tmp/{}' . format ( next ( tempfile . _get_candidate_names ( ) ) ) cmd = f'{dssp2_loc} -i {fn_biounit} -o {dssp_tmp}' result , _ = os_cmd ( cmd ) codes = [ result ] if os . path . isfile ( dssp_tmp ) and result == 0 : for cutoff in cutoffs : socket_tmp = '/tmp/{}' . format ( next ( tempfile . _get_candidate_names ( ) ) ) cmd = f'{socket_loc} -f {fh_tmp.name} -s {dssp_tmp} -c {cutoff}' code , ( stdout , stderr ) = os_cmd ( cmd ) has_cc = any ( [ 'COILED COILS PRESENT' in line for line in stdout ] ) if has_cc and code == 0 : full_fn_out = f'{fn_out}_{cutoff}' fs = open ( full_fn_out , 'w' ) for line in stdout : fs . write ( f'{line}\n' ) fs . close ( ) codes . append ( code ) os . remove ( dssp_tmp ) fh_tmp . close ( ) if codes . count ( 0 ) == len ( codes ) : return 0 , None else : return 1 , None
Runs socket (preceeded by the DSSP run) and writes the output in the plugin directory.
Runs socket ( preceeded by the DSSP run ) and writes the output in the plugin directory .
"""
    Runs socket (preceeded by the DSSP run) and writes the output in the plugin directory. Output is written only if
    coiled coil domain was found in the entry. Inputs are wrapped to allow for multiprocessing.
    Order of the inputs is: pdb_id: PDB identifier, fn_biounit: filename of the biounit, cutoffs: socket cutoffs to run,
    fn_out: filename of the output file if there's any., socket_loc: location of the socket binary, dssp2_loc: location
    of the dssp2 binary.
    :param inps: tuple containing (pdb_id, fn_biounit, cutoffs, fn_out, socket_loc, dssp2_loc)
    :return: dict with the job statuses (NaN or pointer to output file) with socket cutoffs as keys
    """ # Unzipped fh to the biounit file # DSSP run was OK, proceed with socket # Run socket for each cutoff and check if CC was found # Remove tmp file # Close unzipped biounit fh and delete file
dict with the job statuses (NaN or pointer to output file) with socket cutoffs as keys
dict with the job statuses ( NaN or pointer to output file ) with socket cutoffs as keys
inps
tuple containing (pdb_id, fn_biounit, cutoffs, fn_out, socket_loc, dssp2_loc)
tuple containing ( pdb_id fn_biounit cutoffs fn_out socket_loc dssp2_loc )