Last active
October 13, 2015 06:08
-
-
Save meren/4151554 to your computer and use it in GitHub Desktop.
Adds gaps to an unaligned Illumina collection.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
sys.path.append('/bioware/pythonmodules/fastalib/') | |
import fastalib as u | |
fasta = u.SequenceSource(sys.argv[1]) | |
output = u.FastaOutput(sys.argv[1] + '-with-gaps') | |
longest_read = 0 | |
while fasta.next(): | |
if len(fasta.seq) > longest_read: | |
longest_read = len(fasta.seq) | |
fasta.reset() | |
while fasta.next(): | |
if fasta.pos % 10000 == 0: | |
sys.stdout.write('\rreads processed so far: %d' % (fasta.pos)) | |
sys.stdout.flush() | |
gaps = longest_read - len(fasta.seq) | |
output.write_id(fasta.id) | |
output.write_seq(fasta.seq + '-' * gaps, split = False) | |
fasta.close() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment