diff Iterative_mapping/truncate.py @ 71:b6bdd41440f3 draft

Uploaded
author tyty
date Tue, 09 Dec 2014 03:02:27 -0500
parents 9d26c2e4953e
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Iterative_mapping/truncate.py	Tue Dec 09 03:02:27 2014 -0500
@@ -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()
+
+
+
+