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

Uploaded
author tyty
date Mon, 20 Oct 2014 14:44:01 -0400
parents d56631911cc1
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Iterative_mapping/truncate.py	Mon Oct 20 14:44:01 2014 -0400
@@ -0,0 +1,32 @@
+#!/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]
+
+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')
+                h.write(sequence[0:(len(sequence)-shift)])
+                h.write('\n')
+
+
+
+
+h.close()
+
+
+
+