# Path: xenoGI/genomes.py
# def loadSeq(paramD,fileEnding,genesS=None):
#     def __init__(self, geneInfoFN):
#     def initializeGeneRangeByStrainD(self,geneInfoFN):
#     def initializeStrainGeneRangeT(self):
#     def initializeGeneNumToNameD(self,geneInfoFN,strainNamesL=None):
#     def initializeGeneInfoD(self,geneInfoFN,strainNamesL=None):
#     def loadDictFromGeneInfoFile(self,geneInfoFN,strainNamesL,onlyNames):
#     def numToStrainName(self,geneNum):
#     def numToName(self,geneNumber):
#     def iterGenes(self,strainL=None):
#     def iterGenesStrain(self,strainName):
#     def numToGeneInfo(self,geneNumber):
#     def __len__(self):
#     def __repr__(self):
# def getProximityInWindow(geneWinT,geneProximityD):
# def createGeneProximityD(geneOrderD,geneProximityForGroup):
# def createGeneOrderD(geneOrderFN,strainNamesL):
# class genes:
#         D = {}
#         L=s.split('\t')
# 
# Path: xenoGI/fasta.py
# def load(filename):


from Bio import Phylo
from multiprocessing import Pool
from .Tree import *
from xenoGI import genomes,fasta
import glob,os,shutil,subprocess
            else:
                f.write(">" + str(geneNum) + "\n")

            f.write(seqD[geneNum] + "\n")
            f.write("\n")

def backAlign(outAlignFN,protAlignL,dnaSeqD,genesO):
    '''Prints the nucleotide alignments given by one block of protein
    alignments.'''
    with open(outAlignFN,'w') as outf:
        printBlock=''
        for geneNum,header,protSeq in protAlignL:
            dnaSeq = dnaSeqD[geneNum]
            lenProtein = len(protSeq) - protSeq.count('-')
            if (lenProtein + 1) * 3 != len(dnaSeq):
                # dna has stop codon                          
                raise IndexError("Lengths of dna and protein do not correspond.")

            strainName = genesO.numToStrainName(geneNum)
            # add header
            printBlock += header + '\n'
            # adding gaps to the nucleotide sequence corresponding to gaps in 
            # the protein sequence and printing the nucleotide sequence
            printBlock += fixSeq(dnaSeq, protSeq) + "\n"
        print(printBlock,file=outf)

def fixSeq(sequence, protAlignment):
    """takes a nucleotide sequence and adds in gaps based on the corresponding
    protein alignment."""
    result = ""

# Path: xenoGI/genomes.py
# def loadSeq(paramD,fileEnding,genesS=None):
#     def __init__(self, geneInfoFN):
#     def initializeGeneRangeByStrainD(self,geneInfoFN):
#     def initializeStrainGeneRangeT(self):
#     def initializeGeneNumToNameD(self,geneInfoFN,strainNamesL=None):
#     def initializeGeneInfoD(self,geneInfoFN,strainNamesL=None):
#     def loadDictFromGeneInfoFile(self,geneInfoFN,strainNamesL,onlyNames):
#     def numToStrainName(self,geneNum):
#     def numToName(self,geneNumber):
#     def iterGenes(self,strainL=None):
#     def iterGenesStrain(self,strainName):
#     def numToGeneInfo(self,geneNumber):
#     def __len__(self):
#     def __repr__(self):
# def getProximityInWindow(geneWinT,geneProximityD):
# def createGeneProximityD(geneOrderD,geneProximityForGroup):
# def createGeneOrderD(geneOrderFN,strainNamesL):
# class genes:
#         D = {}
#         L=s.split('\t')
# 
# Path: xenoGI/fasta.py
# def load(filename):


# Path: xenoGI/trees.py
from Bio import Phylo
from multiprocessing import Pool
from .Tree import *
from xenoGI import genomes,fasta
import glob,os,shutil,subprocess

            else:
                f.write(">" + str(geneNum) + "\n")

            f.write(seqD[geneNum] + "\n")
            f.write("\n")

def backAlign(outAlignFN,protAlignL,dnaSeqD,genesO):
    '''Prints the nucleotide alignments given by one block of protein
    alignments.'''
    with open(outAlignFN,'w') as outf:
        printBlock=''
        for geneNum,header,protSeq in protAlignL:
            dnaSeq = dnaSeqD[geneNum]
            lenProtein = len(protSeq) - protSeq.count('-')
            if (lenProtein + 1) * 3 != len(dnaSeq):
                # dna has stop codon                          
                raise IndexError("Lengths of dna and protein do not correspond.")

            strainName = genesO.numToStrainName(geneNum)
            # add header
            printBlock += header + '\n'
            # adding gaps to the nucleotide sequence corresponding to gaps in 
            # the protein sequence and printing the nucleotide sequence
            printBlock += fixSeq(dnaSeq, protSeq) + "\n"
        print(printBlock,file=outf)

def fixSeq(sequence, protAlignment):
    """takes a nucleotide sequence and adds in gaps based on the corresponding
    protein alignment."""
    result = ""

    x = 0