Exemple #1
0
    def run(self, fname="codeml-input.txt"):
        """ """
        # CHECK FOR NECESSARY FILES (PHYLIP and NEWICK)
        if os.path.isfile(self.seqfile) is False:
            raise Exception(""" seqfile does not exist! """)
        if os.path.isfile(self.treefile) is False:
            raise Exception(""" treefile does not exist! """)

        # Write out the control file
        self.write(fname)

        # Run a subprocess for codeml
        run_subprocess("codeml", fname)
Exemple #2
0
    def run(self, fname="codeml-input.txt"):
        """ """
        # CHECK FOR NECESSARY FILES (PHYLIP and NEWICK)
        if os.path.isfile(self.seqfile) is False:
            raise Exception(""" seqfile does not exist! """)
        if os.path.isfile(self.treefile) is False:
            raise Exception(""" treefile does not exist! """)

        # Write out the control file
        self.write(fname)

        # Run a subprocess for codeml
        run_subprocess("codeml", fname)
Exemple #3
0
def run(fname_prefix, dtype="aa", rm_tmp=True, *args, **kwargs):
    """ Simple wrapper for running PhyML within Python.

    Options
    -------
    b :



    """
    # Create a temporary fasta file from homologs as input to PhyML.
    # Build command array and run it.
    phy_fname = "%s.phy" % fname_prefix
    stats_fname = "%s.phy_phyml_stats.txt" % fname_prefix # Default name for output from phyml
    tree_fname = "%s.phy_phyml_tree.txt" % fname_prefix # default name for output tree file

    # Construct arguments for subprocess
    stuff = ("-i", phy_fname, "-d", dtype)
    stuff += args
    run_subprocess("phyml", *stuff, **kwargs)

    # Read the tree file and add to homologset.
    with open(tree_fname, "r") as f:
        tree = f.read()

    # Read the stats file.
    with open(stats_fname, "r") as f:
        stats_string = f.read()

    # Return stats.
    stats = parse_phyml_stats(stats_string)

    # Remove alignment files if you want to just keep homologs.
    if rm_tmp:
        os.remove(phy_fname)

    return tree, stats
Exemple #4
0
def run(fname_prefix, dtype="aa", rm_tmp=True, *args, **kwargs):
    """ Simple wrapper for running PhyML within Python.

    Options
    -------
    b :



    """
    # Create a temporary fasta file from homologs as input to PhyML.
    # Build command array and run it.
    phy_fname = "%s.phy" % fname_prefix
    stats_fname = "%s.phy_phyml_stats.txt" % fname_prefix # Default name for output from phyml
    tree_fname = "%s.phy_phyml_tree.txt" % fname_prefix # default name for output tree file

    # Construct arguments for subprocess
    stuff = ("-i", phy_fname, "-d", dtype)
    stuff += args
    run_subprocess("phyml", *stuff, **kwargs)

    # Read the tree file and add to homologset.
    with open(tree_fname, "r") as f:
        tree = f.read()

    # Read the stats file.
    with open(stats_fname, "r") as f:
        stats_string = f.read()

    # Return stats.
    stats = parse_phyml_stats(stats_string)

    # Remove alignment files if you want to just keep homologs.
    if rm_tmp:
        os.remove(phy_fname)

    return tree, stats