Exemple #1
0
 def test_threshold(self):
     """Optional parameter should influence the result."""
     result = calc_consensus_secstruc_for_dbn(BASIC_EXAMPLE) # default 1.0
     self.assertEqual(result,'.............')
     result = calc_consensus_secstruc_for_dbn(BASIC_EXAMPLE, 1.0)
     self.assertEqual(result,'.............')
     result = calc_consensus_secstruc_for_dbn(BASIC_EXAMPLE, 0.51)
     self.assertEqual(result,'..(((...)))..')
     result = calc_consensus_secstruc_for_dbn(SECSTRUCS, 0.625)
     self.assertEqual(result,
             '..........((....)).((((((((..........))))))))..............')
Exemple #2
0
 def test_long(self):
     """Profiling long example."""
     secstrucs = []
     for line in open(os.path.join('test_data', 'long_test.txt')):
         secstrucs.append(line.strip())
     result = calc_consensus_secstruc_for_dbn(secstrucs)
     self.assertTrue(len(result), len(secstrucs[0]))
Exemple #3
0
 def test_valid_threshold(self):
     """The threshold parameter must be between 0.5 < x <= 1.0."""
     self.assertRaises(ConsensusSecstrucError,
                       calc_consensus_secstruc_for_dbn, BASIC_EXAMPLE, -0.8)
     self.assertRaises(ConsensusSecstrucError,
                       calc_consensus_secstruc_for_dbn, BASIC_EXAMPLE, 0.0)
     self.assertRaises(ConsensusSecstrucError,
                       calc_consensus_secstruc_for_dbn, BASIC_EXAMPLE, 1.01)
     result = calc_consensus_secstruc_for_dbn(BASIC_EXAMPLE, 0.500001)
Exemple #4
0
 def test_low_threshold(self):
     """Tests consensus secstruc with very low threshold
     """
     result = calc_consensus_secstruc_for_dbn(BASIC_EXAMPLE, 0.4)
     self.assertEqual(result, '..(((...)))..')
     
     self.assertRaises(ConflictInBasePairsError,
                       calc_consensus_secstruc_for_dbn,
                       BASIC_EXAMPLE, 0.2) # konflikt w resztach!
