示例#1
0
文件: mapper.py 项目: bsmithers/hpf
 def _seed_alignment(self):
     # Build a Seed Alignment
     from hpf.pdb import get_seq, get_crystal
     #kdrew: this gets the atom record sequence and not the full sequence
     pdb_seq = get_seq(get_crystal(self._pdbid))
     #print "_seed_alignment pdb sequence: ", pdb_seq
     from hpf.amnh.align import SeedAlignmentFactory
     from Bio.SeqRecord import SeqRecord
     #kdrew: might change this to be pairwise2 alignment
     factory = SeedAlignmentFactory()
     alignment = factory.create(self._alignment,
                    [SeqRecord(pdb_seq,self._pdbid+"_atom_record")])
     return alignment
示例#2
0
    def buildPDBIndex(self, domain):
        # Now we have to build the mapper and index the columns it covers
        # This maps protein residues to the PDB structure record.
        from sqlalchemy.orm import object_session
        from hpf.hddb.db import PDBSeqRes
        parent_id = int(domain.parent_id[3:])
        session = object_session(domain)
        pdbseqres = session.query(PDBSeqRes).filter(
            PDBSeqRes.sequence_key == parent_id).first()

        protein_atom_mapper = ProteinToPDBAtom(self.protein,
                                               domain,
                                               self.alignment,
                                               pdbseqres=pdbseqres)
        # This maps protein residues to domain residues
        protein_domain_mapper = ProteinDomainMapper(self.domain)
        # This maps protein residues to alignment column numbers
        protein_alignment_mapper = ProteinAlignmentMapper(
            self.protein, self.alignment)

        # Simple structure object to use for indices
        structure = Structure(protein_atom_mapper._pdbid[0:4],
                              chain=protein_atom_mapper._pdbid[4])
        print >> sys.stderr, "Protein", structure.id, structure.chain, protein_atom_mapper._pdbid

        # Get the PDB object downloaded and parsed for the mapping.
        chain = get_crystal(protein_atom_mapper._pdbid, structure=True)

        # Run DSSP on the set if not already run.
        dssp = self.index.getDssp(protein_atom_mapper._pdbid)
        if dssp != None:
            print >> sys.stderr, "Using dssp", protein_atom_mapper._pdbid
        else:
            print >> sys.stderr, "Running dssp", protein_atom_mapper._pdbid
        features = DSSPFeatureSet(protein_atom_mapper, chain, dssp=dssp)
        self.index.setDssp(protein_atom_mapper._pdbid, features.dssp)

        # Iterate over the DSSP features and index them.
        for protein_res, xtra in features:
            column = protein_alignment_mapper[protein_res]
            domain_res = protein_domain_mapper[protein_res]
            structure_res = protein_atom_mapper[protein_res]
            attribute = ColumnStructureAttribute(column, self.protein,
                                                 protein_res, self.domain,
                                                 domain_res, structure,
                                                 structure_res, xtra)
            # This will index all of the attributes for later lookup and serialization.
            self.index.add(attribute)
示例#3
0
文件: dssp.py 项目: bsmithers/hpf
        Yields protein indices paired with DSSP scores.
        @return generator of (protein,chain[protein].xtra[key]) tuples.
        """
        atom_res = list(self.chain)
        for protein, structure in self.mapper:
            if protein == None or structure == None:
                continue
            xtra = atom_res[structure].xtra
            yield (protein, xtra)


if __name__ == "__main__":
    pdbid = "1n6j"
    from hpf.pdb import get_crystal

    pdb = get_crystal("1yelA", structure=True, pdir="/tmp")
    dssp = DSSP(pdb)
    print "done"
    print pdb
    for res in pdb:
        rasa = res.xtra[RASA] if res.xtra.has_key(RASA) else None
        print res.get_resname()[1], rasa

    from hpf.hddb.db import Session, Structure

    session = Session()
    pdb = list(session.query(Structure).get(1054611).pdb[0])[0]
    dssp = DSSP(pdb)
    for res in pdb:
        rasa = res.xtra[RASA] if res.xtra.has_key(RASA) else None
        print res.get_resname()[1], rasa