Created
October 28, 2016 05:50
-
-
Save wckdouglas/c3c794b2e7aadd2395fc6c1afb90151a 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
| def read_fastq(file_fq): | |
| """ | |
| takes a fastq file as input | |
| yields idSeq, sequence and score | |
| for each fastq entry | |
| learned from: | |
| http://codereview.stackexchange.com/questions/32897/efficient-parsing-of-fastq | |
| """ | |
| line_count = 0 | |
| while True: | |
| line = file_fq.readline() | |
| line_count += 1 | |
| #break if we hit the end of the file | |
| if not line: | |
| break | |
| if line_count == 1: | |
| idSeq = line.strip().lstrip('@') | |
| elif line_count == 2: | |
| sequence = line.strip() | |
| elif line_count == 4: | |
| score = line.strip() | |
| line_count = 0 | |
| yield idSeq,sequence, score | |
| yield idSeq, sequence, score |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment