56
|
1 #!/usr/bin/env python
|
|
2 # -*- coding: utf-8 -*-
|
|
3
|
|
4 import sys
|
|
5 from Bio import SeqIO
|
|
6
|
|
7 fasta_file = sys.argv[1]
|
|
8 shift_in = sys.argv[2]
|
|
9 result_file = sys.argv[3]
|
|
10 length = sys.argv[4]
|
|
11 t_end = sys.argv[5]
|
|
12
|
|
13 shift = int(shift_in)
|
|
14
|
|
15 fasta_sequences = SeqIO.parse(open(fasta_file),'fasta');
|
|
16 h = file(result_file,'w')
|
|
17 for seq in fasta_sequences:
|
|
18 nuc = seq.id;
|
|
19 sequence = seq.seq.tostring();
|
|
20 if (len(sequence)-shift)>=int(length):
|
|
21 h.write('>'+nuc)
|
|
22 h.write('\n')
|
|
23 if t_end == 'three_end':
|
|
24 h.write(sequence[0:(len(sequence)-shift)])
|
|
25 if t_end == 'five_end':
|
|
26 h.write(sequence[(shift):(len(sequence))])
|
|
27 h.write('\n')
|
|
28
|
|
29
|
|
30
|
|
31
|
|
32 h.close()
|
|
33
|
|
34
|
|
35
|
|
36
|