Skip to content

Instantly share code, notes, and snippets.

@falsetru
Created April 22, 2013 15:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save falsetru/5435949 to your computer and use it in GitHub Desktop.
Save falsetru/5435949 to your computer and use it in GitHub Desktop.
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