comparison Iterative_mapping/truncate.py @ 30:4d81d174dece draft

Uploaded
author tyty
date Mon, 20 Oct 2014 14:44:01 -0400
parents d56631911cc1
children
comparison
equal deleted inserted replaced
29:003096bd038c 30:4d81d174dece
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
12 shift = int(shift_in)
13
14 fasta_sequences = SeqIO.parse(open(fasta_file),'fasta');
15 h = file(result_file,'w')
16 for seq in fasta_sequences:
17 nuc = seq.id;
18 sequence = seq.seq.tostring();
19 if (len(sequence)-shift)>=int(length):
20 h.write('>'+nuc)
21 h.write('\n')
22 h.write(sequence[0:(len(sequence)-shift)])
23 h.write('\n')
24
25
26
27
28 h.close()
29
30
31
32