From 0e29e97366bc3bed447efc1d2e1df1f8ad19aa48 Mon Sep 17 00:00:00 2001 From: Guruprasad Anada Date: Mon, 20 Jul 2009 16:57:55 -0400 Subject: [PATCH] Committing changes to 'extract genomic dna' tool - twobit file will be opened only once per job. (Courtesy: Gordon). --- tools/extract/extract_genomic_dna.py | 11 +++++------ tools/extract/extract_genomic_dna.xml | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/tools/extract/extract_genomic_dna.py b/tools/extract/extract_genomic_dna.py index ce54c7c1eed..7ebdbd60a27 100644 --- a/tools/extract/extract_genomic_dna.py +++ b/tools/extract/extract_genomic_dna.py @@ -70,7 +70,8 @@ def __main__(): fout = open( output_filename, "w" ) warnings = [] warning = '' - + twobitfile = None + for i, line in enumerate( open( input_filename ) ): line = line.rstrip( '\r\n' ) if line and not line.startswith( "#" ): @@ -118,12 +119,10 @@ def __main__(): invalid_line = line continue elif seq_path and os.path.isfile( seq_path ): - if chrom in twobits: - t = twobits[chrom] - else: - twobits[chrom] = t = bx.seq.twobit.TwoBitFile( file( seq_path ) ) + if not(twobitfile): + twobitfile = bx.seq.twobit.TwoBitFile( file( seq_path ) ) try: - sequence = t[chrom][start:end] + sequence = twobitfile[chrom][start:end] except: warning = "Unable to fetch the sequence from '%d' to '%d' for build '%s'. " %( start, end-start, dbkey ) warnings.append( warning ) diff --git a/tools/extract/extract_genomic_dna.xml b/tools/extract/extract_genomic_dna.xml index 08fd15d129b..83d91959818 100644 --- a/tools/extract/extract_genomic_dna.xml +++ b/tools/extract/extract_genomic_dna.xml @@ -1,4 +1,4 @@ - + using coordinates from assembled/unassembled genomes extract_genomic_dna.py $input $out_file1 -1 ${input.metadata.chromCol},${input.metadata.startCol},${input.metadata.endCol},${input.metadata.strandCol} -d $dbkey -o $out_format -g ${GALAXY_DATA_INDEX_DIR}