diff commons/pyRepetUnit/fastaTranslation/allFrames/TranslateInAllFramesAndReplaceStopByX.py @ 31:0ab839023fe4

Uploaded
author m-zytnicki
date Tue, 30 Apr 2013 14:33:21 -0400
parents 94ab73e8a190
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commons/pyRepetUnit/fastaTranslation/allFrames/TranslateInAllFramesAndReplaceStopByX.py	Tue Apr 30 14:33:21 2013 -0400
@@ -0,0 +1,26 @@
+from commons.core.utils.FileUtils import FileUtils
+from commons.core.seq.BioseqUtils import BioseqUtils
+
+class TranslateInAllFramesAndReplaceStopByX(object):
+
+    def __init__(self):
+        self._inputFile = "" 
+        self._outputFile =  ""
+    
+    def setInputFile(self, input):
+        self._inputFile = input
+
+    def setOutputFile(self, output):
+        self._outputFile = output    
+        
+    def run(self):
+        """
+        read a fasta file with nucleotide sequences and translate all sequences in all frames, write the result in a file
+        """
+        if not FileUtils.isRessourceExists(self._inputFile):
+            raise Exception("Warning your input file %s does not exist!\n" % self._inputFile)
+        bioseqList = BioseqUtils.extractBioseqListFromFastaFile(self._inputFile)
+        bioseqListInAllFrames = BioseqUtils.translateBioseqListInAllFrames(bioseqList)
+        bioseqListTranslatedAndStopsReplace = BioseqUtils.replaceStopCodonsByXInBioseqList(bioseqListInAllFrames)
+        BioseqUtils.writeBioseqListIntoFastaFile(bioseqListTranslatedAndStopsReplace, self._outputFile)   
+                
\ No newline at end of file