Skip to content

Commit

Permalink
Merge pull request #123 from broadinstitute/ct-add-mafft
Browse files Browse the repository at this point in the history
manual closure of input files in transposeChromosomeFiles()
  • Loading branch information
dpark01 committed Apr 9, 2015
2 parents b45370f + f46c40d commit 2061965
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions interhost.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,12 +373,14 @@ def make_vcf(a, ref_idx, chrom):
if a[k][i] == alt[m]:
vars.append(m+1)
yield row+vars
def transposeChromosomeFiles(inputFilesList, outputDirectory, outputFilePrefix, inputFormat="fasta", outputFormat="fasta"):

def transposeChromosomeFiles(inputFilenamesList, outputDirectory, outputFilePrefix, inputFormat="fasta", outputFormat="fasta"):
outputFilenames = []

# open files
inputFilesList = [open(x, 'rU') for x in inputFilenamesList]
# get BioPython iterators for each of the FASTA files specified in the input
fastaFiles = [SeqIO.parse(open(x, "rU"), inputFormat) for x in inputFilesList]
fastaFiles = [SeqIO.parse(x, inputFormat) for x in inputFilesList]

# for each interleaved record
for idx, chrRecordList in enumerate( zip(*fastaFiles) ):
Expand All @@ -391,6 +393,9 @@ def transposeChromosomeFiles(inputFilesList, outputDirectory, outputFilePrefix,
fileObj.close()
outputFilenames.append(os.path.abspath(outputFilename))

#close input files
[x.close() for x in inputFilesList]

return outputFilenames

def full_parser():
Expand Down

0 comments on commit 2061965

Please sign in to comment.