frag_pele/serie_handler.py
def read_instructions_from_file(file):
    """
    It reads an "instruction file". This file contains the information of all the growing's that the user wants to
    perform, each one separated by newlines. Each instruction must have at least 3 columns, separated by tabulations:
    (1) name of the fragment's PDB file,
    (2) atom name of the core (if the user wants to add the H it must be separated by "-", example: C4-H2),
    (3) atom name of the fragment.
    If the line has more than 3 columns, it will be considered as successive growing's simulations, following the same
    structure previously mentioned but several times.
    :param file: filename of the instructions file.
    :return: list with all instructions processed.
    """
    list_of_instructions = []
    with open(file) as sf:
        instructions = sf.readlines()
        for line in instructions:
            if 0 < len(line.split()) <= 3:
                # Read from file the required information
                try:
                    fragment_pdb = line.split()[0]
                    core_atom = line.split()[1]
                    fragment_atom = line.split()[2]
                    ID = "{}{}{}".format(os.path.splitext(fragment_pdb)[0], core_atom, fragment_atom)
                    task = (fragment_pdb, core_atom, fragment_atom, ID)
                    list_of_instructions.append(task)
                except IndexError:
                    logger.critical("Check that the serie file {} contains: 'PDB_fragment_file'\t'PDB_core_atom_name'\t'PDB_fragment_atom_name' ".format(file))
            elif len(line.split()) > 3:
                growing_counter = len(line.split()) / 3
                successive_tasks = []
                for i in range(int(growing_counter)):
                    try:
                        fragment_pdb = line.split()[i * 3]
                        core_atom = line.split()[(i * 3) + 1]
                        if "*" in core_atom:
                            # Get fragment number and remove part of string
                            fragment_number = re.findall(r'[*]\d[*]', core_atom)[0].strip("*")
                            core_atom = core_atom.replace("*{}*".format(fragment_number), "")
                        else:
                            fragment_number = None
                        fragment_atom = line.split()[(i * 3) + 2]
                        ID = "{}{}{}".format(os.path.splitext(fragment_pdb)[0], core_atom, fragment_atom)
                        task = (fragment_pdb, core_atom, fragment_atom, ID, fragment_number)
                        successive_tasks.append(task)
                    except IndexError:
                        logger.critical("Check that the serie file {} contains: 'PDB_fragment_file'\t'PDB_core_atom_name'\t'PDB_fragment_atom_name' ".format(file))
                list_of_instructions.append(successive_tasks)
    return list_of_instructions

    It reads an "instruction file". This file contains the information of all the growing's that the user wants to
    perform, each one separated by newlines. Each instruction must have at least 3 columns, separated by tabulations:
    (1) name of the fragment's PDB file,
    (2) atom name of the core (if the user wants to add the H it must be separated by "-", example: C4-H2),
    (3) atom name of the fragment.
    If the line has more than 3 columns, it will be considered as successive growing's simulations, following the same
    structure previously mentioned but several times.
    :param file: filename of the instructions file.
    :return: list with all instructions processed.
    
