Mercurial > repos > tyty > structurefold
diff structurefold/Iterative_mapping/truncate.py @ 113:aedb21527abd draft
Uploaded
author | tyty |
---|---|
date | Tue, 14 Apr 2015 14:09:42 -0400 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/structurefold/Iterative_mapping/truncate.py Tue Apr 14 14:09:42 2015 -0400 @@ -0,0 +1,36 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import sys +from Bio import SeqIO + +fasta_file = sys.argv[1] +shift_in = sys.argv[2] +result_file = sys.argv[3] +length = sys.argv[4] +t_end = sys.argv[5] + +shift = int(shift_in) + +fasta_sequences = SeqIO.parse(open(fasta_file),'fasta'); +h = file(result_file,'w') +for seq in fasta_sequences: + nuc = seq.id; + sequence = seq.seq.tostring(); + if (len(sequence)-shift)>=int(length): + h.write('>'+nuc) + h.write('\n') + if t_end == 'three_end': + h.write(sequence[0:(len(sequence)-shift)]) + if t_end == 'five_end': + h.write(sequence[(shift):(len(sequence))]) + h.write('\n') + + + + +h.close() + + + +