# Path: xenoGI/trees.py
# def prepareTree(bpTree,outGroupTaxaL):
# def rootTree(bpTree,outGroupTaxaL):
# def makeRootBifurcation(bpTree,outGroupTaxaL):
# def tipsInOutgroupL(clade,outGroupTaxaL):
# def cladeTipNames(clade):
# def nameInternalNodes(bpTree,nameStem):
# def makeSpeciesTree(paramD,aabrhHardCoreL,genesO):
# def makeGeneFamilyTrees(paramD,genesO,familiesO,gtFileStem = 'fam'):
# def makeGeneTrees(paramD,strainHeader,genesO,workDir,gtFileStem,orthoTL):
# def makeOneGeneTreeGroup(argT):
# def makeOneGeneTree(orthoGroupNumStr,orthoT,strainHeader,genesO,protSeqD,dnaSeqD,workDir,gtFileStem,musclePath,fastTreePath):
# def alignOneOrthoT(orthoT,strainHeader,musclePath,inProtFN,outAlignFN,protSeqD,dnaSeqD,genesO):
# def writeFasta(inProtFN,orthoT,strainHeader,genesO,seqD):
# def backAlign(outAlignFN,protAlignL,dnaSeqD,genesO):
# def fixSeq(sequence, protAlignment):
#     L=[]


from Bio import Phylo
from collections import OrderedDict
from xenoGI import trees
        '''Return boolean if node is a leaf'''
        if len(self.nodeConnectD[node]) < 3:
            # internal node must have at least 3 connections
            return True
        else: return False

    def preorder(self):
        return self.preOrderT

    def leaves(self):
        return self.leafNodeT

    def internals(self):
        return self.internalNodeT

    def leafCount(self):
        return len(self.leafNodeT)

    def internalNodeCount(self):
        return len(self.internalNodeT)
    
    def nodeCount(self):
        return len(self.nodeConnectD)

    def multifurcatingNodes(self):
        '''Return a list of all nodes where there's a multifurcation (more
than 3 branches).'''
        multifurcL = []
        for node,connecT in self.nodeConnectD.items():
            if len(connecT) > 3:

# Path: xenoGI/trees.py
# def prepareTree(bpTree,outGroupTaxaL):
# def rootTree(bpTree,outGroupTaxaL):
# def makeRootBifurcation(bpTree,outGroupTaxaL):
# def tipsInOutgroupL(clade,outGroupTaxaL):
# def cladeTipNames(clade):
# def nameInternalNodes(bpTree,nameStem):
# def makeSpeciesTree(paramD,aabrhHardCoreL,genesO):
# def makeGeneFamilyTrees(paramD,genesO,familiesO,gtFileStem = 'fam'):
# def makeGeneTrees(paramD,strainHeader,genesO,workDir,gtFileStem,orthoTL):
# def makeOneGeneTreeGroup(argT):
# def makeOneGeneTree(orthoGroupNumStr,orthoT,strainHeader,genesO,protSeqD,dnaSeqD,workDir,gtFileStem,musclePath,fastTreePath):
# def alignOneOrthoT(orthoT,strainHeader,musclePath,inProtFN,outAlignFN,protSeqD,dnaSeqD,genesO):
# def writeFasta(inProtFN,orthoT,strainHeader,genesO,seqD):
# def backAlign(outAlignFN,protAlignL,dnaSeqD,genesO):
# def fixSeq(sequence, protAlignment):
#     L=[]


# Path: xenoGI/Tree.py
from Bio import Phylo
from collections import OrderedDict
from xenoGI import trees

        '''Return boolean if node is a leaf'''
        if len(self.nodeConnectD[node]) < 3:
            # internal node must have at least 3 connections
            return True
        else: return False

    def preorder(self):
        return self.preOrderT

    def leaves(self):
        return self.leafNodeT

    def internals(self):
        return self.internalNodeT

    def leafCount(self):
        return len(self.leafNodeT)

    def internalNodeCount(self):
        return len(self.internalNodeT)
    
    def nodeCount(self):
        return len(self.nodeConnectD)

    def multifurcatingNodes(self):
        '''Return a list of all nodes where there's a multifurcation (more
than 3 branches).'''
        multifurcL = []
        for node,connecT in self.nodeConnectD.items():
            if len(connecT) > 3:

                multifurcL.append(node)