diff commons/tools/tests/Test_CorrelateTEageWithGCcontent.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/tools/tests/Test_CorrelateTEageWithGCcontent.py	Tue Apr 30 14:33:21 2013 -0400
@@ -0,0 +1,60 @@
+import unittest
+import os
+from commons.core.utils.FileUtils import FileUtils
+
+
+class Test_CorrelateTEageWithGCcontent( unittest.TestCase ):
+    
+    def test_zLaunchAsScript( self ):
+        cDir = os.getcwd()
+        
+        coordFile = "dummyPathFile"
+        coordFileHandler = open( coordFile, "w" )
+        coordFileHandler.write( "1\tchr1\t1\t5\tTE1\t1\t5\t0.0\t100\t98.7\n" )
+        coordFileHandler.write( "1\tchr1\t11\t20\tTE1\t6\t15\t0.0\t100\t98.7\n" )
+        coordFileHandler.write( "2\tchr1\t26\t30\tTE1\t1\t5\t0.0\t100\t96.7\n" )
+        coordFileHandler.write( "3\tchr2\t1\t10\tTE2\t1\t10\t0.0\t100\t98.7\n" )
+        coordFileHandler.close()
+        
+        genomeFile = "dummyGenomeFile"
+        genomeFileHandler = open( genomeFile, "w" )
+        genomeFileHandler.write( ">chr1\n" )
+        genomeFileHandler.write( "AGCTGTTTTTAGCAGACGCATTTTTGGAGGTTTT\n" )
+        genomeFileHandler.write( ">chr2\n" )
+        genomeFileHandler.write( "ATATATATGGTTTTTTTTTT\n" )
+        genomeFileHandler.close()
+        
+        refseqFile = "dummyRefseqFile"
+        refseqFileHandler = open( refseqFile, "w" )
+        refseqFileHandler.write( ">TE1\nAGCAGCGACGACGACGACGACTTTT\n" )
+        refseqFileHandler.write( ">TE2\nAGCAGCGACGACGACGACGACTTTT\n" )
+        refseqFileHandler.write( ">TE3\nAGCAGCGACGACGACGACGACTTTT\n" )
+        refseqFileHandler.close()
+        
+        expFile = "dummyExpFile"
+        expFileHandler = open( expFile, "w" )
+        expFileHandler.write( "copy\tTE\tchr\tlength\tid\tGC\tlengthPerc\n" )
+        expFileHandler.write( "1\tTE1\tchr1\t15\t98.70\t%.2f\t%.2f\n" % ( 100 * 9 / 15.0, 100 * 15 / 25.0 ) )
+        expFileHandler.write( "2\tTE1\tchr1\t5\t96.70\t%.2f\t%.2f\n" % ( 100 * 4 / 5.0, 100 * 5 / 25.0 ) )
+        expFileHandler.write( "3\tTE2\tchr2\t10\t98.70\t%.2f\t%.2f\n" % ( 100 * 2 / 10.0, 100 * 10 / 25.0 ) )
+        expFileHandler.close()
+        
+        obsFile = "dummyObsFile"
+        
+        cmd = "CorrelateTEageWithGCcontent.py"
+        cmd += " -i %s" % ( coordFile )
+        cmd += " -g %s" % ( genomeFile )
+        cmd += " -r %s" % ( refseqFile )
+        cmd += " -o %s" % ( obsFile )
+        cmd += " -v %i" % ( 0 )
+        returnStatus = os.system( cmd )
+        
+        self.assertTrue( returnStatus == 0 )
+        self.assertTrue( FileUtils.are2FilesIdentical( expFile, obsFile ) )
+        
+        for f in [ coordFile, genomeFile, refseqFile, expFile, obsFile ]:
+            os.remove( f )
+        os.chdir( cDir )
+        
+if __name__ == "__main__":
+        unittest.main()
\ No newline at end of file