def __init__(self, tree=None, aln=None, gtr=None, fill_overhangs=True,
                ref=None, verbose = ttconf.VERBOSE, ignore_gaps=True,
                convert_upper=True, seq_multiplicity=None, log=None,
                reduce_alignment=True,
                **kwargs):
        """
        TreeAnc constructor. It prepares the tree, attaches sequences to the leaf nodes,
        and sets some configuration parameters.

        Parameters
        ----------

         tree : str, Bio.Phylo.Tree
            Phylogenetic tree. String passed is interpreted as a filename with
            a tree in a standard format that can be parsed by the Biopython Phylo module.

         aln : str, Bio.Align.MultipleSequenceAlignment, dict
            Sequence alignment. If a string passed, it is interpreted as the
            filename to read Biopython alignment from. If a dict is given,
            this is assumed to be the output of vcf_utils.read_vcf which
            specifies for each sequence the differences from a reference

         gtr : str, GTR
            GTR model object. If string passed, it is interpreted as the type of
            the GTR model. A new GTR instance will be created for this type.

         fill_overhangs : bool
            In some cases, the missing data on both ends of the alignment is
            filled with the gap sign('-'). If set to True, the end-gaps are converted to "unknown"
            characters ('N' for nucleotides, 'X' for aminoacids). Otherwise, the alignment is treated as-is

         ignore_gaps: bool
            Ignore gaps in branch length calculations

         verbose : int
            Verbosity level as number from 0 (lowest) to 10 (highest).

         seq_multiplicity: dict
            If individual nodes in the tree correspond to multiple sampled sequences
            (i.e. read count in a deep sequencing experiment), these can be
            specified as a dictionary. This currently only affects rooting and
            can be used to weigh individual tips by abundance or important during root search.

         **kwargs
            Keyword arguments to construct the GTR model

          .. Note::
                Some GTR types require additional configuration parameters.
                If the new GTR is being instantiated, these parameters are expected
                to be passed as kwargs. If nothing is passed, the default values are
                used, which might cause unexpected results.

        Raises
        ----------

         TypeError
            If a tree is not passed in


        """
        if tree is None:
            raise TypeError("TreeAnc requires a tree!")
        self.t_start = time.time()
        self.verbose = verbose
        self.log=log
        self.logger("TreeAnc: set-up",1)
        self._internal_node_count = 0
        self.additional_constant_sites = 0 # sites not part of the alignment but assumed constant
        self.use_mutation_length=False
        # if not specified, this will be set as the alignment_length or reference length
        self._seq_len = None
        self.seq_len = kwargs['seq_len'] if 'seq_len' in kwargs else None
        self.fill_overhangs = fill_overhangs
        self.is_vcf = False  #this is set true when aln is set, if aln is dict
        # if sequences represent multiple samples, this can be added as multiplicity here
        self.seq_multiplicity = {} if seq_multiplicity is None else seq_multiplicity
        self.reduce_alignment = reduce_alignment
        self.ignore_gaps = ignore_gaps

        self._tree = None
        self.tree = tree
        if tree is None:
            raise AttributeError("TreeAnc: tree loading failed! exiting")

        # set up GTR model
        self._gtr = None
        self.set_gtr(gtr or 'JC69', **kwargs)

        # will be None if not set
        self.ref = ref

        # force all sequences to be upper case letters
        # (desired for nuc or aa, not for other discrete states)
        self.convert_upper = convert_upper

        # set alignment and attach sequences to tree on success.
        # otherwise self.aln will be None
        self._aln = None
        self.reduced_to_full_sequence_map = None
        self.multiplicity = None
        self.aln = aln

        if self.aln and self.tree:
            if len(self.tree.get_terminals()) != len(self.aln):
                self.logger("**WARNING: Number of sequences in tree differs from number of sequences in alignment!**", 3, warn=True)
def __init__ ( self , tree = None , aln = None , gtr = None , fill_overhangs = True , ref = None , verbose = ttconf . VERBOSE , ignore_gaps = True , convert_upper = True , seq_multiplicity = None , log = None , reduce_alignment = True , ** kwargs ) : if tree is None : raise TypeError ( "TreeAnc requires a tree!" ) self . t_start = time . time ( ) self . verbose = verbose self . log = log self . logger ( "TreeAnc: set-up" , 1 ) self . _internal_node_count = 0 self . additional_constant_sites = 0 self . use_mutation_length = False self . _seq_len = None self . seq_len = kwargs [ 'seq_len' ] if 'seq_len' in kwargs else None self . fill_overhangs = fill_overhangs self . is_vcf = False self . seq_multiplicity = { } if seq_multiplicity is None else seq_multiplicity self . reduce_alignment = reduce_alignment self . ignore_gaps = ignore_gaps self . _tree = None self . tree = tree if tree is None : raise AttributeError ( "TreeAnc: tree loading failed! exiting" ) self . _gtr = None self . set_gtr ( gtr or 'JC69' , ** kwargs ) self . ref = ref self . convert_upper = convert_upper self . _aln = None self . reduced_to_full_sequence_map = None self . multiplicity = None self . aln = aln if self . aln and self . tree : if len ( self . tree . get_terminals ( ) ) != len ( self . aln ) : self . logger ( "**WARNING: Number of sequences in tree differs from number of sequences in alignment!**" , 3 , warn = True )
TreeAnc constructor. It prepares the tree, attaches sequences to the leaf nodes,
        and sets some configuration parameters.

        Parameters
        ----------

         tree : str, Bio.Phylo.Tree
            Phylogenetic tree. String passed is interpreted as a filename with
            a tree in a standard format that can be parsed by the Biopython Phylo module.

         aln : str, Bio.Align.MultipleSequenceAlignment, dict
            Sequence alignment. If a string passed, it is interpreted as the
            filename to read Biopython alignment from. If a dict is given,
            this is assumed to be the output of vcf_utils.read_vcf which
            specifies for each sequence the differences from a reference

         gtr : str, GTR
            GTR model object. If string passed, it is interpreted as the type of
            the GTR model. A new GTR instance will be created for this type.

         fill_overhangs : bool
            In some cases, the missing data on both ends of the alignment is
            filled with the gap sign('-'). If set to True, the end-gaps are converted to "unknown"
            characters ('N' for nucleotides, 'X' for aminoacids). Otherwise, the alignment is treated as-is

         ignore_gaps: bool
            Ignore gaps in branch length calculations

         verbose : int
            Verbosity level as number from 0 (lowest) to 10 (highest).

         seq_multiplicity: dict
            If individual nodes in the tree correspond to multiple sampled sequences
            (i.e. read count in a deep sequencing experiment), these can be
            specified as a dictionary. This currently only affects rooting and
            can be used to weigh individual tips by abundance or important during root search.

         **kwargs
            Keyword arguments to construct the GTR model

          .. Note::
                Some GTR types require additional configuration parameters.
                If the new GTR is being instantiated, these parameters are expected
                to be passed as kwargs. If nothing is passed, the default values are
                used, which might cause unexpected results.

        Raises
        ----------

         TypeError
            If a tree is not passed in