示例#1
0
 def test_deep_copy(self):
     tree = EvolTree(WRKDIR + 'tree.nw')
     tree.workdir = 'examples/evol/data/protamine/PRM1/paml/'
     tree.link_to_evol_model(WRKDIR + 'paml/fb/fb.out', 'fb')
     fba = deepcopy(tree.get_evol_model('fb'))
     tree._models['fb.a'] = fba
     self.assertEqual(str(tree.get_evol_model('fb.a')),
                      str(tree.get_evol_model('fb')))
示例#2
0
 def test_run_slr(self):
     if which('Slr'):
         tree = EvolTree('((seq1,seq2),seq3);')
         tree.link_to_alignment('>seq1\nCTGATTCTT\n>seq2\nCTGATTCTT\n>seq3\nATGATTCTT\n')
         tree.run_model('SLR')
         self.assert_('Sitewise Likelihood R' in tree.get_evol_model('SLR').run)
         self.assert_('Positively selected s' in tree.get_evol_model('SLR').run)
         self.assert_('Conserved sites' in tree.get_evol_model('SLR').run)
         self.assert_('lnL' in tree.get_evol_model('SLR').run)
示例#3
0
 def test_deep_copy(self):
     tree = EvolTree (WRKDIR + 'tree.nw')
     tree.workdir = 'examples/evol/data/protamine/PRM1/paml/'
     tree.link_to_evol_model (WRKDIR + 'paml/fb/fb.out', 'fb')
     fba = deepcopy (tree.get_evol_model('fb'))
     tree._models['fb.a'] = fba
     self.assertEqual(str(tree.get_evol_model('fb.a')),
                      str(tree.get_evol_model('fb'))
                  )
示例#4
0
 def test_run_slr(self):
     if which('Slr'):
         tree = EvolTree('((seq1,seq2),seq3);')
         tree.link_to_alignment('>seq1\nCTGATTCTT\n>seq2\nCTGATTCTT\n>seq3\nATGATTCTT\n')
         tree.run_model('SLR')
         self.assert_('Sitewise Likelihood R' in tree.get_evol_model('SLR').run)
         self.assert_('Positively selected s' in tree.get_evol_model('SLR').run)
         self.assert_('Conserved sites' in tree.get_evol_model('SLR').run)
         self.assert_('lnL' in tree.get_evol_model('SLR').run)
示例#5
0
 def test_run_codeml(self):
     if which('codeml'):
         tree = EvolTree('((seq1,seq2),seq3);')
         tree.link_to_alignment('>seq1\nATGCTG\n>seq2\nATGCTG\n>seq3\nTTGATG\n')
         tree.run_model('fb')
         self.assert_('CODONML' in tree.get_evol_model('fb').run)
         self.assert_('Time used:' in tree.get_evol_model('fb').run)
         self.assert_('end of tree file' in tree.get_evol_model('fb').run)
         self.assert_('lnL' in tree.get_evol_model('fb').run)
         self.assert_(tree.get_descendants()[0].w > 0)
示例#6
0
 def test_run_codeml(self):
     if which('codeml'):
         tree = EvolTree('((seq1,seq2),seq3);')
         tree.link_to_alignment('>seq1\nATGCTG\n>seq2\nATGCTG\n>seq3\nTTGATG\n')
         tree.run_model('fb')
         self.assert_('CODONML' in tree.get_evol_model('fb').run)
         self.assert_('Time used:' in tree.get_evol_model('fb').run)
         self.assert_('end of tree file' in tree.get_evol_model('fb').run)
         self.assert_('lnL' in tree.get_evol_model('fb').run)
         self.assert_(tree.get_descendants()[0].w > 0)
示例#7
0
 def test_call_histface(self):
     tree = EvolTree (WRKDIR + 'tree.nw')
     tree.workdir = 'examples/evol/data/protamine/PRM1/paml/'
     tree.link_to_alignment  (WRKDIR + 'alignments.fasta_ali')
     tree.link_to_evol_model (WRKDIR + 'paml/M2/M2.out', 'M2.a')
     col =  {'NS' : 'grey', 'RX' : 'black',
             'RX+': 'grey', 'CN' : 'black',
             'CN+': 'grey', 'PS' : 'black', 'PS+': 'black'}
     col2 = {'NS' : 'white', 'RX' : 'white',
             'RX+': 'white', 'CN' : 'white',
             'CN+': 'white', 'PS' : 'white', 'PS+': 'white'}
     M2a = tree.get_evol_model('M2.a')
     try:
         import PyQt4
     except ImportError:
         pass
     else:
         M2a.set_histface (up=False, kind='stick', hlines=[1.0, 0.3],
                           hlines_col=['red','grey'], header='ugliest face')
         M2a.set_histface (up=False, kind='curve', colors=col2,errors=True,
                           hlines = [2.5, 1.0, 4.0, 0.5],
                           header = 'Many lines, error boxes, background black',
                           hlines_col=['orange', 'yellow', 'red', 'cyan'])
         M2a.set_histface (up=False, kind='bar', hlines = [1.0, 0.3],
                           hlines_col=['black','grey'],colors=col)
         self.assertEqual(str(type(M2a.properties['histface'])),
                          "<class 'ete_dev.treeview.faces.SequencePlotFace'>")
