def test_call_correct_alignment(self):
        """CogentTreeBuilder: output expected alignment file
        """
        p = CogentTreeBuilder({'Module': cogent.app.fasttree})
        log_fp = get_tmp_filename(\
         prefix='CogentTreeBuilderTests_',suffix='.log')
        self._paths_to_clean_up.append(log_fp)

        actual = p(result_path=None, aln_path=self.input_fp, log_path=log_fp)
        expected = tree
        #note: lines in diff order w/ diff versions
        self.assertEqual(str(actual), expected)
Exemple #2
0
    def test_call_correct_alignment(self):
        """CogentTreeBuilder: output expected alignment file
        """
        p = CogentTreeBuilder({'Module': bfillings.fasttree})
        fd, log_fp = mkstemp(prefix='CogentTreeBuilderTests_', suffix='.log')
        close(fd)
        self._paths_to_clean_up.append(log_fp)

        actual = p(result_path=None, aln_path=self.input_fp, log_path=log_fp)
        actual = str(actual)
        # note: order of inputs to FastTree can have very minor effect
        # on the distances, so we need to compare against a couple of trees
        # to avoid failures on different archs
        self.assertTrue(actual == tree or actual == tree2)
def main():
    option_parser, opts, args = parse_command_line_parameters(**script_info)

    if not (opts.tree_method in tree_method_constructors
            or opts.tree_method in tree_module_names):
        option_parser.error(
            'Invalid alignment method: %s.\nValid choices are: %s' %
            (opts.tree_method, ' '.join(tree_method_constructors.keys() +
                                        tree_module_names.keys())))
    try:
        tree_builder_constructor =\
            tree_method_constructors[opts.tree_method]
        tree_builder_type = 'Constructor'
        params = {}
        tree_builder = tree_builder_constructor(params)
    except KeyError:
        tree_builder = CogentTreeBuilder({
            'Module':
            tree_module_names[opts.tree_method],
            'Method':
            opts.tree_method
        })
        tree_builder_type = 'Cogent'

    input_seqs_filepath = opts.input_fp
    result_path = opts.result_fp
    if not result_path:  # empty or None
        fpath, ext = splitext(input_seqs_filepath)  # fpath omits extension
        result_path = fpath + ".tre"

    open(result_path, 'w').close()  # touch
    log_path = opts.log_fp
    if log_path is not None:
        open(log_path, 'w').close()

    if tree_builder_type == 'Constructor':
        tree_builder(input_seqs_filepath,
                     result_path=result_path,
                     log_path=log_path,
                     failure_path=failure_path)
    elif tree_builder_type == 'Cogent':
        tree_builder(result_path,
                     aln_path=input_seqs_filepath,
                     log_path=log_path,
                     root_method=opts.root_method)