-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFAfilterByLenght.py
More file actions
22 lines (20 loc) · 928 Bytes
/
FAfilterByLenght.py
File metadata and controls
22 lines (20 loc) · 928 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from Bio import SeqIO
def FAfilterByLength(sequence, lengths, output_fasta):
"""Well exclude some ids from a multifasta file
"""
fasta_seq = SeqIO.parse(sequence, 'fasta')
buffer_seqs = []
for record in fasta_seq:
if str(len(record.seq)) in lengths:
buffer_seqs.append(record)
SeqIO.write(buffer_seqs, output_fasta, "fasta")
if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser()#pylint: disable=invalid-name
parser.add_argument("-s", "--sequence", help="Sequence file (.fasta)", required=True)
parser.add_argument("-l", "--lenghts", help="Exclude some ids", action='append')
parser.add_argument("-o", "--output", help="Output file name (.fasta format)", required=True)
args = parser.parse_args()#pylint: disable=invalid-name
FAfilterByLength(args.sequence, args.lenghts, args.output)