Exemple #1
0
def test_superimposer_atoms():

    from Bio.PDB.PDBParser import PDBParser

    code = '1ptq'
    fileName = testFilePath + code + '.pdb'

    fixedS = PDBParser().get_structure(code, fileName)
    movingS = PDBParser().get_structure(code, fileName)

    # TODO transform moving

    sup = Superimposer()
    sup.set_atoms(list(fixedS.get_atoms()), list(movingS.get_atoms()))

    assert sup.rms == approx(0.)
    return
Exemple #2
0
def test_compare():
    """
    Compare the result of the diSTruct superimposer to the biopython one.
    """

    from Bio import SeqIO
    from Bio.PDB import Superimposer as BPSuperimposer
    from Bio.PDB import PDBParser

    from distruct.tools.pdb import get_contacts

    code = '1ptq'
    fileName = testFilePath + code + '.pdb'

    refStructure = PDBParser().get_structure(code, fileName)
    contacts = get_contacts(refStructure[0], cutOff=5., minSeqDist=0)

    sequences = []
    with open(fileName, 'r') as f:
        sequences = [r.seq for r in SeqIO.parse(f, "pdb-seqres")]
        pass

    ds = Distructure('test', sequences,
                     [[r.get_id() for r in c if r.get_id()[0] == ' ']
                      for c in refStructure[0]])
    ds.generate_primary_contacts()
    ds.set_tertiary_contacts(contacts)
    ds.run()

    refStructure = PDBParser().get_structure(code, fileName)
    tempStructure = ds.copy()

    refAtoms = list(cull_atoms(refStructure.get_atoms(), ds))
    resAtoms = list(cull_atoms(tempStructure.get_atoms(), refStructure))

    assert len(refAtoms) > 3
    assert len(refAtoms) == len(resAtoms)

    dssup = Superimposer()
    dssup.set_atoms(refAtoms, resAtoms)
    dsRMSD = dssup.rms

    bpsup = BPSuperimposer()
    bpsup.set_atoms(refAtoms, resAtoms)
    bpRMSD = bpsup.rms

    for atom in resAtoms:
        atom.set_coord(-1 * atom.get_coord())
        pass

    bpsup.set_atoms(refAtoms, resAtoms)
    if bpsup.rms < bpRMSD:
        bpRMSD = bpsup.rms
        pass

    assert dsRMSD == approx(bpRMSD)

    return
Exemple #3
0
    if pdb_match:
        PDB = pdb_match.group(1)

    pdb_biomol_match = re.search(PDB_BIOMOL_REGEX, INPUT_FILENAME)
    if pdb_biomol_match:
        PDB = pdb_biomol_match.group(1)
        BIOMOL_ID = pdb_biomol_match.group(2)

    pdb_rcsb_asm_match = re.search(PDB_RCSB_ASM_REGEX, INPUT_FILENAME)
    if pdb_rcsb_asm_match:
        PDB = pdb_rcsb_asm_match.group(1)
        BIOMOL_ID = pdb_rcsb_asm_match.group(2)

    # LOAD STRUCTURE
    structure = PDBParser().get_structure('structure', INPUT_FILE)
    structure_atoms = list(structure.get_atoms())

    logging.info('Loaded PDB structure (BioPython).')

    # CONSTRUCT KDTREE
    neighborsearch = NeighborSearch(structure_atoms)

    logging.info('Constructured NeighborSearch.')

    # GET INTERACTIONS
    logging.info('Calculating interactions...')
    for interaction_level in 'ARC':

        if interaction_level in OUTPUTS:

            logging.info('Calculating interactions for {}s...'.format(
    if pdb_match:
        PDB = pdb_match.group(1)

    pdb_biomol_match = re.search(PDB_BIOMOL_REGEX, INPUT_FILENAME)
    if pdb_biomol_match:
        PDB = pdb_biomol_match.group(1)
        BIOMOL_ID = pdb_biomol_match.group(2)

    pdb_rcsb_asm_match = re.search(PDB_RCSB_ASM_REGEX, INPUT_FILENAME)
    if pdb_rcsb_asm_match:
        PDB = pdb_rcsb_asm_match.group(1)
        BIOMOL_ID = pdb_rcsb_asm_match.group(2)

    # LOAD STRUCTURE
    structure = PDBParser().get_structure('structure', INPUT_FILE)
    structure_atoms = list(structure.get_atoms())

    logging.info('Loaded PDB structure (BioPython).')

    # CONSTRUCT KDTREE
    neighborsearch = NeighborSearch(structure_atoms)

    logging.info('Constructured NeighborSearch.')

    # GET INTERACTIONS
    logging.info('Calculating interactions...')
    for interaction_level in 'ARC':

        if interaction_level in OUTPUTS:

            logging.info('Calculating interactions for {}s...'.format(