Exemple #5
0
    def test_rnastrand_long(self):
        """Two long examples from the RNAstrand database: CRW_00544 & CRW_00528
        """
        # CRW_00544
        # contextfold
        pred_1 = '(((.((((....(((.........)))..................(((((((....((((...................................(((...........)))......((((((.....((((....))))......))))))((((.....((((((.((((((((....))))).........((((((...................)))).))...(((.......((((.((((((.......)))..)))....)))).....))).....(((((((.....)))))))...........((((.((((((((((.(((((((..........)))))))............(((((((........((((((((..........................((((.((((((((((((((.................................)))))))))...(((((((((((((.(((........((((((........((((....((((.............((((..((((((((((............))))))))))..))))...........(((((((......))))))).....(((((((....)))))))..(((((((.......)))))))...............((....)).................(((((.....((((....((((((...........))))))...))))....))))).....))))....)))).(((((.(((.....(((.........)))...)))...)))))........................(((((((.((((..(((.((((((((...((((((((((((((((((.......)))).((....))...........................)))))))))))))).......((((((....(((((.((((((.(.......).).((...(((..((((........)))).)))..))))))).))))).((.......)).......))))))....)))))))).........(((((....)))))...............)))))))))))).))((((.....((((..(((((((.(((....(((((((..(((((...(((.(((((((((((.....(((((((((((((......((((.(((.......((...................))....))))))).((..(((((((((........))))))))).......))......................)))))))....(....)..............................)))))).....(((((((.......))))..........(..(.......((.(((((((((((((((......(((............(((............)))....((((((..(((((((((((((.......(((((((((((...)))))))))))((((......((..((((((((.....(((((((........(........).(((((((((...((((.........))))((((((((((((((((..((((((((................)))))))).........(.......)...........))))))))))))))))........)))))))))....))))))).........))))))))..))......))))...((((((((((.((........)).))))))))))......)))))))))))))...............(((((((........(((........(((((((...)))))))....))))))))))............)))))).........................(((((....))))).............(((((...........)))))))).....((((((.(((.........))).)).))))...))))))))..((((((....))))))))))))).))....)..).......)))........................................(((((....((((((((..((((....))))..))))))))..)))))))))))))))).)))....)))))...))))))).....(((((...)))))............)))...))))))).((((((.((((((............)))))).)))))).....))))........................((((((((((((.....(((...((((........((((...))))..((((((((((((...............((((.((((.........)))).))))(((((..(((...((((.(((.(((((........))))).))).))))...)))..))))).......))))))))))))........))))...)))....))))))))))))....))))....)))))))))...)))))))))))))....)))))))))((((((.((.((((((((.................((((((((.((......(.(......(((((.((....((((((((....((((((...(........((((((((((.(((((.....(((((..(..((...(((((.....)))))..((((((....((.(((.....))).))...))))))..))..)..))))))))).).)))))))))))..))))))......))))))))....))..)))))......).).....)))))))))).....................((((((.....))))))..................))))))))...)).))))))..........)))))))).....(((((........)))))...)))))))(((((((.....((((((((((......)))))..........(((((((((.....(((((((((.................((((....)))).............(....).))))))))))))))))))...((.((((((((......)))))))).))....(((((....)))))........)))))...)))))))...........................)))))))))).)))).(((((((((..(((((...)))))...)))))))))(((((((.((((........(((((((...))))))).............((((((.(((((((...(((((((((((......................(((((........)))))..(((((.......(((.......)))..........((((....))))((.....(((....))).).)........))))))))))))...(............(((((.......(.((((((((((..((((.(((.((((((((...((.......))...)))))))..))))................((((((((((.....(((((...(((........(((((.....)))))..........................(((((((....))).)))).(((((...........)))))..............)))....)))))........)))....))))))).)))).)))))))))).))))))...........)........)))).)))))))))))))...)))))))))))...............))).))))))...((((................)))).....))))........)))).))))))).)))).)))..(((((((((((((((((..((...((((((((.........))))))))...................((((((((((..(((((..((((((.(.......(((((((....))))))).........).))))))..).)))).)))))))))).)).))))))))...(((((((...((((((((......))))))))..))))))))))))))))........((((.........(((((((.....))))))).....))))............'

        # unafold
        pred_2 = '............(..(((...((((..........(((((((((.(((((((...(((((.......((....(((((.................(((....)))....(((((((...............(((((((((((.((((.....((((.((((..(((((.((((((((....)))))..((((((..((((((((((.....)))))....)))))..............((((.(((..((....(((((((..(((((((...((((((.((((((..(((((......((((((((((((.........(((((((((...(((((((..........)))))))..))))))))).(((..(((((.......)))))...)))................))))))))))))......)))))...)))))).))))))......)))))))...(((((((((.....((((((..(((((.....((((((.(((((............((((((((((............((((..((((((((((.(((.....)))))))))))))..)))).............)))))))))).((((((......(((((((....)))))))..(((((((.......)))))))...............((....)).....((((((...(((((((((..((((((....((((((..((....)).))))))...))))))...((((((.........((((.((.......)).....((((((((((((...(((..(.((((((((.(((((((((....((..((.(((((((((((...(((((.(((((.......(((((((((((((((((((...)))))).((....)).(((..(((......)))....)))..))))))))))))))))))......(((((..(((((.(((((..((((......))))...((((.((((........))))))))....))))).)))))((((....(((((........)))))...)))).............(((((....))))).))))).........)))))))))))).)).)).))..)).....(((((((((((........))))).)))))).)))))))))..)))))))).)..)))((((((((..(...(((.......))).(((...(((((.....(((......)))...........(((((((((........))))))))).............)))))..)))....)..))))))))...((((.(((((((((((((((....(((((..((((((..((((........)))).(((.(((((.((((....((((.((((....)))))))).......))))))))))))....))))))(((...............)))......))))).......(((((((((((.((((((((((((...)))))))))))).............((((((((.((..(((((((...((((....)))).((((((((((((.((((.....))))......(((((((((((((((((..(((........(((((((....(((....)))....)))))))...........)))..)))))))))))))))))........)))))))))))).)))))))......)).)))))))).))))))))))).....((((((((((.(((......))).)))))))))).)))))))))))))))))))..(((((......(((((((((((((...(((.((((.(((.((.((((((.((((((....))))..)).)))))).)).)))))))..........................(((((....)))))(..((((((..(((((..((((((((.(((..((((......((((((.((((.......)))).)).))))...))))..(((.....)))..))))))))).)).)))))))))))..)..((((.(((.....(((((((.(((((((.(((((((((......(((((((....((((((((..((((....))))..))))))))..)))))))..........((((((((((((((....)).))))))))))))...............)))))))))...((((.((((.............))))..))))))))))))))))))..)))))))..)))..)))))))))))))..(((((((((((((((((((......((((((((..(((.....)))...(((((((((((((((..((.(((((((......)).))))).))..))..)))))))))))))............))))))))..(((((....((((((..(....)..))))))..)))))..)))))))))...((((((((...))))))))..)))))))))).)))))....((((((((......))))..)))))))))).)))))).))))..(((.....))).)))))).............)))))))))..))))))))))))..))))).)))))).((((((((..............(..((((.((((((((((..(((((.....(((((((((.(...(((((.....)))))..((((((((..((.(((.....))).)).))))))))).)))))..)))))))))...))))))))))..))))..)..(((((((...((((......))))...))))))).))))))))...)))))..))))))...))))))))))))))))..))..)))))))...)))))).....))).))..)))..))))))))..((((((..((((..(((...((((((......)))))).(((.((((......(((....)))............((((((((((((((..(((((((((.....(((((((((......((....((((...(((((........)))))...))))...))))))))))))))))))))...((.((((((((......)))))))).))......))))))))).)))))....)))))))..)))..))))...)))))).........)))).))))))))))).......((((((((((((((((...))))))).)))))))))(((((((.((((...(((((....(((((((((..(((((...(((((((......((..((((...((..(((((((.....(((((.......)))))(((((........)))))..((((((((....)))....(((((((...(((...((((....))))...))).(((....))).))))).))...))))))))))))..))...))))..))..))))))).)))))(((((((((((.((((.((..((((((((.((.(((....))).))))))))).)..))...(((....)))..(((((((((((((..(........)..)).)))..(((((.....)))))......((((...((..(((((....(((((((....))).)))).(((((.(((....)))))))).............(((....))))))))..))....)))).)))))))))))))))))))))))......)))))))))...((((((....)))))).....)))))....))))))))))))))).)))...)))))....))....(((.(((((.......))))))))...................))))))))))))....((((((((((((((((((((((((((.((((((((((((.........)))))))).....)))).)).......((((((((((..((((...((((((((((.....(((((((....)))))))..)))).....))))))....)))).))))))))))....))))))))...(((((((...((((((((......))))))))..))))))))))))))))......))))))).)))))))))(((((.....)))))........)))).)))..)....'
        
        cutoff = 0.4
        
        dbns = [pred_1, pred_2]
        try:
            cutoff, consensus = calc_consensus_secstruc_for_dbn(dbns, threshold=cutoff)
        except ConflictInBasePairsError, error:
            conflicting_bps = BasePairs(eval(str(error).split('\'')[1]))
            solve_conflicts(conflicting_bps)   
            consensus_pred = conflicting_bps.toVienna(len(pred_1), 0)
            self.assertTrue(type(consensus_pred), ViennaStructure)
