Mercurial > repos > tyty > structurefold
comparison Iterative_mapping/truncate.py @ 104:60278e5df493 draft
Uploaded
author | tyty |
---|---|
date | Thu, 19 Mar 2015 17:42:48 -0400 |
parents | 9d26c2e4953e |
children |
comparison
equal
deleted
inserted
replaced
103:51fa1298f55e | 104:60278e5df493 |
---|---|
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 |