Example #1
0
def main():
    option_parser, opts, args =\
                   parse_command_line_parameters(**script_info)
    
    if(opts.parallel):
        tmp_dir='jobs/'
        make_output_dir(tmp_dir)
        asr_table, ci_table =run_asr_in_parallel(tree=opts.input_tree_fp,table=opts.input_trait_table_fp,asr_method=opts.asr_method,parallel_method=opts.parallel_method, num_jobs=opts.num_jobs,tmp_dir=tmp_dir,verbose=opts.verbose)
    else:
        #call the apporpriate ASR app controller 
        if(opts.asr_method == 'wagner'):
            asr_table = wagner_for_picrust(opts.input_tree_fp,opts.input_trait_table_fp,HALT_EXEC=opts.debug)
        elif(opts.asr_method == 'bayestraits'):
            pass
        elif(opts.asr_method == 'ace_ml'):
            asr_table,ci_table = ace_for_picrust(opts.input_tree_fp,opts.input_trait_table_fp,'ML',HALT_EXEC=opts.debug)
        elif(opts.asr_method == 'ace_pic'):
            asr_table,ci_table = ace_for_picrust(opts.input_tree_fp,opts.input_trait_table_fp,'pic',HALT_EXEC=opts.debug)
        elif(opts.asr_method == 'ace_reml'):
            asr_table,ci_table = ace_for_picrust(opts.input_tree_fp,opts.input_trait_table_fp,'REML',HALT_EXEC=opts.debug)


    #output the table to file
    make_output_dir_for_file(opts.output_fp)
    asr_table.writeToFile(opts.output_fp,sep='\t')

    #output the CI file (unless the method is wagner)
    if not (opts.asr_method == 'wagner'):
        make_output_dir_for_file(opts.output_ci_fp)
        ci_table.writeToFile(opts.output_ci_fp,sep='\t')
def main():
    option_parser, opts, args =\
                   parse_command_line_parameters(**script_info)
    
    if(opts.parallel):
        tmp_dir='jobs/'
        make_output_dir(tmp_dir)
        asr_table, ci_table =run_asr_in_parallel(tree=opts.input_tree_fp,table=opts.input_trait_table_fp,asr_method=opts.asr_method,parallel_method=opts.parallel_method, num_jobs=opts.num_jobs,tmp_dir=tmp_dir,verbose=opts.verbose)
    else:
        #call the apporpriate ASR app controller 
        if(opts.asr_method == 'wagner'):
            asr_table = wagner_for_picrust(opts.input_tree_fp,opts.input_trait_table_fp,HALT_EXEC=opts.debug)
        elif(opts.asr_method == 'bayestraits'):
            pass
        elif(opts.asr_method == 'ace_ml'):
            asr_table,ci_table = ace_for_picrust(opts.input_tree_fp,opts.input_trait_table_fp,'ML',HALT_EXEC=opts.debug)
        elif(opts.asr_method == 'ace_pic'):
            asr_table,ci_table = ace_for_picrust(opts.input_tree_fp,opts.input_trait_table_fp,'pic',HALT_EXEC=opts.debug)
        elif(opts.asr_method == 'ace_reml'):
            asr_table,ci_table = ace_for_picrust(opts.input_tree_fp,opts.input_trait_table_fp,'REML',HALT_EXEC=opts.debug)


    #output the table to file
    make_output_dir_for_file(opts.output_fp)
    asr_table.writeToFile(opts.output_fp,sep='\t')

    #output the CI file (unless the method is wagner)
    if not (opts.asr_method == 'wagner'):
        make_output_dir_for_file(opts.output_ci_fp)
        ci_table.writeToFile(opts.output_ci_fp,sep='\t')
Example #3
0
 def test_ace_for_picrust_ml(self):
     """ test_ace_for_picrust with method 'ML' functions as expected with valid input
     """
     actual, actual_ci = ace_for_picrust(self.in_tree1_fp, self.in_trait1_fp, method="ML")
     expected = Table(
         ["nodes", "trait1", "trait2"],
         [
             ["14", "2.9737", "2.5436"],
             ["12", "2.3701", "2.7056"],
             ["11", "0.8370", "2.9706"],
             ["10", "4.4826", "2.1388"],
         ],
     )
     self.assertEqual(actual.tostring(), expected.tostring())
     expected_ci = Table(
         ["nodes", "trait1", "trait2"],
         [
             ["14", "1.4467|4.5007", "2.1979|2.8894"],
             ["12", "0.9729|3.7674", "2.3892|3.0219"],
             ["11", "0.147|1.527", "2.8143|3.1268"],
             ["10", "3.4227|5.5426", "1.8988|2.3788"],
             ["sigma", "1.9742|0.6981", "0.1012|0.0359"],
             ["loglik", "-6.7207", "5.1623"],
         ],
     )
     self.assertEqual(actual_ci.tostring(), expected_ci.tostring())