Exemple #6
0
 def test_identity(self):
     """If there is only one, the same seq should be returned."""
     seq = '(.(.(..).))'
     result = calc_consensus_secstruc_for_dbn([seq])
     self.assertEqual(result, seq)
Exemple #7
0
 def test_calc_consensus_secstruc(self):
     """Calculates a consensus secstr. from a list of dot-bracket strings."""
     result = calc_consensus_secstruc_for_dbn(SECSTRUCS, 1.0)
     self.assertEqual(len(result),len(SECSTRUCS[0]))
     self.assertEqual(result,CONSENSUS)
Exemple #8
0
        else:
            self.assertTrue(False)
            
        # CRW_00528
        # ContextFold
        pred_3 = '.((((...(((((((((((.(.((((..((((((((((........((((..(((........((((((.................(((........)))..................((((((.....(((....))).........))))))((((((((..((((.....))))..)).))))))(((......)))........))))))......((......(((((((..........))))))).......))................)))...((((.((((((((((((((((((.......))))))).)))))).))))))))).(((.(((((((((.(.(((((((((.....(((.(((((((((.....(((((((......(((((....)))))...(...).(((.......))))))))))....)))))))))..)))...)))))))))).))))))))).)))......(((((((........)))))))....(((((.((....)).)))))..)))).......)))))).)))))))).).........((....))................((((....))))...................)))))))))))............................................(((((....................(((((....))))).......(((((..........((((((...))))))..(((((((((((((((((........(((((..(((((((((((((((((........(((((..(............))))))................))))))))))))))))).)))))...))))))))))))))))).(((((....((((..((((((.......((((((((((......((((((..(((((....(((((((((((((.(((((((....))))))))))))))))))))......)))))..))))))((((((((((((((.........))))))))..(((....)))..)))))).....)))))))))).........)))))).)))).....))))).......)))))((((........)))).......((((((((((((((..(((((............((((...........))))....)))))..................((((((((((((.........)))))))).((((.........))))...........))))..((((((......))))))........))))))))))))))..))))).)))).....(((((((((((.....(...(((((((....)))))))..).................(((.......)))........))))))))))).(((...((.((........)).))....)))(((..(((((.(..(.(((((..........((((((((((...(((((....)))))...)...............(((((..((((((.....)))))).)))))...)))).)))))..........))))).)....)....)))))..)))(((((.(((.((..........)).))))))))((((.(((((.....))))).))))....(((((((..((....((((((....((((.......(((((((........(((((...(((.(((((((((..(((((............)))))...........((((.....((((........))))......))))))))))))))))........)))))....)))))))))))....))))))((((((((((..(.......((((....))))....)...)))))))))).............((((..(((......((((((.((....))))))))...)))..))))....(((((((...((((.....((...............(((((((.(((((((.((((....(((((((((.(.(((.......((....((((.....))))....))....(((....)))))).).)))))(.((((..(((((((....))))))).....)))))..............(((((........)))))........(((((((((((((............(((....))).............((((((...((((.((((.((((..(((((((.......))))))).........((((((((((....((((.....))))....)))))))))).....(((..((((((((....(((((((((....)))))))))......))))))))..)))........(((((((((....)))))))))....))))..)))).)))).........))))))........(((((...((((((.(((((((............))))))).)))))))))))...)))))))))).)))................)))).....)))).))).)))).)))))))....(((...)))............((((((((.(((.(((..........(((((....(....).....)))))(..(((((((((((((.((((((..((((.(((((.((((..(((((...((..((((((((((........................))))))))))..))...)))))..)))).))))).))))....................((((..(((((....))))).))))))))))........)))))))..)))))).).............(((((((((.(((((.............((((((((....((((....)))).....)))))))).....(((.((.((((((...........((((........))))..)))))).))....))).((((((.......))))))...(((((......))))).(((((.......))))).......))))).....)).)))))))))).))).)))))))).....))....)))).((((((........)))))).........((((........))))(((((((((..((((((((.(((((((((((((((((((((((..........(((((..((((((((.(((((((((........)))))))))....))))))))............))))).)))))).))))))))))).............((((((((((....((.....(((((......(((..((.............))..)))..)))))....))....))))))))))(((((.(((((....)))))...))))))))))).)))))))..((.((((((((...........))))))))))...)..)))))))))...........((((((((......((((((...(.(.((.......((((((((.......)))))))).((((....)))))).)..)...))))))(((..((((...))))..)))..((((((((..((((.....((((.(((...((((((((..............(((((.......)))))(((...)))...))))))))..)))))))......((((((((((((((.(((((((.......))))))).)....((.........))....)))))))..)..)))).).....(((((((....))).))))....((((..((((.(((........(((((((.....)))))))....)))..))))..)))).....(.((((((...(.(....).)..)))))).)(((((..........((((((((((....)))))..)))))........))))).(((....(((((............)))))....))).........((((((.....))))))(((((((((.......(((((((....)))))))(((((.......)))))..((.........((((((((.((((((((.............)))))))).......))))))))........))((((.(((((((((((((((((((((....))))))))))))))))))))).))))...........)))))))))......)))).........((((....))))))))))))......))))))))(((((......))))))))))))...))..)))))))...............'

        #unafold
        pred_4 = '..(((((.(((((.....((..(((.((((((((((((...((...((((........((((.................((..((((((.(((((((.....((((...........(((((((((((.(((....))).))))....)))))))(((((((..((((.....))))..)).))))).))))..(((((..((((.........))))..)))))................)))))))...))))))..)).................(((((((((....(((((((((((((((.......))))))).))))))))(((..(((.....((..(((((((.(((..((((.....(((((((...((((((((((................((((....))))......((((.....))))........)))))))))))))))))...))))..))).)))))))..))...)))..))).)))))))))......)))).....(((((((......))))))).))))..))...))))))).)))))..)))..))....((....))..)))))............(((.((((((......(((((((((((..(((((.......))))).....((((((....(((((((((((.(((((((..((((...))))..))))....))).)))))))))))((((((((((....((((((((((......(((((((((....((((((((((((((((((......((((((..((..(..((((((((((((....(((..(((((..(((.....)))..).))))..))).....)).))))))))))..)..)).)))))).)))))))))))))))))).......(((((((..((((((((((((((..((.((((((((.......))))))))..((..(((((((((((.(((((((....))))))))))))))))))..))..))......)))).))))))..))))..)))))))(((((((..((((((.((((.....((((((((.........(..(((((((....((((((((((...........(((((((((...(((((((......(((((.((..((((((((((((((..((....................((((...(((((((((((((....)))))))...))))))..)))).....(((((((((........)))...))))))..)).....((((((((((((..............))))).))).))))..))))))))))))))..))...(((((((...(((((((((((.........(((((((....)))))))....((.(((.(((.(((....)))))).))).))......)))))))))))...(((........))).)))))))......)))))....((....))....)))))))...))).))))))....(((((....)))))..)))))))))))))))))..).(((((..((.....))..)))))))))))))..........((((((((((.(((((....((((((...(((((((.(((..((...................((((((...(((.((((.........((((...((((....))))..)))).........)))).))).....)))))).(((((((((....(((((((((.......(((.....(((....)))......)))..(((((((((.((((.(((........))))).))........((((((...........))))))))))))))))))))))))..(((((((((((((........(((((....)))))......))))))))))).))........)))))))))..))..))).))))))).(((((((((.(((......(((((..(((...(((....)))....)))..........(((((..((((((.(((...(((((((..((((.......))))...))))))).....(((((...(((....)))..)))))..))).)))))).((((......((((((((....)))))))).....)))).)))))..))))).(((((........))))).)))....(((((((((((((..(((....((((.((((((...............((((......(((.((((((((((((.(((((.......)))))..........(((((((((((....((((.....))))....)))))))))))..(((((..((((((((..(((((((..((....))..))).))))...))))))))..))).)).....(((((((((....)))))))))))).))).)))))).)))(((((.....)))))......))))......(((((..(((..........)))..))))).)))))).)))).)))...)))))))))).)))............((((.((((((.(((......)))..(((((((.....)))).))).....................(((((((((((((.......((((......))))..((((((..(.(((((((((((((...((.((((.(((((.((((..(..(((((..(((..((((((((((..(((..(((.....)))..))).)))))))))).)))..))))))..)))).))))).)))).)).................((((..(((((....))))).))))..............)))))))..))))))........(((((..(((((((((...............((((((((((((....((((....)))).....)))))))..(((((((((...(((((....((((.((((((........)))))).)))).)))))...)))))))))..)))))...............(((.((((..((((((.......)))))).))))...))).....)).)))))))..)))))((((((((((...((((......((((((..((...(((((((......(((((((((........)))))))))......((((((((..((((.(((((((((((((((((..((.((((..((....(((((((((..((((((((......)))))))).....)))))))))....))...)))).))..)))))).))))))))))).(((((.......(((.(((((...(((((((..(((.....))).)))))))....)))))....(((....(((((((....)))))))...))).)))....(((((....)))))..)))))..))))..)))))))).((.((((((((...........)))))))))).....)))))))........(((..((((((((..((((.....(((....((((...((.((((((((((.....)))))))))).))...))))....)))...((((((((((...((((.(((((.......))))).......)))).))))))).))).....))))..))).)))))..))).))..)))))).....))))..)))))).))))....)..))))))...)))))))).)))))...)))))))))).))))).)))).....))))))....)))))..(((((..(..(((.((..((((...(((((((....))).))))......))))..)).)))..)..)))))....)))))))))).........)))).))))))..((((.(((((((....((((.......((((((.......))))))...(((((.((((((....)))))))))))....)))).....)))))))....))))...))))))).((((((........))))))........)))))))))..))))))))))...........(((((.(((((((((....((((((((.((((....))))...))))))))))))))))))))))....))))))))))(((.((((((((((............((((.((((((((((..(((((((((....)))))))))..)))))))))).)))).....(((((((........))))))).)))))))))))))))))))....)))).))))))).((((.((..(((((......)))))..))))))...)))))).))).))))).........'

        # consensus
        cutoff = 0.4
        dbns = [pred_3, pred_4]
        
        try:
            cutoff, consensus = calc_consensus_secstruc_for_dbn(dbns, threshold=cutoff)
        except ConflictInBasePairsError, error:
            conflicting_bps = BasePairs(eval(str(error).split('\'')[1]))
            solve_conflicts(conflicting_bps)
            consensus_pred = conflicting_bps.toVienna(len(pred_3), 0)
            self.assertTrue(type(consensus_pred), ViennaStructure)
        else:
            self.assertTrue(False)
        
    

class CalcConsensusSecstrucForBpsTests(TestCase):
    """
        Tests for calc_consensus_secstruc_for_bps
    """
    def setUp(self):