예제 #1
0
 def test_resid_slice_backward_key_in_seq(self):
     self.assertEqual(self.seq2.with_missing[fgr.resid_from_str("B:13"):fgr.resid_from_str("A:15"):-1],
                      "GGC&GAA")
     self.assertEqual(self.seq2.with_missing[:fgr.resid_from_str("A:15"):-1],
                      "CGGGC&GAA")
     self.assertEqual(self.seq2.with_missing[fgr.resid_from_str("B:13")::-1],
                      "GGC&GAAAG")
예제 #2
0
 def test_indexing_with_missing(self):
     self.assertEqual(
         self.seq2.with_missing.with_modifications[fgr.resid_from_str("A:13")], "I")
     self.assertEqual(
         self.seq2.with_modifications.with_missing[fgr.resid_from_str("A:13")], "I")
     with self.assertRaises(IndexError):
         self.seq2.with_modifications[fgr.resid_from_str("A:13")]
예제 #3
0
 def test_resid_slice_forward_key_in_seq(self):
     self.assertEqual(self.seq2.with_missing[fgr.resid_from_str("A:15"):fgr.resid_from_str("B:13")],
                      "AAG&CGG")
     self.assertEqual(self.seq2.with_missing[fgr.resid_from_str("A:15"):],
                      "AAG&CGGGC")
     self.assertEqual(self.seq2.with_missing[:fgr.resid_from_str("B:13")],
                      "GAAAG&CGG")
예제 #4
0
 def setUp(self):
     self.seq = fgs.Sequence("AUGCA",
                             list(map(fgr.resid_from_str,
                                      "A:14,A:15,A:15.A,A:16,A:18".split(","))), [], {fgr.resid_from_str("A:14"): "I", fgr.resid_from_str("A:16"): "Some Free Text"})
     self.seq2 = fgs.Sequence("AAA&GGG",
                              list(map(fgr.resid_from_str,
                                       "A:14,A:15,A:15.A,B:12,B:13,B:200.A".split(","))),
                              [{"model": None, "ssseq": 13, "res_name": "G", "chain": "A", "insertion": None},
                               {"model": None, "ssseq": 16, "res_name": "G",
                                   "chain": "A", "insertion": "D"},
                               {"model": None, "ssseq": 11, "res_name": "C",
                                   "chain": "B", "insertion": None},
                               {"model": None, "ssseq": 202, "res_name": "C", "chain": "B", "insertion": "A"}],
                              {fgr.resid_from_str("A:13"): "I",
                               fgr.resid_from_str("B:200.A"): "Hallo"}
                              )
예제 #5
0
 def setUp(self):
     # Full seq:
     # GGCAUACAUUCGUCCGG
     #   **** ***  ****
     self.seq1 = fgs.Sequence("CAUAAUUUCCG",
                              list(map(fgr.resid_from_str,
                                       "A:14,A:15,A:15.A,A:16,A:18,A:19,A:20,A:21,A:22,A:23,A:24".split(","))),
                              [{"model": None, "ssseq": 8, "res_name": "G", "chain": "A", "insertion": None},
                                  {"model": None, "ssseq": 10, "res_name": "G",
                                      "chain": "A", "insertion": "D"},
                                  {"model": None, "ssseq": 17, "res_name": "C",
                                      "chain": "A", "insertion": None},
                                  {"model": None, "ssseq": 20, "res_name": "C",
                                      "chain": "A", "insertion": "A"},
                                  {"model": None, "ssseq": 20, "res_name": "G",
                                      "chain": "A", "insertion": "B"},
                                  {"model": None, "ssseq": 25, "res_name": "G", "chain": "A", "insertion": None}])
     self.seq2 = fgs.Sequence("AAA&GGG",
                              list(map(fgr.resid_from_str,
                                       "A:14,A:15,A:15.A,B:12,B:13,B:200.A".split(","))),
                              [{"model": None, "ssseq": 13, "res_name": "G", "chain": "A", "insertion": None},
                               {"RESID": "A:16.D", "res_name": "G"},
                               {"RESID": fgr.resid_from_str(
                                   "B:11"), "res_name": "G"},
                               {"model": None, "ssseq": 202, "res_name": "C", "chain": "B", "insertion": "A"}])
예제 #6
0
 def test_indexing_with_resid(self):
     self.assertEqual(self.seq[fgr.resid_from_str("14")], "C")
     self.assertEqual(self.seq[fgr.resid_from_str("15")], "A")
     self.assertEqual(self.seq[fgr.resid_from_str("15.A")], "U")
     self.assertEqual(self.seq[fgr.resid_from_str("16")], "A")
     self.assertEqual(self.seq[fgr.resid_from_str("18")], "A")
     self.assertEqual(self.seq[fgr.resid_from_str("A:24")], "G")
     with self.assertRaises(LookupError):
         self.seq[fgr.resid_from_str("B:24")]
     with self.assertRaises(LookupError):
         self.seq[fgr.resid_from_str("15.C")]
     with self.assertRaises(LookupError):
         self.seq[fgr.resid_from_str("13")]