示例#8
0
 def test_call_histface(self):
     tree = EvolTree (WRKDIR + 'tree.nw')
     tree.workdir = 'examples/evol/data/protamine/PRM1/paml/'
     tree.link_to_alignment  (WRKDIR + 'alignments.fasta_ali')
     tree.link_to_evol_model (WRKDIR + 'paml/M2/M2.out', 'M2.a')
     col =  {'NS' : 'grey', 'RX' : 'black',
             'RX+': 'grey', 'CN' : 'black',
             'CN+': 'grey', 'PS' : 'black', 'PS+': 'black'}
     col2 = {'NS' : 'white', 'RX' : 'white',
             'RX+': 'white', 'CN' : 'white',
             'CN+': 'white', 'PS' : 'white', 'PS+': 'white'}
     M2a = tree.get_evol_model('M2.a')
     try:
         import PyQt4
     except ImportError:
         pass
     else:
         M2a.set_histface (up=False, kind='stick', hlines=[1.0, 0.3],
                           hlines_col=['red','grey'], header='ugliest face')
         M2a.set_histface (up=False, kind='curve', colors=col2,errors=True,
                           hlines = [2.5, 1.0, 4.0, 0.5],
                           header = 'Many lines, error boxes, background black',
                           hlines_col=['orange', 'yellow', 'red', 'cyan'])
         M2a.set_histface (up=False, kind='bar', hlines = [1.0, 0.3],
                           hlines_col=['black','grey'],colors=col)
         self.assertEqual(str(type(M2a.properties['histface'])),
                          "<class 'ete_dev.treeview.faces.SequencePlotFace'>")
示例#9
0
 def test_pickling(self):
     tree = EvolTree(WRKDIR + 'tree.nw')
     tree.workdir = ETEPATH + '/examples/data/protamine/PRM1/paml/'
     tree.link_to_alignment(WRKDIR + 'alignments.fasta_ali')
     tree.link_to_evol_model(WRKDIR + 'paml/M2/M2.out', 'M2.a')
     out = open('blip.pik', 'w')
     dump(tree, out)
     out.close()
     out = open('blip.pik')
     tree2 = load(out)
     out.close()
     os.remove('blip.pik')
     self.assertEqual(str(tree2.get_evol_model('M2.a')),
                      str(tree.get_evol_model('M2.a')))
示例#10
0
 def test_pickling(self):
     tree = EvolTree (WRKDIR + 'tree.nw')
     tree.workdir = ETEPATH + '/examples/data/protamine/PRM1/paml/'
     tree.link_to_alignment  (WRKDIR + 'alignments.fasta_ali')
     tree.link_to_evol_model (WRKDIR + 'paml/M2/M2.out', 'M2.a')
     out = open('blip.pik', 'w')
     dump (tree, out)
     out.close()
     out = open('blip.pik')
     tree2 = load (out)
     out.close()
     os.remove('blip.pik')
     self.assertEqual(str(tree2.get_evol_model('M2.a')),
                      str(tree.get_evol_model('M2.a'))
     )
示例#11
0
 def test_load_model(self):
     tree = EvolTree (WRKDIR + 'tree.nw')
     tree.workdir = 'examples/evol/data/protamine/PRM1/paml/'
     tree.link_to_evol_model (WRKDIR + 'paml/fb/fb.out', 'fb')
     tree.link_to_evol_model (WRKDIR + 'paml/M1/M1.out', 'M1')
     tree.link_to_evol_model (WRKDIR + 'paml/M2/M2.out', 'M2')
     tree.link_to_evol_model (WRKDIR + 'paml/M7/M7.out', 'M7')
     tree.link_to_evol_model (WRKDIR + 'paml/M8/M8.out', 'M8')
     tree.link_to_alignment  (WRKDIR + 'alignments.fasta_ali')
     self.assertEqual(sorted(tree._models.keys()),
                      sorted(['fb', 'M1', 'M2', 'M7', 'M8']))
     self.assertEqual(len (tree.get_evol_model('M2').branches), 194)
     self.assertEqual(tree.get_evol_model('fb').lnL, -3265.316569)
     self.assert_('proportions' in str(tree.get_evol_model('M2')))
     self.assert_('p2=' in str(tree.get_evol_model('M2')))
     self.assert_('proportions' not in str(tree.get_evol_model('fb')))
     self.assert_(' #193' in str(tree.get_evol_model('fb')))
