Beispiel #1
0
    def testPdbId(self):
        pdbid = "1ddf"
        for loc in self.res:
            r = Residues("\t 1ddf \t" + loc[0] + "\t\n\n\n")
            self.assertEqual(r.pdbid, pdbid)
            self.assertEqual(str(r), pdbid + " " + loc[0])

            r = Residues(pdbid + " " + loc[0])
            self.assertEqual(r.pdbid, pdbid)
            self.assertEqual(str(r), pdbid + " " + loc[0])

            r = Residues("104l A:112-113")
            self.assertEqual(r.pdbid, "104l")
            self.assertEqual(r.fragments, (("A", "112", "113"), ))
    def getSeqMap(self, residues):
        """Get the sequence map for a collection of residues.

        Arguments:
         - residues -- A Residues instance, or a string that can be
           converted into a Residues instance.

        """
        if isinstance(residues, basestring):
            residues = Residues(residues)

        pdbid = residues.pdbid
        frags = residues.fragments
        if not frags:
            frags = (("_", "", ""),)  # All residues of unnamed chain

        seqMap = None
        for frag in frags:
            chainid = frag[0]
            if chainid in ["", "-", " ", "_"]:
                chainid = "_"
            id = pdbid + chainid

            sm = self[id]

            # Cut out fragment of interest
            start = 0
            end = len(sm.res)
            if frag[1]:
                start = int(sm.index(frag[1], chainid))
            if frag[2]:
                end = int(sm.index(frag[2], chainid)) + 1

            sm = sm[start:end]

            if seqMap is None:
                seqMap = sm
            else:
                seqMap += sm

        return seqMap
Beispiel #3
0
 def testJustPdbId(self):
     r = Residues("1sds")
     self.assertEqual(r.pdbid, "1sds")
     self.assertFalse(r.fragments)
Beispiel #4
0
 def testAstralParse(self):
     """Test if we can parse residue subsets enclosed in brackets."""
     for loc in self.res:
         r = Residues("(" + loc[0] + ")")
         self.assertEqual(r.fragments, loc[1])
Beispiel #5
0
 def testStr(self):
     for loc in self.res:
         r = Residues(loc[0])
         self.assertEqual(str(r), loc[0])
Beispiel #6
0
 def testParse(self):
     for loc in self.res:
         r = Residues(loc[0])
         self.assertEqual(r.fragments, loc[1])