It reads an "instruction file". This file contains the information of all the growing's that the user wants to
perform, each one separated by newlines. Each instruction must have at least 3 columns, separated by tabulations:
(1) name of the fragment's PDB file,
(2) atom name of the core (if the user wants to add the H it must be separated by "-", example: C4-H2),
(3) atom name of the fragment.
If the line has more than 3 columns, it will be considered as successive growing's simulations, following the same
structure previously mentioned but several times.
It reads an " instruction file " . This file contains the information of all the growing ' s that the user wants to perform each one separated by newlines . Each instruction must have at least 3 columns separated by tabulations : ( 1 ) name of the fragment ' s PDB file ( 2 ) atom name of the core ( if the user wants to add the H it must be separated by " - " example : C4 - H2 ) ( 3 ) atom name of the fragment . If the line has more than 3 columns it will be considered as successive growing ' s simulations following the same structure previously mentioned but several times .
def read_instructions_from_file(file):
    list_of_instructions = []
    with open(file) as sf:
        instructions = sf.readlines()
        for line in instructions:
            if 0 < len(line.split()) <= 3:
                try:
                    fragment_pdb = line.split()[0]
                    core_atom = line.split()[1]
                    fragment_atom = line.split()[2]
                    ID = "{}{}{}".format(os.path.splitext(fragment_pdb)[0], core_atom, fragment_atom)
                    task = (fragment_pdb, core_atom, fragment_atom, ID)
                    list_of_instructions.append(task)
                except IndexError:
                    logger.critical("Check that the serie file {} contains: 'PDB_fragment_file'\t'PDB_core_atom_name'\t'PDB_fragment_atom_name' ".format(file))
            elif len(line.split()) > 3:
                growing_counter = len(line.split()) / 3
                successive_tasks = []
                for i in range(int(growing_counter)):
                    try:
                        fragment_pdb = line.split()[i * 3]
                        core_atom = line.split()[(i * 3) + 1]
                        if "*" in core_atom:
                            fragment_number = re.findall(r'[*]\d[*]', core_atom)[0].strip("*")
                            core_atom = core_atom.replace("*{}*".format(fragment_number), "")
                        else:
                            fragment_number = None
                        fragment_atom = line.split()[(i * 3) + 2]
                        ID = "{}{}{}".format(os.path.splitext(fragment_pdb)[0], core_atom, fragment_atom)
                        task = (fragment_pdb, core_atom, fragment_atom, ID, fragment_number)
                        successive_tasks.append(task)
                    except IndexError:
                        logger.critical("Check that the serie file {} contains: 'PDB_fragment_file'\t'PDB_core_atom_name'\t'PDB_fragment_atom_name' ".format(file))
                list_of_instructions.append(successive_tasks)
    return list_of_instructions
def read_instructions_from_file ( file ) : list_of_instructions = [ ] with open ( file ) as sf : instructions = sf . readlines ( ) for line in instructions : if 0 < len ( line . split ( ) ) <= 3 : try : fragment_pdb = line . split ( ) [ 0 ] core_atom = line . split ( ) [ 1 ] fragment_atom = line . split ( ) [ 2 ] ID = "{}{}{}" . format ( os . path . splitext ( fragment_pdb ) [ 0 ] , core_atom , fragment_atom ) task = ( fragment_pdb , core_atom , fragment_atom , ID ) list_of_instructions . append ( task ) except IndexError : logger . critical ( "Check that the serie file {} contains: 'PDB_fragment_file'\t'PDB_core_atom_name'\t'PDB_fragment_atom_name' " . format ( file ) ) elif len ( line . split ( ) ) > 3 : growing_counter = len ( line . split ( ) ) / 3 successive_tasks = [ ] for i in range ( int ( growing_counter ) ) : try : fragment_pdb = line . split ( ) [ i * 3 ] core_atom = line . split ( ) [ ( i * 3 ) + 1 ] if "*" in core_atom : fragment_number = re . findall ( r'[*]\d[*]' , core_atom ) [ 0 ] . strip ( "*" ) core_atom = core_atom . replace ( "*{}*" . format ( fragment_number ) , "" ) else : fragment_number = None fragment_atom = line . split ( ) [ ( i * 3 ) + 2 ] ID = "{}{}{}" . format ( os . path . splitext ( fragment_pdb ) [ 0 ] , core_atom , fragment_atom ) task = ( fragment_pdb , core_atom , fragment_atom , ID , fragment_number ) successive_tasks . append ( task ) except IndexError : logger . critical ( "Check that the serie file {} contains: 'PDB_fragment_file'\t'PDB_core_atom_name'\t'PDB_fragment_atom_name' " . format ( file ) ) list_of_instructions . append ( successive_tasks ) return list_of_instructions
It reads an "instruction file".
It reads an " instruction file " .
"""
    It reads an "instruction file". This file contains the information of all the growing's that the user wants to
    perform, each one separated by newlines. Each instruction must have at least 3 columns, separated by tabulations:
    (1) name of the fragment's PDB file,
    (2) atom name of the core (if the user wants to add the H it must be separated by "-", example: C4-H2),
    (3) atom name of the fragment.
    If the line has more than 3 columns, it will be considered as successive growing's simulations, following the same
    structure previously mentioned but several times.
    :param file: filename of the instructions file.
    :return: list with all instructions processed.
    """ # Read from file the required information # Get fragment number and remove part of string
list with all instructions processed.
list with all instructions processed .
file
filename of the instructions file.
filename of the instructions file .