示例#12
0
 def test_load_model(self):
     tree = EvolTree (WRKDIR + 'tree.nw')
     tree.workdir = 'examples/evol/data/protamine/PRM1/paml/'
     tree.link_to_evol_model (WRKDIR + 'paml/fb/fb.out', 'fb')
     tree.link_to_evol_model (WRKDIR + 'paml/M1/M1.out', 'M1')
     tree.link_to_evol_model (WRKDIR + 'paml/M2/M2.out', 'M2')
     tree.link_to_evol_model (WRKDIR + 'paml/M7/M7.out', 'M7')
     tree.link_to_evol_model (WRKDIR + 'paml/M8/M8.out', 'M8')
     tree.link_to_alignment  (WRKDIR + 'alignments.fasta_ali')
     self.assertEqual(sorted(tree._models.keys()),
                      sorted(['fb', 'M1', 'M2', 'M7', 'M8']))
     self.assertEqual(len (tree.get_evol_model('M2').branches), 194)
     self.assertEqual(tree.get_evol_model('fb').lnL, -3265.316569)
     self.assert_('proportions' in str(tree.get_evol_model('M2')))
     self.assert_('p2=' in str(tree.get_evol_model('M2')))
     self.assert_('proportions' not in str(tree.get_evol_model('fb')))
     self.assert_(' #193' in str(tree.get_evol_model('fb')))
示例#13
0
raw_input("\n         ====> Hit some key to launch LRT")

pv = T.get_most_likely('M2', 'M1')
if pv <= 0.05:
    print '         ---->   -> most likely model is model M2, there is positive selection, pval: ',pv
else:
    print '         ---->   -> most likely model is model M1, pval: ',pv

raw_input("         ====> Hit some key...")

###
# tengo que encontrar un ejemplo mas bonito pero bueno.... :P

print '\n\n\n         ----> We now add histograms to our tree to repesent site models with add_histface function: \n\n%s\n%s\n%s\n'\
      % ('*'*10 + ' doc ' + '*'*10, T.get_evol_model('M2').set_histface.func_doc,'*'*30)
print 'Upper face is an histogram representing values of omega for each column in the alignment,'
print '\
Colors represent significantly conserved sites(cyan to blue), neutral sites(greens), or under \n\
positive selection(orange to red). \n\
Lower face also represents values of omega(red line) and bars represent the error of the estimation.\n\
Also significance of belonging to one class of site can be painted in background(here lightgrey for\n\
evrething significant)\n\
Both representation are done according to BEB estimation of M2, M1 or M7 estimation can also be \n\
drawn but should not be used.\n'
raw_input("         ====> Hit some key to display, histograms of omegas BEB from M2 model...")

col = {'NS' : 'grey',
       'RX' : 'grey',
       'RX+': 'grey',
       'CN' : 'grey',
示例#14
0
raw_input("\n         ====> Hit some key to launch LRT")

pv = T.get_most_likely('M2', 'M1')
if pv <= 0.05:
    print '         ---->   -> most likely model is model M2, there is positive selection, pval: ',pv
else:
    print '         ---->   -> most likely model is model M1, pval: ',pv

raw_input("         ====> Hit some key...")

###
# tengo que encontrar un ejemplo mas bonito pero bueno.... :P

print '\n\n\n         ----> We now add histograms to our tree to repesent site models with add_histface function: \n\n%s\n%s\n%s\n'\
      % ('*'*10 + ' doc ' + '*'*10, T.get_evol_model ('M2').set_histface.func_doc,'*'*30)
print 'Upper face is an histogram representing values of omega for each column in the alignment,'
print '\
Colors represent significantly conserved sites (cyan to blue), neutral sites (greens), or under \n\
positive selection (orange to red). \n\
Lower face also represents values of omega (red line) and bars represent the error of the estimation.\n\
Also significance of belonging to one class of site can be painted in background (here lightgrey for\n\
evrething significant)\n\
Both representation are done according to BEB estimation of M2, M1 or M7 estimation can also be \n\
drawn but should not be used.\n'
raw_input("         ====> Hit some key to display, histograms of omegas BEB from M2 model...")

col = {'NS' : 'white',
       'RX' : 'lightgrey',
       'RX+': 'lightgrey',
       'CN' : 'lightgrey',