annotate Iterative_mapping/truncate.py @ 62:58df1060fea1 draft

Uploaded
author tyty
date Tue, 18 Nov 2014 15:53:42 -0500
parents 9d26c2e4953e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
56
9d26c2e4953e Uploaded
tyty
parents:
diff changeset
1 #!/usr/bin/env python
9d26c2e4953e Uploaded
tyty
parents:
diff changeset
2 # -*- coding: utf-8 -*-
9d26c2e4953e Uploaded
tyty
parents:
diff changeset
3
9d26c2e4953e Uploaded
tyty
parents:
diff changeset
4 import sys
9d26c2e4953e Uploaded
tyty
parents:
diff changeset
5 from Bio import SeqIO
9d26c2e4953e Uploaded
tyty
parents:
diff changeset
6
9d26c2e4953e Uploaded
tyty
parents:
diff changeset
7 fasta_file = sys.argv[1]
9d26c2e4953e Uploaded
tyty
parents:
diff changeset
8 shift_in = sys.argv[2]
9d26c2e4953e Uploaded
tyty
parents:
diff changeset
9 result_file = sys.argv[3]
9d26c2e4953e Uploaded
tyty
parents:
diff changeset
10 length = sys.argv[4]
9d26c2e4953e Uploaded
tyty
parents:
diff changeset
11 t_end = sys.argv[5]
9d26c2e4953e Uploaded
tyty
parents:
diff changeset
12
9d26c2e4953e Uploaded
tyty
parents:
diff changeset
13 shift = int(shift_in)
9d26c2e4953e Uploaded
tyty
parents:
diff changeset
14
9d26c2e4953e Uploaded
tyty
parents:
diff changeset
15 fasta_sequences = SeqIO.parse(open(fasta_file),'fasta');
9d26c2e4953e Uploaded
tyty
parents:
diff changeset
16 h = file(result_file,'w')
9d26c2e4953e Uploaded
tyty
parents:
diff changeset
17 for seq in fasta_sequences:
9d26c2e4953e Uploaded
tyty
parents:
diff changeset
18 nuc = seq.id;
9d26c2e4953e Uploaded
tyty
parents:
diff changeset
19 sequence = seq.seq.tostring();
9d26c2e4953e Uploaded
tyty
parents:
diff changeset
20 if (len(sequence)-shift)>=int(length):
9d26c2e4953e Uploaded
tyty
parents:
diff changeset
21 h.write('>'+nuc)
9d26c2e4953e Uploaded
tyty
parents:
diff changeset
22 h.write('\n')
9d26c2e4953e Uploaded
tyty
parents:
diff changeset
23 if t_end == 'three_end':
9d26c2e4953e Uploaded
tyty
parents:
diff changeset
24 h.write(sequence[0:(len(sequence)-shift)])
9d26c2e4953e Uploaded
tyty
parents:
diff changeset
25 if t_end == 'five_end':
9d26c2e4953e Uploaded
tyty
parents:
diff changeset
26 h.write(sequence[(shift):(len(sequence))])
9d26c2e4953e Uploaded
tyty
parents:
diff changeset
27 h.write('\n')
9d26c2e4953e Uploaded
tyty
parents:
diff changeset
28
9d26c2e4953e Uploaded
tyty
parents:
diff changeset
29
9d26c2e4953e Uploaded
tyty
parents:
diff changeset
30
9d26c2e4953e Uploaded
tyty
parents:
diff changeset
31
9d26c2e4953e Uploaded
tyty
parents:
diff changeset
32 h.close()
9d26c2e4953e Uploaded
tyty
parents:
diff changeset
33
9d26c2e4953e Uploaded
tyty
parents:
diff changeset
34
9d26c2e4953e Uploaded
tyty
parents:
diff changeset
35
9d26c2e4953e Uploaded
tyty
parents:
diff changeset
36