Mercurial > repos > yufei-luo > s_mart
view commons/tools/tests/Test_CorrelateTEageWithGCcontent.py @ 18:94ab73e8a190
Uploaded
author | m-zytnicki |
---|---|
date | Mon, 29 Apr 2013 03:20:15 -0400 |
parents | |
children |
line wrap: on
line source
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()