예제 #7
0
def _safe_resid_from_chain_res(chain, residue):
    try:
        return fgr.resid_from_str(str("{}:{}".format(chain, residue)))
    except ValueError as e:
        if residue.isdigit():
            with log_to_exception(log, e):
                log.error("Chain is '{}', res is '{}'".format(chain, residue))
            raise
        else:
            warnings.warn("Illegal residue number: '{}'.".format(residue))
            return
예제 #8
0
def _safe_resid_from_chain_res(chain, residue):
    try:
        return fgr.resid_from_str(str("{}:{}".format(chain, residue)))
    except ValueError as e:
        if residue.isdigit():
            with log_to_exception(log, e):
                log.error("Chain is '{}', res is '{}'".format(chain, residue))
            raise
        else:
            warnings.warn("Illegal residue number: '{}'.".format(residue))
            return
예제 #9
0
 def test_resid_slice_key_not_in_seq(self):
     # Forward
     self.assertEqual(self.seq2.with_missing[fgr.resid_from_str("A:13"):fgr.resid_from_str("A:16.D")],
                      "GAAAG")
     self.assertEqual(self.seq2.with_missing[fgr.resid_from_str("B:11"):],
                      "CGGGC")
     self.assertEqual(self.seq2.with_missing[:fgr.resid_from_str("B:11")],
                      "GAAAG&C")
     # Backwards
     self.assertEqual(self.seq2.with_missing[fgr.resid_from_str("A:16.D"):fgr.resid_from_str("A:13"):-1],
                      "GAAAG")
     self.assertEqual(self.seq2.with_missing[:fgr.resid_from_str("B:11"):-1],
                      "CGGGC")
     self.assertEqual(self.seq2.with_missing[fgr.resid_from_str("B:11")::-1],
                      "C&GAAAG")
예제 #10
0
    def setUp(self):
        bgs = fgb.BulgeGraph.from_fasta_text(fasta)
        self.trafo1 = fgt.BGTransformer(bgs[0])
        self.trafo2 = fgt.BGTransformer(bgs[2])
        self.trafo3 = fgt.BGTransformer(bgs[3])

        self.bg1_condensed = bgs[1]

        missing_residues = list(map(
            lambda x: fgs.MissingResidue(fgr.resid_from_str(x[:-2]), x[-1]),
            ["A:2_C", "A:5_G", "A:6_C", "A:8_A", "A:9_U", "A:10_G", "A:11_C",
             "A:14_G", "A:15_G", "A:17_C", "A:18_C", "A:20_G"]
        ))
        self.bg1_condensed.seq._set_missing_residues(missing_residues)
예제 #11
0
    def setUp(self):
        bgs = fgb.BulgeGraph.from_fasta_text(fasta)
        self.trafo1 = fgt.BGTransformer(bgs[0])
        self.trafo2 = fgt.BGTransformer(bgs[2])
        self.trafo3 = fgt.BGTransformer(bgs[3])

        self.bg1_condensed = bgs[1]

        missing_residues = list(
            map(
                lambda x: fgs.
                MissingResidue(fgr.resid_from_str(x[:-2]), x[-1]), [
                    "A:2_C", "A:5_G", "A:6_C", "A:8_A", "A:9_U", "A:10_G",
                    "A:11_C", "A:14_G", "A:15_G", "A:17_C", "A:18_C", "A:20_G"
                ]))
        self.bg1_condensed.seq._set_missing_residues(missing_residues)
예제 #12
0
 def test_resid_slice_backward(self):
     self.assertEqual(self.seq[fgr.resid_from_str(
         "18"):fgr.resid_from_str("15"):-1], "AAUA")
     self.assertEqual(self.seq[fgr.resid_from_str("18")::-1], "AAUAC")
     self.assertEqual(self.seq[:fgr.resid_from_str("15"):-1], "GCCUUUAAUA")
예제 #13
0
 def test_resid_slice_forward(self):
     self.assertEqual(self.seq[fgr.resid_from_str(
         "15"):fgr.resid_from_str("18")], "AUAA")
     self.assertEqual(self.seq[:fgr.resid_from_str("18")], "CAUAA")
     self.assertEqual(self.seq[fgr.resid_from_str("15"):], "AUAAUUUCCG")
예제 #14
0
 def test_indexing_with_resid_without_missing(self):
     self.assertEqual(self.seq1[fgr.resid_from_str("A:14")], "C")
     with self.assertRaises(IndexError):
         self.seq1[fgr.resid_from_str("A:8")]
예제 #15
0
 def test_indexing_with_resid(self):
     self.assertEqual(
         self.seq1.with_missing[fgr.resid_from_str("A:14")], "C")
     self.assertEqual(
         self.seq1.with_missing[fgr.resid_from_str("A:8")], "G")
예제 #16
0
 def test_iter_modifications(self):
     self.assertEqual(list(self.seq2.iter_modifications()),
                      [(fgr.resid_from_str("A:13"), "I"),
                       (fgr.resid_from_str("B:200.A"), "Hallo")]
                      )
예제 #17
0
 def test_indexing_resid(self):
     self.assertEqual(
         self.seq.with_modifications[fgr.resid_from_str("A:14")], "I")
     self.assertEqual(self.seq2.with_modifications[fgr.resid_from_str("A:14"):fgr.resid_from_str("B:200.A")],
                      [["A", "A", "A"], ["G", "G", "Hallo"]])