view Iterative_mapping/truncate.py @ 66:d2817a631a7b draft

Uploaded
author tyty
date Tue, 18 Nov 2014 16:24:04 -0500
parents 9d26c2e4953e
children
line wrap: on
line source

#!/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()