Example #4
0
 def test_ace_for_picrust_pic_with_funky_tip_labels(self):
     """ test_ace_for_picrust for a tree with underscores in tip labels
     """
     actual, ci = ace_for_picrust(self.in_tree2_fp, self.in_trait3_fp, method="pic")
     expected = Table(
         ["nodes", "trait1", "trait2"],
         [["14", "2.9737", "2.5436"], ["12", "1.2727", "3"], ["11", "0.6667", "3"], ["10", "5", "2"]],
     )
     self.assertEqual(actual.tostring(), expected.tostring())
Example #5
0
 def test_ace_for_picrust_pic_with_funky_tip_labels(self):
     """ test_ace_for_picrust for a tree with underscores in tip labels
     """
     actual, ci = ace_for_picrust(self.in_tree2_fp,
                                  self.in_trait3_fp,
                                  method="pic")
     expected = Table(['nodes', 'trait1', 'trait2'],
                      [['14', '2.9737', '2.5436'], ['12', '1.2727', '3'],
                       ['11', '0.6667', '3'], ['10', '5', '2']])
     self.assertEqual(actual.tostring(), expected.tostring())
Example #6
0
 def test_ace_for_picrust_pic_single_trait(self):
     """ test_ace_for_picrust with method 'pic' functions as expected with single column trait table
     """
     actual, ci = ace_for_picrust(self.in_tree1_fp,
                                  self.in_trait2_fp,
                                  method="pic")
     expected = Table(['nodes', 'trait1'],
                      [['14', '2.9737'], ['12', '1.2727'], ['11', '0.6667'],
                       ['10', '5']])
     self.assertEqual(actual.tostring(), expected.tostring())
Example #7
0
 def test_ace_for_picrust_pic(self):
     """ test_ace_for_picrust with method 'pic' functions as expected with valid input
     """
     actual,actual_ci= ace_for_picrust(self.in_tree1_fp,self.in_trait1_fp, method="pic")
     expected=Table(['nodes','trait1','trait2'],[['14','2.9737','2.5436'],['12','1.2727','3'],['11','0.6667','3'],['10','5','2']])
     self.assertEqual(actual.tostring(),expected.tostring())
     expected_ci=Table(['nodes','trait1','trait2'],\
                           [['14','0.7955|5.1519','0.3655|4.7218'],\
                            ['12','-1.1009|3.6464','0.6264|5.3736'],\
                            ['11','-0.4068|1.7402','1.9265|4.0735'],\
                            ['10','3.3602|6.6398','0.3602|3.6398'],\
                            ])
     self.assertEqual(actual_ci.tostring(),expected_ci.tostring())
Example #8
0
 def test_ace_for_picrust_pic(self):
     """ test_ace_for_picrust with method 'pic' functions as expected with valid input
     """
     actual,actual_ci= ace_for_picrust(self.in_tree1_fp,self.in_trait1_fp, method="pic")
     expected=Table(['nodes','trait1','trait2'],[['14','2.9737','2.5436'],['12','1.2727','3'],['11','0.6667','3'],['10','5','2']])
     self.assertEqual(actual.tostring(),expected.tostring())
     expected_ci=Table(['nodes','trait1','trait2'],\
                           [['14','0.7955|5.1519','0.3655|4.7218'],\
                            ['12','-1.1009|3.6464','0.6264|5.3736'],\
                            ['11','-0.4068|1.7402','1.9265|4.0735'],\
                            ['10','3.3602|6.6398','0.3602|3.6398'],\
                            ])
     self.assertEqual(actual_ci.tostring(),expected_ci.tostring())
