Mercurial > repos > tyty > structurefold
comparison upload/Iterative_mapping/truncate.py @ 34:d74ed492efdd draft
Uploaded
| author | tyty |
|---|---|
| date | Mon, 20 Oct 2014 14:55:16 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 33:1a92d934f8d1 | 34:d74ed492efdd |
|---|---|
| 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 |
