Skip to content

Instantly share code, notes, and snippets.

@walterst
Created November 22, 2013 15:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save walterst/7602058 to your computer and use it in GitHub Desktop.
Save walterst/7602058 to your computer and use it in GitHub Desktop.
Usage: python filter_short_reads.py X Y > Z where X is the input fasta file Y is the minimum length Z is the output fasta file
#!/usr/bin/env python
"""Usage:
python filter_short_reads.py X Y > Z
where
X is the input fasta file
Y is the minimum length
Z is the output fasta file
"""
from sys import argv
from cogent.parse.fasta import MinimalFastaParser
fasta_f = open(argv[1], "U")
min_len = int(argv[2])
for label, seq in MinimalFastaParser(fasta_f):
if len(seq) >= min_len:
print ">%s\n%s" % (label, seq)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment