| 18 | 1 import unittest | 
|  | 2 import os, glob | 
|  | 3 from SMART.Java.Python.getWigProfile import GetWigProfile | 
|  | 4 | 
|  | 5 | 
|  | 6 class Test_F_GetWigProfile(unittest.TestCase): | 
|  | 7 | 
|  | 8     def setUp(self): | 
|  | 9         self.transcriptFileName = "transcriptFile.gff3" | 
|  | 10         self.wigFileName        = "file.wig" | 
|  | 11         self.outputFileName     = "outputFile.png" | 
|  | 12 | 
|  | 13     def tearDown(self): | 
|  | 14         for fileRoot in (self.transcriptFileName, self.wigFileName, self.outputFileName): | 
|  | 15             for file in glob.glob("%s*" % (fileRoot)): | 
|  | 16                 os.remove(file) | 
|  | 17         os.system("rm .RData .chr1.index ") | 
|  | 18 | 
|  | 19     def test_run_simple(self): | 
|  | 20         handle = open(self.transcriptFileName, "w") | 
|  | 21         handle.write("chr1\tSMART\tmRNA\t10\t20\t.\t+\t.\tID=test1;Name=test1") | 
|  | 22         handle.close() | 
|  | 23         handle = open(self.wigFileName, "w") | 
|  | 24         handle.write("variableStep chrom=chr1\n") | 
|  | 25         handle.write("1 1\n") | 
|  | 26         handle.write("2 1\n") | 
|  | 27         handle.write("3 1\n") | 
|  | 28         handle.write("4 1\n") | 
|  | 29         handle.write("5 1\n") | 
|  | 30         handle.write("6 1\n") | 
|  | 31         handle.write("7 1\n") | 
|  | 32         handle.write("8 1\n") | 
|  | 33         handle.write("9 1\n") | 
|  | 34         handle.write("10 1\n") | 
|  | 35         handle.write("11 2\n") | 
|  | 36         handle.write("12 3\n") | 
|  | 37         handle.write("13 4\n") | 
|  | 38         handle.write("14 5\n") | 
|  | 39         handle.write("15 5\n") | 
|  | 40         handle.write("16 5\n") | 
|  | 41         handle.write("17 5\n") | 
|  | 42         handle.write("18 5\n") | 
|  | 43         handle.write("19 5\n") | 
|  | 44         handle.write("20 5\n") | 
|  | 45         handle.write("21 1\n") | 
|  | 46         handle.write("21 1\n") | 
|  | 47         handle.close() | 
|  | 48         wigProfile = GetWigProfile(0) | 
|  | 49         wigProfile.strands        = False | 
|  | 50         wigProfile.inputFileName  = self.transcriptFileName | 
|  | 51         wigProfile.inputFormat    = "gff3" | 
|  | 52         wigProfile.wig            = self.wigFileName | 
|  | 53         wigProfile.nbPoints       = 11 | 
|  | 54         wigProfile.distance       = 1 | 
|  | 55         wigProfile.smoothenForce  = None | 
|  | 56         wigProfile.log            = False | 
|  | 57         wigProfile.outputFileName = self.outputFileName | 
|  | 58         wigProfile.readTranscripts() | 
|  | 59         wigProfile.smoothen() | 
|  | 60         wigProfile.plot() | 
|  | 61         self.assertTrue(os.path.exists(self.outputFileName)) | 
|  | 62 | 
|  | 63 if __name__ == "__main__": | 
|  | 64     unittest.main() | 
|  | 65 |