Beispiel #1
0
def get_atom_lines_from_input(input_file, tags=['ATOM  ', 'HETATM']):
    lines = propka.lib.open_file_for_reading(input_file).readlines()
    conformation = ''

    atoms = {}
    numbers = []

    for line in lines:
        tag = line[0:6]

        # set the conformation
        if tag == 'MODEL ':
            conformation = line[6:].strip()

        # found an atom - save it
        if tag in tags:
            atom = Atom(line=line)
            atom.get_input_parameters()
            atom.groups_extracted = 1
            atom.is_protonated = True
            atoms[atom.numb] = atom
            numbers.append(atom.numb)

        # found bonding information - apply it
        if tag == 'CONECT' and len(line) > 14:
            conect_numbers = [
                line[i:i + 5] for i in range(6,
                                             len(line) - 1, 5)
            ]
            center_atom = atoms[int(conect_numbers[0])]
            for n in conect_numbers[1:]:
                b = atoms[int(n)]
                # remember to check for cysteine bridges
                if center_atom.element == 'S' and b.element == 'S':
                    center_atom.cysteine_bridge = True
                    b.cysteine_bridge = True
                # set up bonding
                if not b in center_atom.bonded_atoms:
                    center_atom.bonded_atoms.append(b)
                if not center_atom in b.bonded_atoms:
                    b.bonded_atoms.append(center_atom)

        # found info on covalent coupling
        if tag == 'CCOUPL' and len(line) > 14:
            conect_numbers = [
                line[i:i + 5] for i in range(6,
                                             len(line) - 1, 5)
            ]
            center_atom = atoms[int(conect_numbers[0])]
            for n in conect_numbers[1:]:
                cg = atoms[int(n)]
                center_atom.group.couple_covalently(cg.group)

        # found info on non-covalent coupling
        if tag == 'NCOUPL' and len(line) > 14:
            conect_numbers = [
                line[i:i + 5] for i in range(6,
                                             len(line) - 1, 5)
            ]
            center_atom = atoms[int(conect_numbers[0])]
            for n in conect_numbers[1:]:
                cg = atoms[int(n)]
                center_atom.group.couple_non_covalently(cg.group)

        # this conformation is done - yield the atoms
        if tag == 'ENDMDL':
            for n in numbers:
                yield (conformation, atoms[n])
            # prepare for next conformation
            atoms = {}
            numbers = []

    return
Beispiel #2
0
def get_atom_lines_from_input(input_file, tags = ['ATOM  ','HETATM']):
    lines = propka.lib.open_file_for_reading(input_file).readlines()
    conformation = ''

    atoms = {}
    numbers = []

    for line in lines:
        tag = line[0:6]

        # set the conformation
        if tag == 'MODEL ':
            conformation = line[6:].strip()

        # found an atom - save it
        if tag in tags:
            atom = Atom(line=line)
            atom.get_input_parameters()
            atom.groups_extracted = 1
            atom.is_protonated = True
            atoms[atom.numb] = atom
            numbers.append(atom.numb)

        # found bonding information - apply it
        if tag == 'CONECT' and len(line)>14:
            conect_numbers = [line[i:i+5] for i in range(6, len(line)-1, 5)]
            center_atom = atoms[int(conect_numbers[0])]
            for n in conect_numbers[1:]:
                b = atoms[int(n)]
                # remember to check for cysteine bridges
                if center_atom.element == 'S' and b.element == 'S':
                        center_atom.cysteine_bridge = True
                        b.cysteine_bridge = True
                # set up bonding
                if not b in center_atom.bonded_atoms:
                    center_atom.bonded_atoms.append(b)
                if not center_atom in b.bonded_atoms:
                    b.bonded_atoms.append(center_atom)

        # found info on covalent coupling
        if tag == 'CCOUPL' and len(line)>14:
            conect_numbers = [line[i:i+5] for i in range(6, len(line)-1, 5)]
            center_atom = atoms[int(conect_numbers[0])]
            for n in conect_numbers[1:]:
                cg = atoms[int(n)]
                center_atom.group.couple_covalently(cg.group)

        # found info on non-covalent coupling
        if tag == 'NCOUPL' and len(line)>14:
            conect_numbers = [line[i:i+5] for i in range(6, len(line)-1, 5)]
            center_atom = atoms[int(conect_numbers[0])]
            for n in conect_numbers[1:]:
                cg = atoms[int(n)]
                center_atom.group.couple_non_covalently(cg.group)

        # this conformation is done - yield the atoms
        if tag == 'ENDMDL':
            for n in numbers:
                yield (conformation, atoms[n])
            # prepare for next conformation
            atoms = {}
            numbers = []


    return
Beispiel #3
0
def get_atom_lines_from_input(input_file, tags=['ATOM  ', 'HETATM']):
    """Get atom lines from a PROPKA input file.

    Args:
        input_file:  input file
        tags:  tags defining atom lines
    Yields:
        conformation container, list of atoms
    """
    lines = open_file_for_reading(input_file).readlines()
    conformation = ''
    atoms = {}
    numbers = []
    for line in lines:
        tag = line[0:6]
        # set the conformation
        if tag == 'MODEL ':
            conformation = line[6:].strip()
        # found an atom - save it
        if tag in tags:
            atom = Atom(line=line)
            atom.get_input_parameters()
            initialize_atom_group(atom)
            atom.groups_extracted = 1
            atom.is_protonated = True
            atoms[atom.numb] = atom
            numbers.append(atom.numb)
        # found bonding information - apply it
        if tag == 'CONECT' and len(line) > 14:
            conect_numbers = [
                line[i:i + 5] for i in range(6,
                                             len(line) - 1, 5)
            ]
            center_atom = atoms[int(conect_numbers[0])]
            for num in conect_numbers[1:]:
                bond_atom = atoms[int(num)]
                # remember to check for cysteine bridges
                if center_atom.element == 'S' and bond_atom.element == 'S':
                    center_atom.cysteine_bridge = True
                    bond_atom.cysteine_bridge = True
                # set up bonding
                if not bond_atom in center_atom.bonded_atoms:
                    center_atom.bonded_atoms.append(bond_atom)
                if not center_atom in bond_atom.bonded_atoms:
                    bond_atom.bonded_atoms.append(center_atom)
        # found info on covalent coupling
        if tag == 'CCOUPL' and len(line) > 14:
            conect_numbers = [
                line[i:i + 5] for i in range(6,
                                             len(line) - 1, 5)
            ]
            center_atom = atoms[int(conect_numbers[0])]
            for num in conect_numbers[1:]:
                cov_atom = atoms[int(num)]
                center_atom.group.couple_covalently(cov_atom.group)
        # found info on non-covalent coupling
        if tag == 'NCOUPL' and len(line) > 14:
            conect_numbers = [
                line[i:i + 5] for i in range(6,
                                             len(line) - 1, 5)
            ]
            center_atom = atoms[int(conect_numbers[0])]
            for num in conect_numbers[1:]:
                cov_atom = atoms[int(num)]
                center_atom.group.couple_non_covalently(cov_atom.group)
        # this conformation is done - yield the atoms
        if tag == 'ENDMDL':
            for num in numbers:
                yield (conformation, atoms[num])
            # prepare for next conformation
            atoms = {}
            numbers = []