Example #1
0
 def __init__(self, **kw):
     PhyltrCommand.__init__(self, **kw)
     self.tree_count = 0
     self.taxa_count = 0
     self.ultrametric = True
     self.topologically_unique_trees = []
     self.tree_ages = []
Example #2
0
 def __init__(self, rename=None, **kw):
     PhyltrCommand.__init__(self, **kw)
     if rename:
         self.rename = rename
     elif self.opts.filename and self.opts.from_ and self.opts.to_:
         self.read_rename_file(self.opts.filename, self.opts.from_, self.opts.to_)
     else:
         raise ValueError("Must supply renaming dictionary or filename and columns!")
Example #3
0
    def __init__(self, dummy=False, **kw):
        PhyltrCommand.__init__(self, **kw)
        self.dummy = dummy

        if not self.dummy:  # pragma: no cover
            # Setup TreeStyle
            self.ts = TreeStyle()
            self.ts.show_scale = False
            self.ts.show_branch_support = not self.opts.no_support
            self.ts.show_leaf_name = False
Example #4
0
    def __init__(self, **kw):
        PhyltrCommand.__init__(self, **kw)
        self.annotations = {}

        if self.opts.extract and (self.opts.filename == "-"
                                  or not self.opts.filename):
            # If we're writing an extracted CSV to stdin, we don't want to also
            # serialise the trees, so plumb to null
            self.sink = NullSink

        if not self.opts.extract:
            self.read_annotation_file()
Example #5
0
 def __init__(self, **kw):
     PhyltrCommand.__init__(self, **kw)
     if not (self.opts.taxa or self.opts.filename):
         raise ValueError(
             "Must provide a list of taxa or a file containing such a list!"
         )
     if not self.opts.taxa:
         self.opts.taxa = read_taxa(self.opts.filename,
                                    column=self.opts.column)
     self.opts.taxa = set(self.opts.taxa)
     if len(self.opts.taxa) == 1:
         raise ValueError("Must specify more than one taxon!")
Example #6
0
 def __init__(self, **kw):
     PhyltrCommand.__init__(self, **kw)
     if not (self.opts.taxa or self.opts.filename):
         raise ValueError(
             "Must provide a list of taxa or a file containing such a list!"
         )
     if not self.opts.taxa:
         self.opts.taxa = read_taxa(self.opts.filename,
                                    column=self.opts.column)
         # FIXME: read_taxa returns a set, we do need an ordered data structure!
     self.opts.taxa = {taxon: t for t, taxon in enumerate(self.opts.taxa)}
     self.median_cache = {}
     if len(self.opts.taxa) == 1:
         raise ValueError("Must specify more than one taxon!")
Example #7
0
 def __init__(self, **kw):
     PhyltrCommand.__init__(self, **kw)
     ...
Example #8
0
 def __init__(self, **kw):
     PhyltrCommand.__init__(self, **kw)
     self.condition = selector_from_taxa_spec(self.opts)
Example #9
0
Command specific help is availble via "phyltr <command> --help".
"""

import os.path
import shlex
from signal import signal, SIGPIPE, SIG_DFL
import sys
from textwrap import shorten

# import all commands:
from phyltr.commands import *  # noqa: F401, F403
from phyltr.commands.base import PhyltrCommand

COMMANDS = {
    cls.__name__.lower(): cls
    for cls in PhyltrCommand.__subclasses__()
}


def _format_command_overview():
    max_name = max(len(k) for k in COMMANDS)
    res = []
    for cmd in sorted(COMMANDS.keys()):
        res.append('  {0} {1}'.format(
            cmd.ljust(max_name), shorten(COMMANDS[cmd].__doc__,
                                         77 - max_name)))
    return '\n'.join(res)


def _split_string(spec_string):
    spec_string = spec_string.strip()
Example #10
0
 def __init__(self, **kw):
     PhyltrCommand.__init__(self, **kw)
     self.trees = []
     self.cp = phyltr.utils.cladeprob.CladeProbabilities()
Example #11
0
 def __init__(self, **kw):
     PhyltrCommand.__init__(self, **kw)
     self.taxonset = None
Example #12
0
 def __init__(self, **kw):
     PhyltrCommand.__init__(self, **kw)
     self.topologies = {}