Created
April 22, 2013 15:30
-
-
Save falsetru/5435949 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 collections | |
import sys | |
def is_valid_fastq(lines): | |
return ( | |
lines[0].startswith('@') and | |
lines[2].startswith('+') and | |
len(lines[1]) == len(lines[3]) | |
) | |
def FastqIterator(f): | |
lines = collections.deque([next(f) for _ in range(3)], maxlen=4) | |
for line in f: | |
lines.append(line) | |
if is_valid_fastq(lines): | |
#yield from lines | |
for line in lines: | |
yield line | |
if __name__ == '__main__': | |
sys.stdout.writelines(FastqIterator(sys.stdin)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment