Created
June 21, 2018 09:56
-
-
Save moselhy/ca69052e074f39e0fe61440bea1bec35 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python | |
import sys | |
import os | |
if len(sys.argv) != 4: | |
print("Usage: {} (string)filename.fastq (string)readID (int)numreads".format(sys.argv[0])) | |
sys.exit(1) | |
filepath = sys.argv[1] | |
readID = sys.argv[2] | |
numreads = int(sys.argv[3]) | |
filename = os.path.splitext(filepath)[0] | |
newfilepath = "{}_new.fastq".format(filename) | |
with open(filepath, 'r') as fpread, open(newfilepath, 'w') as fpwrite: | |
for line in fpread: | |
if line.startswith(readID): | |
numreads-=1 | |
if numreads >= 0: | |
fpwrite.write(line) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment