Skip to content

Instantly share code, notes, and snippets.

@jwintersinger
Created August 13, 2012 17:36
Show Gist options
  • Save jwintersinger/3342665 to your computer and use it in GitHub Desktop.
Save jwintersinger/3342665 to your computer and use it in GitHub Desktop.
import argparse
from __future__ import with_statement
from Bio import SeqIO
def main():
parser = argparse.ArgumentParser()
parser.add_argument("inputFile", help="Input FASTA file")
parser.add_argument("outputFile",help="Filtered FASTA output")
parser.add_argument("-d", "--header", default=None, dest="sampleName", help="Sample name to remove")
args = parser.parse_args()
if not args.sampleName:
raise Exception('Please specify a sample name to remove.')
with open(args.outputFile, "w") as fileOut:
for seq_record in SeqIO.parse(args.inputFile, "fasta"):
if args.sampleName not in seq_record.id:
fileOut.write(seq_record.format("fasta"))
if __name__ == '__main__':
main()
@ivan-krukov
Copy link

I like

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment