Created
August 13, 2012 17:36
-
-
Save jwintersinger/3342665 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
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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I like