Example #9
0
 def test_ace_for_picrust_ml(self):
     """ test_ace_for_picrust with method 'ML' functions as expected with valid input
     """
     actual,actual_ci= ace_for_picrust(self.in_tree1_fp, self.in_trait1_fp, method="ML")
     expected=Table(['nodes','trait1','trait2'],[['14','2.9737','2.5436'],['12','2.3701','2.7056'],['11','0.8370','2.9706'],['10','4.4826','2.1388']])
     self.assertEqual(actual.tostring(),expected.tostring())
     expected_ci=Table(['nodes','trait1','trait2'],\
                           [['14','1.4467|4.5007','2.1979|2.8894'],\
                            ['12','0.9729|3.7674','2.3892|3.0219'],\
                            ['11','0.147|1.527','2.8143|3.1268'],\
                            ['10','3.4227|5.5426','1.8988|2.3788'],\
                            ['sigma','1.9742|0.6981','0.1012|0.0359'],\
                            ['loglik','-6.7207','5.1623'],\
                            ])
     self.assertEqual(actual_ci.tostring(),expected_ci.tostring())
Example #10
0
 def test_ace_for_picrust_ml(self):
     """ test_ace_for_picrust with method 'ML' functions as expected with valid input
     """
     actual,actual_ci= ace_for_picrust(self.in_tree1_fp, self.in_trait1_fp, method="ML")
     expected=Table(['nodes','trait1','trait2'],[['14','2.9737','2.5436'],['12','2.3701','2.7056'],['11','0.8370','2.9706'],['10','4.4826','2.1388']])
     self.assertEqual(actual.tostring(),expected.tostring())
     expected_ci=Table(['nodes','trait1','trait2'],\
                           [['14','1.4467|4.5007','2.1979|2.8894'],\
                            ['12','0.9729|3.7674','2.3892|3.0219'],\
                            ['11','0.147|1.527','2.8143|3.1268'],\
                            ['10','3.4227|5.5426','1.8988|2.3788'],\
                            ['sigma','1.9742|0.6981','0.1012|0.0359'],\
                            ['loglik','-6.7207','5.1623'],\
                            ])
     self.assertEqual(actual_ci.tostring(),expected_ci.tostring())
Example #11
0
 def test_ace_for_picrust_pic(self):
     """ test_ace_for_picrust with method 'pic' functions as expected with valid input
     """
     actual, actual_ci = ace_for_picrust(self.in_tree1_fp, self.in_trait1_fp, method="pic")
     expected = Table(
         ["nodes", "trait1", "trait2"],
         [["14", "2.9737", "2.5436"], ["12", "1.2727", "3"], ["11", "0.6667", "3"], ["10", "5", "2"]],
     )
     self.assertEqual(actual.tostring(), expected.tostring())
     expected_ci = Table(
         ["nodes", "trait1", "trait2"],
         [
             ["14", "0.7955|5.1519", "0.3655|4.7218"],
             ["12", "-1.1009|3.6464", "0.6264|5.3736"],
             ["11", "-0.4068|1.7402", "1.9265|4.0735"],
             ["10", "3.3602|6.6398", "0.3602|3.6398"],
         ],
     )
     self.assertEqual(actual_ci.tostring(), expected_ci.tostring())
Example #12
0
 def test_ace_for_picrust_pic_single_trait(self):
     """ test_ace_for_picrust with method 'pic' functions as expected with single column trait table
     """
     actual,ci= ace_for_picrust(self.in_tree1_fp,self.in_trait2_fp, method="pic")
     expected=Table(['nodes','trait1'],[['14','2.9737'],['12','1.2727'],['11','0.6667'],['10','5']])
     self.assertEqual(actual.tostring(),expected.tostring())
Example #13
0
 def test_ace_for_picrust_pic_with_funky_tip_labels(self):
     """ test_ace_for_picrust for a tree with underscores in tip labels
     """
     actual,ci= ace_for_picrust(self.in_tree2_fp,self.in_trait3_fp, method="pic")
     expected=Table(['nodes','trait1','trait2'],[['14','2.9737','2.5436'],['12','1.2727','3'],['11','0.6667','3'],['10','5','2']])
     self.assertEqual(actual.tostring(),expected.tostring())
Example #14
0
 def test_ace_for_picrust_pic_single_trait(self):
     """ test_ace_for_picrust with method 'pic' functions as expected with single column trait table
     """
     actual, ci = ace_for_picrust(self.in_tree1_fp, self.in_trait2_fp, method="pic")
     expected = Table(["nodes", "trait1"], [["14", "2.9737"], ["12", "1.2727"], ["11", "0.6667"], ["10", "5"]])
     self.assertEqual(actual.tostring(), expected.tostring())