Ejemplo n.º 1
0
class TaxaClassifier(object):
    """Can assign taxonomy to a FASTA file of random shotgun sequences."""

    all_paths = """
    /tree.txt
    /annot.txt
    /graph.xml
    /graph.png
    """

    def __repr__(self): return '<%s object of %s>' % (self.__class__.__name__, self.parent)

    def __init__(self):
        # Files #
        self.taxa_file = FilePath(self.base_dir + self.sample.name + '.txt')
        self.class_out_file = FilePath(self.base_dir + self.sample.type + '.txt')
        self.class_out_file.link_from(self.taxa_file, safe=True)
        # NMDS #
        self.coord = (0,0)

    def make_graph(self):
        # Convert #
        graphconv = sh.Command(home + "share/metaphlan/plotting_scripts/metaphlan2graphlan.py")
        graphconv(self.taxa_file, '--tree_file', self.p.tree, '--annot_file', self.p.annot)
        # Annotate #
        annotate = sh.Command(home + "share/graphlan/graphlan_annotate.py")
        annotate('--annot', self.p.annot, self.p.tree, self.p.xml)
        # Graph #
        graphlan = sh.Command(home + "share/graphlan/graphlan.py")
        graphlan('--dpi', 200, self.p.xml, self.p.png)