annotate commons/core/parsing/test/Test_Multifasta2SNPFile.py @ 6:769e306b7933

Change the repository level.
author yufei-luo
date Fri, 18 Jan 2013 04:54:14 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1 import os
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
2 import shutil
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
3 import unittest
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
4 from commons.core.utils.FileUtils import FileUtils
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
5 from commons.core.parsing.Multifasta2SNPFile import Multifasta2SNPFile
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
6 from commons.core.parsing.Multifasta2SNPFile import ReferenceBioseqAndLinesBioseqDBWrapper
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
7 from commons.core.seq.Bioseq import Bioseq
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
8 from commons.core.seq.BioseqDB import BioseqDB
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
9 from smac_pipe.tests.Utils4Test import Utils4Test
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
10
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
11
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
12 class Test_Multifasta2SNPFile(unittest.TestCase):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
13 # TODO TEST LOGFILE
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
14 def setUp(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
15 os.chdir("%s/commons/core/parsing/test/" % os.environ["REPET_PATH"])
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
16 self._inFileName = "multifasta_input.fasta"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
17
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
18 self._expSubSNPFileName = "%s/commons/core/parsing/test/expSubSNP.csv" % os.environ["REPET_PATH"]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
19 self._expAlleleFileName = "%s/commons/core/parsing/test/expAllele.csv" % os.environ["REPET_PATH"]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
20
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
21 self._expIndividualFileName = "%s/commons/core/parsing/test/expIndividual.csv" % os.environ["REPET_PATH"]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
22 self._expSequenceFSAFileName = "%s/commons/core/parsing/test/expSequences.fsa" % os.environ["REPET_PATH"]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
23 self._expSequenceCSVFileName = "%s/commons/core/parsing/test/expSequences.csv" % os.environ["REPET_PATH"]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
24 self._expBatchFileName = "%s/commons/core/parsing/test/expBatch.txt" % os.environ["REPET_PATH"]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
25 self._expBatchLineFileName = "%s/commons/core/parsing/test/expBatchLine.csv" % os.environ["REPET_PATH"]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
26
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
27 self._realInputFileName = "data/real_multifasta_input.fasta"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
28 self._realExpSubSNPFileName = "data/realExpSubSNP.csv"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
29 self._realExpSequenceFSAFileName = "data/realExpSequences.fsa"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
30 self._realExpBatchLineFileName = "data/realExpBatchLine.csv"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
31 self._realExpIndividualFileName = "data/realExpIndividual.csv"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
32
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
33 self._inputDirSeveralBatches = "%s/commons/core/parsing/test/severalBatchDir" % os.environ["REPET_PATH"]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
34
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
35 self._obsSubSNPFileName = "SubSNP.csv"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
36 self._obsAlleleFileName = "Allele.csv"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
37 self._obsIndividualFileName = "Individual.csv"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
38 self._obsSequenceFSAFileName = "Sequences.fsa"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
39 self._obsSequenceCSVFileName = "Sequences.csv"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
40 self._obsBatchFileName = "Batch.txt"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
41 self._obsBatchLineFileName = "BatchLine.csv"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
42
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
43 self._fileUtils = FileUtils()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
44
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
45 def tearDown(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
46 os.chdir("%s/commons/core/parsing/test/" % os.environ["REPET_PATH"])
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
47 logFileName = "multifasta2SNP.log"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
48 if self._fileUtils.isRessourceExists(self._inFileName):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
49 os.remove(self._inFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
50 if self._fileUtils.isRessourceExists(self._obsSubSNPFileName):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
51 os.remove(self._obsSubSNPFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
52 if self._fileUtils.isRessourceExists(self._obsSubSNPFileName + "_filtered"):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
53 os.remove(self._obsSubSNPFileName + "_filtered")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
54 if self._fileUtils.isRessourceExists(self._obsAlleleFileName):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
55 os.remove(self._obsAlleleFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
56 if self._fileUtils.isRessourceExists(self._obsIndividualFileName):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
57 os.remove(self._obsIndividualFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
58 if self._fileUtils.isRessourceExists(self._obsSequenceFSAFileName):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
59 os.remove(self._obsSequenceFSAFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
60 if self._fileUtils.isRessourceExists(self._obsSequenceCSVFileName):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
61 os.remove(self._obsSequenceCSVFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
62 if self._fileUtils.isRessourceExists(self._obsBatchFileName):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
63 os.remove(self._obsBatchFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
64 if self._fileUtils.isRessourceExists(self._obsBatchLineFileName):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
65 os.remove(self._obsBatchLineFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
66
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
67 if self._fileUtils.isRessourceExists(self._expSubSNPFileName):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
68 os.remove(self._expSubSNPFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
69 if self._fileUtils.isRessourceExists(self._realExpSubSNPFileName + "_filtered"):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
70 os.remove(self._realExpSubSNPFileName + "_filtered")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
71 if self._fileUtils.isRessourceExists(self._expAlleleFileName):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
72 os.remove(self._expAlleleFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
73 if self._fileUtils.isRessourceExists(self._expIndividualFileName):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
74 os.remove(self._expIndividualFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
75 if self._fileUtils.isRessourceExists(self._expSequenceFSAFileName):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
76 os.remove(self._expSequenceFSAFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
77 if self._fileUtils.isRessourceExists(self._expSequenceCSVFileName):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
78 os.remove(self._expSequenceCSVFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
79 if self._fileUtils.isRessourceExists(self._expBatchFileName):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
80 os.remove(self._expBatchFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
81 if self._fileUtils.isRessourceExists(self._expBatchLineFileName):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
82 os.remove(self._expBatchLineFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
83
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
84 if self._fileUtils.isRessourceExists(logFileName):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
85 os.remove(logFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
86 if self._fileUtils.isRessourceExists(self._inputDirSeveralBatches):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
87 shutil.rmtree(self._inputDirSeveralBatches)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
88
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
89
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
90 def test_runOneBatch(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
91 self._writeInputFile()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
92 self._writeExpSubSNPFile()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
93 self._writeExpAlleleFile()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
94 self._writeExpIndividualFile()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
95 self._writeExpSequenceFile()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
96 self._writeExpBatchFile()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
97 self._writeExpBatchLineFile()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
98
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
99 multifasta2SNPFile = Multifasta2SNPFile("Arabidopsis thaliana", "Batch1", "methyltransferase")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
100 multifasta2SNPFile.runOneBatch(self._inFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
101
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
102 self.assertTrue(FileUtils.isRessourceExists(self._obsAlleleFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
103 self.assertTrue(FileUtils.are2FilesIdentical(self._expAlleleFileName, self._obsAlleleFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
104
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
105 self.assertTrue(FileUtils.isRessourceExists(self._obsIndividualFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
106 self.assertTrue(FileUtils.are2FilesIdentical(self._expIndividualFileName, self._obsIndividualFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
107
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
108 self.assertTrue(FileUtils.isRessourceExists(self._obsSequenceFSAFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
109 self.assertTrue(FileUtils.are2FilesIdentical(self._expSequenceFSAFileName, self._obsSequenceFSAFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
110
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
111 self.assertTrue(FileUtils.isRessourceExists(self._obsSequenceCSVFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
112 self.assertTrue(FileUtils.are2FilesIdentical(self._expSequenceCSVFileName, self._obsSequenceCSVFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
113
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
114 self.assertTrue(FileUtils.isRessourceExists(self._obsBatchFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
115 self.assertTrue(FileUtils.are2FilesIdentical(self._expBatchFileName, self._obsBatchFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
116
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
117 self.assertTrue(FileUtils.isRessourceExists(self._obsBatchLineFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
118 self.assertTrue(FileUtils.are2FilesIdentical(self._expBatchLineFileName, self._obsBatchLineFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
119 self.assertTrue(FileUtils.isRessourceExists(self._obsSubSNPFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
120 self.assertTrue(FileUtils.are2FilesIdentical(self._expSubSNPFileName, self._obsSubSNPFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
121
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
122 def test_runOneBatch_with_a_real_input_file(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
123 self._writeRealExpAlleleFile()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
124 self._writeRealExpSequenceCSVFile()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
125 self._writeRealExpBatchFile()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
126
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
127 multifasta2SNPFile = Multifasta2SNPFile("Pinus pinaster", "INRA_Pinus_pinaster_HDZ31-1", "PpHDZ31")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
128 multifasta2SNPFile.runOneBatch(self._realInputFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
129
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
130 self.assertTrue(FileUtils.isRessourceExists(self._obsIndividualFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
131 self.assertTrue(FileUtils.are2FilesIdentical(self._realExpIndividualFileName, self._obsIndividualFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
132
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
133 self.assertTrue(FileUtils.isRessourceExists(self._obsSequenceFSAFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
134 self.assertTrue(FileUtils.are2FilesIdentical(self._realExpSequenceFSAFileName, self._obsSequenceFSAFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
135
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
136 self.assertTrue(FileUtils.isRessourceExists(self._obsSequenceCSVFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
137 self.assertTrue(FileUtils.are2FilesIdentical(self._expSequenceCSVFileName, self._obsSequenceCSVFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
138
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
139 self.assertTrue(FileUtils.isRessourceExists(self._obsBatchFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
140 self.assertTrue(FileUtils.are2FilesIdentical(self._expBatchFileName, self._obsBatchFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
141
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
142 self.assertTrue(FileUtils.isRessourceExists(self._obsBatchLineFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
143 self.assertTrue(FileUtils.are2FilesIdentical(self._realExpBatchLineFileName, self._obsBatchLineFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
144
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
145 self.assertTrue(FileUtils.isRessourceExists(self._obsAlleleFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
146 self.assertTrue(FileUtils.are2FilesIdentical(self._expAlleleFileName, self._obsAlleleFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
147
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
148 self.assertTrue(FileUtils.isRessourceExists(self._obsSubSNPFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
149 self.assertTrue(FileUtils.are2FilesIdentical(self._realExpSubSNPFileName , self._obsSubSNPFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
150
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
151 def test_runOneBatch_with_errors_in_refSeq(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
152 self._writeInputFileWithSeqErrorsInRefSeq()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
153 multifasta2SNPFile = Multifasta2SNPFile("Arabidopsis thaliana", "Batch1", "methyltransferase")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
154 self.assertRaises(Exception, multifasta2SNPFile.runOneBatch, self._inFileName, self._obsSubSNPFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
155
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
156 def test_runOneBatch_with_errors_in_lineSeq(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
157 self._writeInputFileWithSeqErrorsInOneLineSeq()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
158 multifasta2SNPFile = Multifasta2SNPFile("Arabidopsis thaliana", "Batch1", "methyltransferase")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
159 self.assertRaises(Exception, multifasta2SNPFile.runOneBatch, self._inFileName, self._obsSubSNPFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
160
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
161 def test_runOneBatch_with_a_several_lineSeq(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
162 self._writeInputFileWithASeveralLineSeq()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
163 self._writeExpSubSNPFileSeveralLineSeq()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
164 self._writeExpAlleleFile()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
165 self._writeExpIndividualFile()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
166 self._writeExpSequenceFileSeveralLineSeq()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
167 self._writeExpBatchFile()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
168 self._writeExpBatchLineFile()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
169
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
170 multifasta2SNPFile = Multifasta2SNPFile("Arabidopsis thaliana", "Batch1", "methyltransferase")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
171 multifasta2SNPFile.runOneBatch(self._inFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
172
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
173 self.assertTrue(FileUtils.isRessourceExists(self._obsSubSNPFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
174 self.assertTrue(FileUtils.are2FilesIdentical(self._expSubSNPFileName, self._obsSubSNPFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
175
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
176 self.assertTrue(FileUtils.isRessourceExists(self._obsAlleleFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
177 self.assertTrue(FileUtils.are2FilesIdentical(self._expAlleleFileName, self._obsAlleleFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
178
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
179 self.assertTrue(FileUtils.isRessourceExists(self._obsIndividualFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
180 self.assertTrue(FileUtils.are2FilesIdentical(self._expIndividualFileName, self._obsIndividualFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
181
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
182 self.assertTrue(FileUtils.isRessourceExists(self._obsSequenceFSAFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
183 self.assertTrue(FileUtils.are2FilesIdentical(self._expSequenceFSAFileName, self._obsSequenceFSAFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
184
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
185 self.assertTrue(FileUtils.isRessourceExists(self._obsSequenceCSVFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
186 self.assertTrue(FileUtils.are2FilesIdentical(self._expSequenceCSVFileName, self._obsSequenceCSVFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
187
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
188 self.assertTrue(FileUtils.isRessourceExists(self._obsBatchFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
189 self.assertTrue(FileUtils.are2FilesIdentical(self._expBatchFileName, self._obsBatchFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
190
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
191 self.assertTrue(FileUtils.isRessourceExists(self._obsBatchLineFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
192 self.assertTrue(FileUtils.are2FilesIdentical(self._expBatchLineFileName, self._obsBatchLineFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
193
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
194 def test_runOneBatch_with_2_seqs_with_the_same_name(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
195 self._writeInputFileWith2SeqsWithTheSameName()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
196 batchName = "batch1"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
197 taxon = "Arabidopsis thaliana"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
198 gene = "methyltransferase"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
199 isSysExitRaised = False
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
200 multifasta2SNPFile = Multifasta2SNPFile(taxon, batchName, gene)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
201
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
202 try:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
203 multifasta2SNPFile.runOneBatch(self._inFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
204 except SystemExit:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
205 isSysExitRaised = True
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
206
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
207 self.assertTrue(isSysExitRaised)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
208
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
209 def test_runOneBatch_with_indels_and_snps(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
210 self._writeInputFileWithSnpsAndIndels()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
211 self._writeExpSubSNPFileWithSnpsAndIndels()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
212 self._writeExpAlleleFileWithSnpsAndIndels()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
213 self._writeExpIndividualFile()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
214 self._writeExpSequenceFileWithDeletion()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
215 self._writeExpBatchFile()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
216 self._writeExpBatchLineFile()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
217
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
218 batchName = "Batch1"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
219 taxon = "Arabidopsis thaliana"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
220 gene = "methyltransferase"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
221 multifasta2SNPFile = Multifasta2SNPFile(taxon, batchName, gene)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
222 multifasta2SNPFile.runOneBatch(self._inFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
223
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
224 self.assertTrue(FileUtils.isRessourceExists(self._obsIndividualFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
225 self.assertTrue(FileUtils.are2FilesIdentical(self._expIndividualFileName, self._obsIndividualFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
226
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
227 self.assertTrue(FileUtils.isRessourceExists(self._obsSequenceFSAFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
228 self.assertTrue(FileUtils.are2FilesIdentical(self._expSequenceFSAFileName, self._obsSequenceFSAFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
229
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
230 self.assertTrue(FileUtils.isRessourceExists(self._obsSequenceCSVFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
231 self.assertTrue(FileUtils.are2FilesIdentical(self._expSequenceCSVFileName, self._obsSequenceCSVFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
232
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
233 self.assertTrue(FileUtils.isRessourceExists(self._obsBatchFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
234 self.assertTrue(FileUtils.are2FilesIdentical(self._expBatchFileName, self._obsBatchFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
235
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
236 self.assertTrue(FileUtils.isRessourceExists(self._obsBatchLineFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
237 self.assertTrue(FileUtils.are2FilesIdentical(self._expBatchLineFileName, self._obsBatchLineFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
238
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
239 self.assertTrue(FileUtils.isRessourceExists(self._obsAlleleFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
240 self.assertTrue(FileUtils.are2FilesIdentical(self._expAlleleFileName, self._obsAlleleFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
241
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
242 self.assertTrue(FileUtils.isRessourceExists(self._obsSubSNPFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
243 self.assertTrue(FileUtils.are2FilesIdentical(self._expSubSNPFileName, self._obsSubSNPFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
244
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
245 def test_runOneBatchWithPotentialDooblons(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
246 self._writeInputFileBatchWithPotentialDooblons()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
247
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
248 batchName = "Batch_AU247387"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
249 taxon = "Arabidopsis thaliana"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
250 gene = "methyltransferase"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
251 multifasta2SNPFile = Multifasta2SNPFile(taxon, batchName, gene)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
252 multifasta2SNPFile.runOneBatch(self._inFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
253 self.assertTrue(FileUtils.isRessourceExists(self._obsSubSNPFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
254
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
255 expSubSNPFile = "data/ExpPotDooblonsSubSNP.csv"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
256
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
257 Utils4Test.removeOneSpecifiedColumn(expSubSNPFile, ";", 8)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
258 Utils4Test.removeOneSpecifiedColumn(self._obsSubSNPFileName, ";", 8)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
259
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
260 Utils4Test.removeOneSpecifiedColumn(expSubSNPFile + "_filtered", ";", 9)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
261 Utils4Test.removeOneSpecifiedColumn(self._obsSubSNPFileName + "_filtered", ";", 9)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
262
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
263 Utils4Test.removeOneSpecifiedColumn(expSubSNPFile + "_filtered_filtered", ";", 13)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
264 Utils4Test.removeOneSpecifiedColumn(self._obsSubSNPFileName + "_filtered_filtered", ";", 13)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
265
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
266 comparableExpSubSNPFile = expSubSNPFile + "_filtered_filtered_filtered"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
267 comparableObsSubSNPFile = self._obsSubSNPFileName + "_filtered_filtered_filtered"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
268
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
269 self.assertTrue(FileUtils.isRessourceExists(comparableExpSubSNPFile))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
270 self.assertTrue(FileUtils.isRessourceExists(comparableObsSubSNPFile))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
271 self.assertTrue(FileUtils.are2FilesIdentical(comparableExpSubSNPFile, comparableObsSubSNPFile))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
272
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
273 if(self._fileUtils.isRessourceExists(self._obsSubSNPFileName + "_filtered")):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
274 os.remove(self._obsSubSNPFileName + "_filtered")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
275 if(self._fileUtils.isRessourceExists(expSubSNPFile + "_filtered")):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
276 os.remove(expSubSNPFile + "_filtered")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
277
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
278 if(self._fileUtils.isRessourceExists(self._obsSubSNPFileName + "_filtered_filtered")):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
279 os.remove(self._obsSubSNPFileName + "_filtered_filtered")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
280 if(self._fileUtils.isRessourceExists(expSubSNPFile + "_filtered_filtered")):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
281 os.remove(expSubSNPFile + "_filtered_filtered")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
282
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
283 if self._fileUtils.isRessourceExists(comparableExpSubSNPFile):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
284 os.remove(comparableExpSubSNPFile)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
285 if self._fileUtils.isRessourceExists(comparableObsSubSNPFile):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
286 os.remove(comparableObsSubSNPFile)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
287
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
288 def test_runSeveralBatches(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
289 self._writeInputFileSeveralBatches()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
290 self._writeExpSubSNPFileSeveralBatches()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
291 self._writeExpAlleleFileSeveralBatches()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
292 self._writeExpIndividualFile()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
293 self._writeExpSequenceSeveralBatches()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
294 self._writeExpBatchFileSeveralBatches()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
295 self._writeExpBatchLineFileSeveralBatches()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
296
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
297 multifasta2SNPFile = Multifasta2SNPFile("Arabidopsis thaliana")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
298 multifasta2SNPFile.runSeveralBatches(self._inputDirSeveralBatches)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
299
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
300 self.assertTrue(FileUtils.isRessourceExists(self._inputDirSeveralBatches + "/" + self._obsAlleleFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
301 self.assertTrue(FileUtils.are2FilesIdentical(self._expAlleleFileName, self._inputDirSeveralBatches + "/" + self._obsAlleleFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
302
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
303 self.assertTrue(FileUtils.isRessourceExists(self._inputDirSeveralBatches + "/" +self._obsIndividualFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
304 self.assertTrue(FileUtils.are2FilesIdentical(self._expIndividualFileName, self._inputDirSeveralBatches + "/" + self._obsIndividualFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
305
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
306 self.assertTrue(FileUtils.isRessourceExists(self._inputDirSeveralBatches + "/" + self._obsSequenceFSAFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
307 self.assertTrue(FileUtils.are2FilesIdentical(self._expSequenceFSAFileName, self._inputDirSeveralBatches + "/" + self._obsSequenceFSAFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
308
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
309 self.assertTrue(FileUtils.isRessourceExists(self._inputDirSeveralBatches + "/" + self._obsSequenceCSVFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
310 self.assertTrue(FileUtils.are2FilesIdentical(self._expSequenceCSVFileName, self._inputDirSeveralBatches + "/" + self._obsSequenceCSVFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
311
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
312 self.assertTrue(FileUtils.isRessourceExists(self._inputDirSeveralBatches + "/" + self._obsBatchFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
313 self.assertTrue(FileUtils.are2FilesIdentical(self._expBatchFileName, self._inputDirSeveralBatches + "/" + self._obsBatchFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
314
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
315 self.assertTrue(FileUtils.isRessourceExists(self._inputDirSeveralBatches + "/" + self._obsBatchLineFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
316 self.assertTrue(FileUtils.are2FilesIdentical(self._expBatchLineFileName, self._inputDirSeveralBatches + "/" + self._obsBatchLineFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
317 self.assertTrue(FileUtils.isRessourceExists(self._inputDirSeveralBatches + "/" + self._obsSubSNPFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
318 self.assertTrue(FileUtils.are2FilesIdentical(self._expSubSNPFileName, self._inputDirSeveralBatches + "/" + self._obsSubSNPFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
319
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
320 def test_runSeveralBatches_different_lines_between_files(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
321 self._writeInputFileSeveralBatches_different_lines_between_files()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
322 self._writeExpSubSNPFileSeveralBatches_different_lines_between_files()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
323 self._writeExpAlleleFileSeveralBatches()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
324 self._writeExpIndividualFile_different_lines_between_files()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
325 self._writeExpSequenceSeveralBatches()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
326 self._writeExpBatchFileSeveralBatches()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
327 self._writeExpBatchLineFileSeveralBatches_different_lines_between_files()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
328
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
329 multifasta2SNPFile = Multifasta2SNPFile("Arabidopsis thaliana")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
330 multifasta2SNPFile.runSeveralBatches(self._inputDirSeveralBatches)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
331
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
332 self.assertTrue(FileUtils.isRessourceExists(self._inputDirSeveralBatches + "/" + self._obsAlleleFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
333 self.assertTrue(FileUtils.are2FilesIdentical(self._expAlleleFileName, self._inputDirSeveralBatches + "/" + self._obsAlleleFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
334
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
335 self.assertTrue(FileUtils.isRessourceExists(self._inputDirSeveralBatches + "/" +self._obsIndividualFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
336 self.assertTrue(FileUtils.are2FilesIdentical(self._expIndividualFileName, self._inputDirSeveralBatches + "/" + self._obsIndividualFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
337
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
338 self.assertTrue(FileUtils.isRessourceExists(self._inputDirSeveralBatches + "/" + self._obsSequenceFSAFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
339 self.assertTrue(FileUtils.are2FilesIdentical(self._expSequenceFSAFileName, self._inputDirSeveralBatches + "/" + self._obsSequenceFSAFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
340
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
341 self.assertTrue(FileUtils.isRessourceExists(self._inputDirSeveralBatches + "/" + self._obsSequenceCSVFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
342 self.assertTrue(FileUtils.are2FilesIdentical(self._expSequenceCSVFileName, self._inputDirSeveralBatches + "/" + self._obsSequenceCSVFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
343
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
344 self.assertTrue(FileUtils.isRessourceExists(self._inputDirSeveralBatches + "/" + self._obsBatchFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
345 self.assertTrue(FileUtils.are2FilesIdentical(self._expBatchFileName, self._inputDirSeveralBatches + "/" + self._obsBatchFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
346
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
347 self.assertTrue(FileUtils.isRessourceExists(self._inputDirSeveralBatches + "/" + self._obsBatchLineFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
348 self.assertTrue(FileUtils.are2FilesIdentical(self._expBatchLineFileName, self._inputDirSeveralBatches + "/" + self._obsBatchLineFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
349 self.assertTrue(FileUtils.isRessourceExists(self._inputDirSeveralBatches + "/" + self._obsSubSNPFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
350 self.assertTrue(FileUtils.are2FilesIdentical(self._expSubSNPFileName, self._inputDirSeveralBatches + "/" + self._obsSubSNPFileName))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
351
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
352 def test_runSeveralBatches_different_lines_and_same_refseq_between_files(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
353 self._writeInputFileSeveralBatches_different_lines_and_same_refseq_between_files()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
354 self._writeExpSubSNPFileSeveralBatches_different_lines_between_files()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
355 self._writeExpAlleleFileSeveralBatches()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
356 self._writeExpIndividualFile_different_lines_between_files()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
357 self._writeExpSequenceSeveralBatchesForSameRefSeq()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
358 self._writeExpBatchFileSeveralBatchesForSameRefSeq()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
359 self._writeExpBatchLineFileSeveralBatches_different_lines_between_files()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
360
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
361 multifasta2SNPFile = Multifasta2SNPFile("Arabidopsis thaliana")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
362 try:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
363 multifasta2SNPFile.runSeveralBatches(self._inputDirSeveralBatches)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
364 except Exception, e :
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
365 self.assertRaises(Exception, e)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
366
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
367 def test_detectSNPAndIndels(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
368 refBioseq = Bioseq()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
369 alignedBioseqDB = BioseqDB()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
370 batchName = "batch1"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
371 taxon = "Arabidopsis thaliana"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
372 gene = "methyltransferase"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
373 multifasta2SNPFile = Multifasta2SNPFile(taxon, batchName, gene)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
374 refBioseq.sequence = "ATTCGCGTATGCGTATGCTT"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
375 refBioseq.header = "reference"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
376
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
377 bs1 = Bioseq( "line1", "ATCCGCGTATGCGTATGATT" )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
378 bs2 = Bioseq( "line2", "ATTCGTGTATGCGTATGGTT" )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
379
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
380 alignedBioseqDB.setData( [ bs1, bs2 ] )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
381
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
382 multifasta2SNPFile._wrapper = ReferenceBioseqAndLinesBioseqDBWrapper(refBioseq, alignedBioseqDB, multifasta2SNPFile._logFile, self._inFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
383 multifasta2SNPFile._dBatchResults = {'BatchNumber': 1, 'BatchName': "Batch1", 'GeneName': "methyltransferase", 'RefSeqName': "Sequence_de_Reference"}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
384 multifasta2SNPFile.detectSNPsAndIndels(multifasta2SNPFile._wrapper)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
385
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
386 dExpAllele = {'C': 1, 'A': 2, 'T': 3, 'G': 4 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
387 lExpSNP = [{'subSNPName': batchName + "_SNP_3_line1", 'position': 3, 'lineName': 1, 'allele': 1, '5flank': "AT", '3flank': "CGCGTATGCGTATGATT", 'batchNumber': 1, 'confidenceValue' : "A", 'type' : "SNP", 'length': 1},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
388 {'subSNPName': batchName + "_SNP_3_line2", 'position': 3, 'lineName': 2, 'allele': 3, '5flank': "AT", '3flank': "CGTGTATGCGTATGGTT", 'batchNumber': 1, 'confidenceValue' : "A", 'type' : "SNP", 'length': 1},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
389 {'subSNPName': batchName + "_SNP_6_line2", 'position': 6, 'lineName': 2, 'allele': 3, '5flank': "ATTCG", '3flank': "GTATGCGTATGGTT", 'batchNumber': 1, 'confidenceValue' : "A", 'type' : "SNP", 'length': 1},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
390 {'subSNPName': batchName + "_SNP_6_line1", 'position': 6, 'lineName': 1, 'allele': 1, '5flank': "ATCCG", '3flank': "GTATGCGTATGATT",'batchNumber': 1, 'confidenceValue' : "A", 'type' : "SNP", 'length': 1},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
391 {'subSNPName': batchName + "_SNP_18_line1", 'position': 18, 'lineName': 1, 'allele': 2, '5flank': "ATCCGCGTATGCGTATG", '3flank': "TT", 'batchNumber': 1, 'confidenceValue' : "A", 'type' : "SNP", 'length': 1},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
392 {'subSNPName': batchName + "_SNP_18_line2", 'position': 18, 'lineName': 2, 'allele': 4, '5flank': "ATTCGTGTATGCGTATG", '3flank': "TT", 'batchNumber': 1, 'confidenceValue' : "A", 'type' : "SNP", 'length': 1}]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
393 lExpIndividual = [{'individualNumber': 1, 'individualName': "line1", 'scientificName': "Arabidopsis thaliana"},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
394 {'individualNumber': 2, 'individualName': "line2", 'scientificName': "Arabidopsis thaliana"},]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
395
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
396 self.assertEquals(multifasta2SNPFile._sortSubSNPResultByBatchPositionAndLineName(lExpSNP), multifasta2SNPFile._lSubSNPFileResults)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
397 self.assertEquals(dExpAllele, multifasta2SNPFile._dAlleleFileResults)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
398 self.assertEquals(lExpIndividual, multifasta2SNPFile._lIndividualFileResults)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
399
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
400 def test_detectSNPAndIndels_no_polym(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
401 refBioseq = Bioseq()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
402 alignedBioseqDB = BioseqDB()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
403 batchName = "batch1"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
404 taxon = "Arabidopsis thaliana"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
405 gene = "methyltransferase"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
406 multifasta2SNPFile = Multifasta2SNPFile(taxon, batchName, gene)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
407 refBioseq.sequence = "ATTCGCGTATGCGTATGCTT"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
408 refBioseq.header = "reference"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
409
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
410 bs1 = Bioseq( "line1", "ATTCGCGTATGCGTATGCTT" )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
411 bs2 = Bioseq( "line2", "ATTCGCGTATGCGTATGCTT" )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
412
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
413 alignedBioseqDB.setData( [ bs1, bs2 ] )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
414
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
415 instance = ReferenceBioseqAndLinesBioseqDBWrapper(refBioseq, alignedBioseqDB, multifasta2SNPFile._logFile, self._inFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
416
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
417 multifasta2SNPFile.detectSNPsAndIndels(instance)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
418
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
419 lExpSNP = []
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
420
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
421 self.assertEquals(lExpSNP, multifasta2SNPFile._lSubSNPFileResults)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
422
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
423 def test_detectSNPAndIndels_with_only_dels(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
424 refBioseq = Bioseq()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
425 alignedBioseqDB = BioseqDB()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
426 batchName = "batch1"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
427 taxon = "Arabidopsis thaliana"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
428 gene = "methyltransferase"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
429 multifasta2SNPFile = Multifasta2SNPFile(taxon, batchName, gene)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
430 refBioseq.sequence = "ATTACCGAA"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
431 refBioseq.header = "reference"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
432
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
433 bs1 = Bioseq( "line1", "A--ACCGAA" )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
434 bs2 = Bioseq( "line2", "---ACCGAA" )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
435
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
436 alignedBioseqDB.setData( [ bs1, bs2 ] )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
437
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
438 multifasta2SNPFile._wrapper = ReferenceBioseqAndLinesBioseqDBWrapper(refBioseq, alignedBioseqDB, multifasta2SNPFile._logFile, self._inFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
439 multifasta2SNPFile._dBatchResults = {'BatchNumber': 1, 'BatchName': "Batch1", 'GeneName': "methyltransferase", 'RefSeqName': "Sequence_de_Reference"}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
440 multifasta2SNPFile.detectSNPsAndIndels(multifasta2SNPFile._wrapper)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
441
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
442 dExpAllele = {'A--': 1, '---': 2}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
443 lExpSNP = [{'subSNPName': batchName + "_DEL_1_line2", 'position': 1, 'lineName': 2, 'allele': 2, '5flank': "", '3flank': "ACCGAA", 'batchNumber': 1, 'confidenceValue' : "A", 'type' : "DELETION", 'length': 3},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
444 {'subSNPName': batchName + "_DEL_1_line1", 'position': 1, 'lineName': 1, 'allele': 1, '5flank': "", '3flank': "ACCGAA", 'batchNumber': 1, 'confidenceValue' : "A", 'type' : "DELETION", 'length': 3}]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
445 lExpIndividual = [{'individualNumber': 1, 'individualName': "line1", 'scientificName': "Arabidopsis thaliana"},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
446 {'individualNumber': 2, 'individualName': "line2", 'scientificName': "Arabidopsis thaliana"}]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
447
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
448 self.assertEquals(dExpAllele, multifasta2SNPFile._dAlleleFileResults)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
449 self.assertEquals(multifasta2SNPFile._sortSubSNPResultByBatchPositionAndLineName(lExpSNP), multifasta2SNPFile._lSubSNPFileResults)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
450 self.assertEquals(lExpIndividual, multifasta2SNPFile._lIndividualFileResults)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
451
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
452 def test_detectSNPAndIndels_with_dels_and_snps(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
453 refBioseq = Bioseq()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
454 alignedBioseqDB = BioseqDB()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
455 batchName = "batch1"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
456 taxon = "Arabidopsis thaliana"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
457 gene = "methyltransferase"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
458 multifasta2SNPFile = Multifasta2SNPFile(taxon, batchName, gene)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
459 refBioseq.sequence = "ATTACCGAA"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
460 refBioseq.header = "reference"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
461
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
462 bs1 = Bioseq( "line1", "A--ACCGAA" )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
463 bs2 = Bioseq( "line2", "---ACCGAA" )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
464 bs3 = Bioseq( "line3", "ATTACCGGA" )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
465 bs4 = Bioseq( "line4", "----CCGAA" )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
466
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
467 alignedBioseqDB.setData( [ bs1, bs2, bs3, bs4 ] )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
468
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
469 multifasta2SNPFile._wrapper = ReferenceBioseqAndLinesBioseqDBWrapper(refBioseq, alignedBioseqDB, multifasta2SNPFile._logFile, self._inFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
470 multifasta2SNPFile._dBatchResults = {'BatchNumber': 1, 'BatchName': "Batch1", 'GeneName': "methyltransferase", 'RefSeqName': "Sequence_de_Reference"}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
471 multifasta2SNPFile.detectSNPsAndIndels(multifasta2SNPFile._wrapper)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
472
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
473 dExpAllele = {'G': 1, 'A--A': 2, '---A': 3, '----': 4, 'ATTA': 5, 'A': 6}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
474 lExpSNP = [{'subSNPName': batchName + "_DEL_1_line2", 'position': 1, 'lineName': 2, 'allele': 3, '5flank': "", '3flank': "CCGAA", 'batchNumber': 1, 'confidenceValue' : "A", 'type' : "DELETION", 'length': 4},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
475 {'subSNPName': batchName + "_DEL_1_line1", 'position': 1, 'lineName': 1, 'allele': 2, '5flank': "", '3flank': "CCGAA",'batchNumber': 1, 'confidenceValue' : "A", 'type' : "DELETION", 'length': 4},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
476 {'subSNPName': batchName + "_SNP_8_line3", 'position': 8, 'lineName': 3, 'allele': 1, '5flank': "ATTACCG", '3flank': "A", 'batchNumber': 1, 'confidenceValue' : "A", 'type' : "SNP", 'length': 1},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
477 {'subSNPName': batchName + "_SNP_8_line1", 'position': 8, 'lineName': 1, 'allele': 6, '5flank': "A--ACCG", '3flank': "A", 'batchNumber': 1, 'confidenceValue' : "A", 'type' : "SNP", 'length': 1},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
478 {'subSNPName': batchName + "_SNP_8_line2", 'position': 8, 'lineName': 2, 'allele': 6, '5flank': "---ACCG", '3flank': "A", 'batchNumber': 1, 'confidenceValue' : "A", 'type' : "SNP", 'length': 1},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
479 {'subSNPName': batchName + "_SNP_8_line4", 'position': 8, 'lineName': 4, 'allele': 6, '5flank': "----CCG", '3flank': "A", 'batchNumber': 1, 'confidenceValue' : "A", 'type' : "SNP", 'length': 1},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
480 {'subSNPName': batchName + "_DEL_1_line4", 'position': 1, 'lineName': 4, 'allele': 4, '5flank': "", '3flank': "CCGAA",'batchNumber': 1, 'confidenceValue' : "A", 'type' : "DELETION", 'length': 4},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
481 {'subSNPName': batchName + "_DEL_1_line3", 'position': 1, 'lineName': 3, 'allele': 5, '5flank': "", '3flank': "CCGGA",'batchNumber': 1, 'confidenceValue' : "A", 'type' : "DELETION", 'length': 4}]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
482 lExpIndividual = [{'individualNumber': 1, 'individualName': "line1", 'scientificName': "Arabidopsis thaliana"},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
483 {'individualNumber': 2, 'individualName': "line2", 'scientificName': "Arabidopsis thaliana"},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
484 {'individualNumber': 3, 'individualName': "line3", 'scientificName': "Arabidopsis thaliana"},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
485 {'individualNumber': 4, 'individualName': "line4", 'scientificName': "Arabidopsis thaliana"}]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
486
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
487 self.assertEquals(dExpAllele, multifasta2SNPFile._dAlleleFileResults)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
488 self.assertEquals(multifasta2SNPFile._sortSubSNPResultByBatchPositionAndLineName(lExpSNP), multifasta2SNPFile._lSubSNPFileResults)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
489 self.assertEquals(lExpIndividual, multifasta2SNPFile._lIndividualFileResults)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
490
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
491 def test_detectSNPAndIndels_with_only_inserts(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
492 refBioseq = Bioseq()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
493 alignedBioseqDB = BioseqDB()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
494 batchName = "batch1"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
495 taxon = "Arabidopsis thaliana"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
496 gene = "methyltransferase"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
497 multifasta2SNPFile = Multifasta2SNPFile(taxon, batchName, gene)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
498 refBioseq.sequence = "A--ACCGAA"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
499 refBioseq.header = "reference"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
500
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
501 bs1 = Bioseq( "line1", "A--ACCGAA" )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
502 bs2 = Bioseq( "line2", "AG-ACCGAA" )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
503 bs3 = Bioseq( "line3", "ATTACCGAA" )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
504
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
505 alignedBioseqDB.setData( [ bs1, bs2, bs3 ] )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
506
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
507 multifasta2SNPFile._wrapper = ReferenceBioseqAndLinesBioseqDBWrapper(refBioseq, alignedBioseqDB, multifasta2SNPFile._logFile, self._inFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
508 multifasta2SNPFile._dBatchResults = {'BatchNumber': 1, 'BatchName': "Batch1", 'GeneName': "methyltransferase", 'RefSeqName': "Sequence_de_Reference"}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
509 multifasta2SNPFile.detectSNPsAndIndels(multifasta2SNPFile._wrapper)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
510
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
511 dExpAllele = {'G-': 1, 'TT': 2, '--': 3}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
512 lExpSNP = [{'subSNPName': batchName + "_INS_1_line2", 'position': 1, 'lineName': 2, 'allele': 1, '5flank': "A", '3flank': "ACCGAA", 'batchNumber': 1, 'confidenceValue' : "A", 'type' : "INSERTION", 'length': 2},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
513 {'subSNPName': batchName + "_INS_1_line3", 'position': 1, 'lineName': 3, 'allele': 2, '5flank': "A", '3flank': "ACCGAA", 'batchNumber': 1, 'confidenceValue' : "A", 'type' : "INSERTION", 'length': 2},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
514 {'subSNPName': batchName + "_INS_1_line1", 'position': 1, 'lineName': 1, 'allele': 3, '5flank': "A", '3flank': "ACCGAA", 'batchNumber': 1, 'confidenceValue' : "A", 'type' : "INSERTION", 'length': 2}]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
515 lExpIndividual = [{'individualNumber': 1, 'individualName': "line1", 'scientificName': "Arabidopsis thaliana"},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
516 {'individualNumber': 2, 'individualName': "line2", 'scientificName': "Arabidopsis thaliana"},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
517 {'individualNumber': 3, 'individualName': "line3", 'scientificName': "Arabidopsis thaliana"}]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
518
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
519 self.assertEquals(dExpAllele, multifasta2SNPFile._dAlleleFileResults)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
520 self.assertEquals(multifasta2SNPFile._sortSubSNPResultByBatchPositionAndLineName(lExpSNP), multifasta2SNPFile._lSubSNPFileResults)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
521 self.assertEquals(lExpIndividual, multifasta2SNPFile._lIndividualFileResults)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
522
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
523 def test_detectSNPAndIndels_with_snps_and_inserts(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
524 refBioseq = Bioseq()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
525 alignedBioseqDB = BioseqDB()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
526 batchName = "batch1"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
527 taxon = "Arabidopsis thaliana"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
528 gene = "methyltransferase"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
529 multifasta2SNPFile = Multifasta2SNPFile(taxon, batchName, gene)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
530 refBioseq.sequence = "A--ACCGAA"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
531 refBioseq.header = "reference"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
532
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
533 bs1 = Bioseq( "line1", "A--ACCGAA" )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
534 bs2 = Bioseq( "line2", "AG-ACCGAA" )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
535 bs3 = Bioseq( "line3", "ATTACCGCA" )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
536
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
537 alignedBioseqDB.setData( [ bs1, bs2, bs3 ] )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
538
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
539 multifasta2SNPFile._wrapper = ReferenceBioseqAndLinesBioseqDBWrapper(refBioseq, alignedBioseqDB, multifasta2SNPFile._logFile, self._inFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
540 multifasta2SNPFile._dBatchResults = {'BatchNumber': 1, 'BatchName': "Batch1", 'GeneName': "methyltransferase", 'RefSeqName': "Sequence_de_Reference"}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
541 multifasta2SNPFile.detectSNPsAndIndels(multifasta2SNPFile._wrapper)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
542
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
543 dExpAllele = {'C': 1, 'G-': 2, 'TT': 3, '--': 4, 'A' : 5}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
544 lExpSNP = [{'subSNPName': batchName + "_SNP_6_line3", 'position': 6, 'lineName': 3, 'allele': 1, '5flank': "ATTACCG", '3flank': "A", 'batchNumber': 1, 'confidenceValue' : "A", 'type' : "SNP", 'length': 1},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
545 {'subSNPName': batchName + "_SNP_6_line1", 'position': 6, 'lineName': 1, 'allele': 5, '5flank': "A--ACCG", '3flank': "A", 'batchNumber': 1, 'confidenceValue' : "A", 'type' : "SNP", 'length': 1},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
546 {'subSNPName': batchName + "_SNP_6_line2", 'position': 6, 'lineName': 2, 'allele': 5, '5flank': "AG-ACCG", '3flank': "A", 'batchNumber': 1, 'confidenceValue' : "A", 'type' : "SNP", 'length': 1},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
547 {'subSNPName': batchName + "_INS_1_line2", 'position': 1, 'lineName': 2, 'allele': 2, '5flank': "A", '3flank': "ACCGAA", 'batchNumber': 1, 'confidenceValue' : "A", 'type' : "INSERTION", 'length': 2},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
548 {'subSNPName': batchName + "_INS_1_line3", 'position': 1, 'lineName': 3, 'allele': 3, '5flank': "A", '3flank': "ACCGCA", 'batchNumber': 1, 'confidenceValue' : "A", 'type' : "INSERTION", 'length': 2},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
549 {'subSNPName': batchName + "_INS_1_line1", 'position': 1, 'lineName': 1, 'allele': 4, '5flank': "A", '3flank': "ACCGAA", 'batchNumber': 1, 'confidenceValue' : "A", 'type' : "INSERTION", 'length': 2}]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
550 lExpIndividual = [{'individualNumber': 1, 'individualName': "line1", 'scientificName': "Arabidopsis thaliana"},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
551 {'individualNumber': 2, 'individualName': "line2", 'scientificName': "Arabidopsis thaliana"},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
552 {'individualNumber': 3, 'individualName': "line3", 'scientificName': "Arabidopsis thaliana"}]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
553
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
554 self.assertEquals(dExpAllele, multifasta2SNPFile._dAlleleFileResults)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
555 self.assertEquals(multifasta2SNPFile._sortSubSNPResultByBatchPositionAndLineName(lExpSNP), multifasta2SNPFile._lSubSNPFileResults)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
556 self.assertEquals(lExpIndividual, multifasta2SNPFile._lIndividualFileResults)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
557
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
558 def test_detectSNPAndIndels_with_snps_inserts_and_dels(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
559 refBioseq = Bioseq()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
560 alignedBioseqDB = BioseqDB()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
561 batchName = "batch1"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
562 taxon = "Arabidopsis thaliana"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
563 gene = "methyltransferase"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
564 multifasta2SNPFile = Multifasta2SNPFile(taxon, batchName, gene)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
565 refBioseq.sequence = "A--ACCGAATATAC"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
566 refBioseq.header = "reference"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
567
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
568 bs1 = Bioseq( "line1", "A--ACCGAATATAC" )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
569 bs2 = Bioseq( "line2", "AG-ACCGAAT--AC" )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
570 bs3 = Bioseq( "line3", "ATTACCGCA-----" )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
571
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
572 alignedBioseqDB.setData( [ bs1, bs2, bs3 ] )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
573
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
574 multifasta2SNPFile._wrapper = ReferenceBioseqAndLinesBioseqDBWrapper(refBioseq, alignedBioseqDB, multifasta2SNPFile._logFile, self._inFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
575 multifasta2SNPFile._dBatchResults = {'BatchNumber': 1, 'BatchName': "Batch1", 'GeneName': "methyltransferase", 'RefSeqName': "Sequence_de_Reference"}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
576 multifasta2SNPFile.detectSNPsAndIndels(multifasta2SNPFile._wrapper)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
577
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
578 dExpAllele = {'C': 1, 'G-': 2, 'T--AC': 3, 'TT': 4, '-----': 5, '--': 6, 'TATAC': 7, 'A': 8}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
579 lExpSNP = [{'subSNPName': batchName + "_SNP_6_line3", 'position': 6, 'lineName': 3, 'allele': 1, '5flank': "ATTACCG", '3flank': "A-----", 'batchNumber': 1, 'confidenceValue' : "A", 'type' : "SNP", 'length': 1},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
580 {'subSNPName': batchName + "_SNP_6_line1", 'position': 6, 'lineName': 1, 'allele': 8, '5flank': "A--ACCG", '3flank': "ATATAC", 'batchNumber': 1, 'confidenceValue' : "A", 'type' : "SNP", 'length': 1},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
581 {'subSNPName': batchName + "_SNP_6_line2", 'position': 6, 'lineName': 2, 'allele': 8, '5flank': "AG-ACCG", '3flank': "AT--AC", 'batchNumber': 1, 'confidenceValue' : "A", 'type' : "SNP", 'length': 1},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
582
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
583 {'subSNPName': batchName + "_INS_1_line2", 'position': 1, 'lineName': 2, 'allele': 2, '5flank': "A", '3flank': "ACCGAAT--AC", 'batchNumber': 1, 'confidenceValue' : "A", 'type' : "INSERTION", 'length': 2},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
584 {'subSNPName': batchName + "_INS_1_line3", 'position': 1, 'lineName': 3, 'allele': 4, '5flank': "A", '3flank': "ACCGCA-----", 'batchNumber': 1, 'confidenceValue' : "A", 'type' : "INSERTION", 'length': 2},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
585 {'subSNPName': batchName + "_INS_1_line1", 'position': 1, 'lineName': 1, 'allele': 6, '5flank': "A", '3flank': "ACCGAATATAC", 'batchNumber': 1, 'confidenceValue' : "A", 'type' : "INSERTION", 'length': 2},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
586
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
587 {'subSNPName': batchName + "_DEL_8_line2", 'position': 8, 'lineName': 2, 'allele': 3, '5flank': "AG-ACCGAA", '3flank': "", 'batchNumber': 1, 'confidenceValue' : "A", 'type' : "DELETION", 'length': 5},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
588 {'subSNPName': batchName + "_DEL_8_line3", 'position': 8, 'lineName': 3, 'allele': 5, '5flank': "ATTACCGCA", '3flank': "", 'batchNumber': 1, 'confidenceValue' : "A", 'type' : "DELETION", 'length': 5},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
589 {'subSNPName': batchName + "_DEL_8_line1", 'position': 8, 'lineName': 1, 'allele': 7, '5flank': "A--ACCGAA", '3flank': "", 'batchNumber': 1, 'confidenceValue' : "A", 'type' : "DELETION", 'length': 5}]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
590 lExpIndividual = [{'individualNumber': 1, 'individualName': "line1", 'scientificName': "Arabidopsis thaliana"},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
591 {'individualNumber': 2, 'individualName': "line2", 'scientificName': "Arabidopsis thaliana"},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
592 {'individualNumber': 3, 'individualName': "line3", 'scientificName': "Arabidopsis thaliana"}]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
593
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
594 self.assertEquals(dExpAllele, multifasta2SNPFile._dAlleleFileResults)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
595 self.assertEquals(multifasta2SNPFile._sortSubSNPResultByBatchPositionAndLineName(lExpSNP), multifasta2SNPFile._lSubSNPFileResults)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
596 self.assertEquals(lExpIndividual, multifasta2SNPFile._lIndividualFileResults)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
597
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
598 def test_createWrapperFromFile_with_upcase_and_lowcase_nucleotide(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
599 self._writeInputFileWithUpcaseAndLowcaseNucleotide()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
600 batchName = "batch1"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
601 taxon = "Arabidopsis thaliana"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
602 gene = "methyltransferase"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
603 multifasta2SNPFile = Multifasta2SNPFile(taxon, batchName, gene)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
604
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
605 expLineBioseqDB = BioseqDB()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
606 expRefBioseq = Bioseq("Sequence_de_Reference",\
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
607 "CCTAAGCCATTGCTTGGTGATTATGAAGGCAGTAGTCAAACCTCCACAATCCGCAGTAGCCAAACCTCCACAATA")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
608 iBioSeq = Bioseq("Line1","CCTTAGCCATTGCTTGGTGACTATGAAGGCAGTAGGCAAACCTCCACAATCCGCAGTAGCCAAACCTCCACAATA")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
609 expLineBioseqDB.add ( iBioSeq )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
610 iBioSeq = Bioseq("Line2","CCTAAGCCATTGCTTGGTGACTATCAAGGCAGTAGCCAAACCTCCACAATACGCAGTAGCCAAACCTCCACAATA")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
611 expLineBioseqDB.add ( iBioSeq )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
612
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
613 expBioseqDBWrapper = ReferenceBioseqAndLinesBioseqDBWrapper (expRefBioseq, expLineBioseqDB, multifasta2SNPFile._logFile, self._inFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
614
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
615 obsBioseqDBWrapper = multifasta2SNPFile.createWrapperFromFile(self._inFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
616
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
617 self.assertEquals(obsBioseqDBWrapper._iReferenceBioseq, expBioseqDBWrapper._iReferenceBioseq)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
618 self.assertEquals(obsBioseqDBWrapper._iLinesBioseqDB, expBioseqDBWrapper._iLinesBioseqDB)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
619
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
620 def test_checkHeaderAlphabet(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
621 # header ALPHABET [^a-zA-Z0-9_-:]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
622 batchName = "batch1"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
623 taxon = "Arabidopsis thaliana"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
624 gene = "methyltransferase"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
625 multifasta2SNPFile = Multifasta2SNPFile(taxon, batchName, gene)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
626 strToBeCheck="abcdefghijklmnopqrstuvwxyz0912834567_:-"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
627 self.assertTrue ( multifasta2SNPFile.checkHeaderAlphabet(strToBeCheck))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
628 strToBeCheck="ABCDEFGHIJKLMNOPQRSTUVWXYZ0912834567_:-"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
629 self.assertTrue ( multifasta2SNPFile.checkHeaderAlphabet(strToBeCheck))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
630
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
631 def test_checkHeaderAlphabet_empty_string(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
632 batchName = "batch1"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
633 taxon = "Arabidopsis thaliana"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
634 gene = "methyltransferase"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
635 multifasta2SNPFile = Multifasta2SNPFile(taxon, batchName, gene)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
636 strToBeCheck=""
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
637 self.assertFalse ( multifasta2SNPFile.checkHeaderAlphabet(strToBeCheck))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
638
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
639 def test_checkHeaderAlphabet_space(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
640 batchName = "batch1"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
641 taxon = "Arabidopsis thaliana"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
642 gene = "methyltransferase"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
643 multifasta2SNPFile = Multifasta2SNPFile(taxon, batchName, gene)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
644 strToBeCheck=" "
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
645 self.assertFalse ( multifasta2SNPFile.checkHeaderAlphabet(strToBeCheck))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
646
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
647 def test_checkHeaderAlphabet_non_aphabetical(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
648 batchName = "batch1"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
649 taxon = "Arabidopsis thaliana"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
650 gene = "methyltransferase"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
651 multifasta2SNPFile = Multifasta2SNPFile(taxon, batchName, gene)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
652 strToBeCheck="}"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
653 self.assertFalse ( multifasta2SNPFile.checkHeaderAlphabet(strToBeCheck))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
654
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
655 def test_isDNA_bases( self ):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
656 batchName = "batch1"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
657 taxon = "Arabidopsis thaliana"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
658 gene = "methyltransferase"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
659 multifasta2SNPFile = Multifasta2SNPFile(taxon, batchName, gene)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
660 strToBeCheck="TGTGGCTTCTAGTTGATCAGTTTATGATCACAATGATTTCACGTAGGTGTCTCGTGGCTCCGACTAATCAACAATATAATGCGAGTAGAGCTTGA"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
661 self.assertTrue ( multifasta2SNPFile.isDNA_bases(strToBeCheck))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
662
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
663 def test_isDNA_bases_non_DNA_letter( self ):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
664 batchName = "batch1"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
665 taxon = "Arabidopsis thaliana"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
666 gene = "methyltransferase"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
667 multifasta2SNPFile = Multifasta2SNPFile(taxon, batchName, gene)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
668 strToBeCheck="XTAGTTGATCA"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
669 self.assertFalse ( multifasta2SNPFile.isDNA_bases(strToBeCheck))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
670
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
671 def test_isDNA_bases_carriage_return( self ):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
672 batchName = "batch1"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
673 taxon = "Arabidopsis thaliana"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
674 gene = "methyltransferase"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
675 multifasta2SNPFile = Multifasta2SNPFile(taxon, batchName, gene)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
676 strToBeCheck="TA\nGTTGATCA"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
677 self.assertFalse ( multifasta2SNPFile.isDNA_bases(strToBeCheck))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
678
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
679 def test_isDNA_bases_empty_string( self ):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
680 batchName = "batch1"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
681 taxon = "Arabidopsis thaliana"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
682 gene = "methyltransferase"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
683 multifasta2SNPFile = Multifasta2SNPFile(taxon, batchName, gene)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
684 strToBeCheck=""
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
685 self.assertFalse ( multifasta2SNPFile.isDNA_bases(strToBeCheck))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
686
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
687 def test_isDNA_bases_space( self ):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
688 batchName = "batch1"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
689 taxon = "Arabidopsis thaliana"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
690 gene = "methyltransferase"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
691 multifasta2SNPFile = Multifasta2SNPFile(taxon, batchName, gene)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
692 strToBeCheck=" "
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
693 self.assertFalse ( multifasta2SNPFile.isDNA_bases(strToBeCheck))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
694
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
695 def test_isDNA_bases_IUPAC_letter_but_non_DNA_bases( self ):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
696 batchName = "batch1"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
697 taxon = "Arabidopsis thaliana"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
698 gene = "methyltransferase"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
699 multifasta2SNPFile = Multifasta2SNPFile(taxon, batchName, gene)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
700 strToBeCheck="UMWSB"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
701 self.assertFalse ( multifasta2SNPFile.isDNA_bases(strToBeCheck))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
702
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
703 def test_getLineAsAHeader (self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
704 lineToBeCheck=">test on good header"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
705 batchName = "batch1"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
706 expHeader = "test_on_good_header"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
707 taxon = "Arabidopsis thaliana"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
708 gene = "methyltransferase"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
709 multifasta2SNPFile = Multifasta2SNPFile(taxon, batchName, gene)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
710 obsHeader = multifasta2SNPFile.getLineAsAHeader(lineToBeCheck)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
711 self.assertEqual(obsHeader,expHeader)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
712
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
713 def test_getLineAsAHeader_warning_bad_header_tag_omitted(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
714
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
715 lineToBeCheck="test on bad header with tag omitted"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
716 batchName = "batch1"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
717 taxon = "Arabidopsis thaliana"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
718 gene = "methyltransferase"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
719 multifasta2SNPFile = Multifasta2SNPFile(taxon, batchName, gene)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
720 try :
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
721 expHeader = multifasta2SNPFile.getLineAsAHeader( lineToBeCheck )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
722 except Exception, e :
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
723 self.assertRaises(Exception, e , self._inFileName, self._obsSubSNPFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
724
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
725 def test_getLineAsAHeader_warning_repeated_blanks_removed(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
726
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
727 lineToBeCheck =">test on header \twith warning"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
728 expHeader = "test_on_header_with_warning"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
729 batchName = "batch1"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
730 taxon = "Arabidopsis thaliana"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
731 gene = "methyltransferase"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
732 multifasta2SNPFile = Multifasta2SNPFile(taxon, batchName, gene)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
733 obsHeader = multifasta2SNPFile.getLineAsAHeader( lineToBeCheck )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
734 self.assertEquals( obsHeader, expHeader)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
735 self.assertRaises(Exception, multifasta2SNPFile.getLineAsAHeader( lineToBeCheck ) , self._inFileName, self._obsSubSNPFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
736
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
737 def test_getLineAsAHeader_fatal_error_bad_header(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
738 lineToBeCheck=">test\on bad header with fatal error"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
739
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
740 batchName = "batch1"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
741 taxon = "Arabidopsis thaliana"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
742 gene = "methyltransferase"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
743 multifasta2SNPFile = Multifasta2SNPFile(taxon, batchName, gene)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
744 try :
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
745 expHeader = multifasta2SNPFile.getLineAsAHeader( lineToBeCheck )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
746 except Exception, e :
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
747 self.assertRaises(Exception, e , self._inFileName, self._obsSubSNPFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
748
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
749 def test_isHeaderInRefSeqList(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
750 header = "line1"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
751 bs1 = Bioseq( "line1", "A--ACCGAATATAC" )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
752 bs2 = Bioseq( "line2", "AG-ACCGAAT--AC" )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
753 bs3 = Bioseq( "line3", "ATTACCGCA-----" )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
754
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
755 batchName = "batch1"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
756 taxon = "Arabidopsis thaliana"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
757 gene = "methyltransferase"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
758
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
759 multifasta2SNPFile = Multifasta2SNPFile(taxon, batchName, gene)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
760 multifasta2SNPFile._lRefSequences = [bs1, bs2, bs3]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
761 try:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
762 isHeader = multifasta2SNPFile.isHeaderInRefSeqList(header)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
763 except Exception, e :
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
764 self.assertRaises(Exception, e)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
765
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
766 def test_completeAlleleSetWithCurrentAllele_one_allele_added(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
767 dAlleleSetInInput = {"A" : 1,
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
768 "T" : 2,
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
769 "G" : 3}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
770 alleleToAdd = "C"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
771 dAlleleExpSet = {"A" : 1,
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
772 "T" : 2,
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
773 "G" : 3,
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
774 "C" : 4}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
775 batchName = "batch1"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
776 taxon = "Arabidopsis thaliana"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
777 gene = "methyltransferase"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
778 multifasta2SNPFile = Multifasta2SNPFile(taxon, batchName, gene)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
779 dAlleleObsSet = multifasta2SNPFile._completeAlleleSetWithCurrentAllele(dAlleleSetInInput, alleleToAdd)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
780 self.assertEquals(dAlleleObsSet, dAlleleExpSet)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
781
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
782 def test_completeAlleleSetWithCurrentAllele_no_allele_added(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
783 dAlleleSetInInput = {"A" : 1,
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
784 "T" : 2,
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
785 "G" : 3}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
786 alleleToAdd = "T"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
787 dAlleleExpSet = {"A" : 1,
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
788 "T" : 2,
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
789 "G" : 3}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
790 batchName = "batch1"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
791 taxon = "Arabidopsis thaliana"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
792 gene = "methyltransferase"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
793 multifasta2SNPFile = Multifasta2SNPFile(taxon, batchName, gene)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
794 dAlleleObsSet = multifasta2SNPFile._completeAlleleSetWithCurrentAllele(dAlleleSetInInput, alleleToAdd)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
795 self.assertEquals(dAlleleObsSet, dAlleleExpSet)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
796
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
797 def test_completeAlleleSetWithCurrentAllele_with_an_empty_allele_set(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
798 dAlleleSetInInput = {}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
799 alleleToAdd = "T"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
800 dAlleleExpSet = {"T" : 1}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
801 batchName = "batch1"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
802 taxon = "Arabidopsis thaliana"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
803 gene = "methyltransferase"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
804 multifasta2SNPFile = Multifasta2SNPFile(taxon, batchName, gene)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
805 dAlleleObsSet = multifasta2SNPFile._completeAlleleSetWithCurrentAllele(dAlleleSetInInput, alleleToAdd)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
806 self.assertEquals(dAlleleObsSet, dAlleleExpSet)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
807
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
808 def test_completeBatchLineListWithCurrentIndividual(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
809 #TODO: this test only pass with a batchNumber of 1
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
810 iCurrentBatchNumber = 1
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
811 lBatchLineResults = [{'IndividualNumber': "1", 'BatchNumber': iCurrentBatchNumber},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
812 {'IndividualNumber': "2", 'BatchNumber': iCurrentBatchNumber}]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
813 lIndividualResults = [{'individualNumber': 1, 'individualName': "Individual1", 'scientificName': "Arabidopsis thaliana"},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
814 {'individualNumber': 2, 'individualName': "Individual2", 'scientificName': "Arabidopsis thaliana"},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
815 {'individualNumber': 3, 'individualName': "Individual3", 'scientificName': "Arabidopsis thaliana"}]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
816 lExpBatchLineResults = [{'IndividualNumber': "1", 'BatchNumber': iCurrentBatchNumber},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
817 {'IndividualNumber': "2", 'BatchNumber': iCurrentBatchNumber},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
818 {'IndividualNumber': "3", 'BatchNumber': iCurrentBatchNumber}]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
819 lineName2Add = "Individual3"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
820 batchName = "batch1"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
821 taxon = "Arabidopsis thaliana"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
822 gene = "methyltransferase"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
823 multifasta2SNPFile = Multifasta2SNPFile(taxon, batchName, gene)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
824 lBatchLineResults = multifasta2SNPFile._completeBatchLineListWithCurrentIndividual(lBatchLineResults, lIndividualResults, lineName2Add)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
825 self.assertEquals(lBatchLineResults, lExpBatchLineResults)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
826
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
827 def test_completeBatchLineListWithCurrentIndividual_no_entries_in_batchline_results_in_input(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
828 lBatchLineResults = []
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
829 lIndividualResults = [{'individualNumber': 1, 'individualName': "Individual1", 'scientificName': "Arabidopsis thaliana"},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
830 {'individualNumber': 2, 'individualName': "Individual2", 'scientificName': "Arabidopsis thaliana"},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
831 {'individualNumber': 3, 'individualName': "Individual3", 'scientificName': "Arabidopsis thaliana"}]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
832 lExpBatchLineResults = [{'IndividualNumber': "2", 'BatchNumber': 1}]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
833 lineName2Add = "Individual2"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
834 batchName = "batch1"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
835 taxon = "Arabidopsis thaliana"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
836 gene = "methyltransferase"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
837 multifasta2SNPFile = Multifasta2SNPFile(taxon, batchName, gene)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
838 lBatchLineResults = multifasta2SNPFile._completeBatchLineListWithCurrentIndividual(lBatchLineResults, lIndividualResults, lineName2Add)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
839 self.assertEquals(lBatchLineResults, lExpBatchLineResults)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
840
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
841 def test_completeBatchLineListWithCurrentIndividual_no_individual_in_individualList(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
842 lBatchLineResults = [{'IndividualNumber': "1", 'BatchNumber': 1},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
843 {'IndividualNumber': "2", 'BatchNumber': 1}]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
844 lIndividualResults = []
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
845
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
846 lineName2Add = "Individual3"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
847 batchName = "batch1"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
848 taxon = "Arabidopsis thaliana"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
849 gene = "methyltransferase"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
850 multifasta2SNPFile = Multifasta2SNPFile(taxon, batchName, gene)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
851 try:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
852 lBatchLineResults = multifasta2SNPFile._completeBatchLineListWithCurrentIndividual(lBatchLineResults, lIndividualResults, lineName2Add)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
853 except Exception, e :
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
854 self.assertRaises(Exception, e)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
855
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
856 def test_completeBatchLineListWithCurrentIndividual_individual_added_has_no_individual_number(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
857 lBatchLineResults = [{'IndividualNumber': "1", 'BatchNumber': "1"},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
858 {'IndividualNumber': "2", 'BatchNumber': "1"}]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
859 lIndividualResults = [{'individualNumber': 1, 'individualName': "Individual1", 'scientificName': "Arabidopsis thaliana"},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
860 {'individualNumber': 2, 'individualName': "Individual2", 'scientificName': "Arabidopsis thaliana"},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
861 {'individualName': "Individual3", 'scientificName': "Arabidopsis thaliana"}]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
862
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
863 lineName2Add = "Individual3"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
864 batchName = "batch1"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
865 taxon = "Arabidopsis thaliana"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
866 gene = "methyltransferase"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
867 multifasta2SNPFile = Multifasta2SNPFile(taxon, batchName, gene)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
868 try:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
869 lBatchLineResults = multifasta2SNPFile._completeBatchLineListWithCurrentIndividual(lBatchLineResults, lIndividualResults, lineName2Add)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
870 except Exception, e :
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
871 self.assertRaises(Exception, e)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
872
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
873 def test_completeBatchLineListWithCurrentIndividual_individual_not_present_in_individualList(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
874 lBatchLineResults = [{'IndividualNumber': "1", 'BatchNumber': "1"},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
875 {'IndividualNumber': "2", 'BatchNumber': "1"}]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
876 lIndividualResults = [{'individualNumber': 1, 'individualName': "Individual1", 'scientificName': "Arabidopsis thaliana"},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
877 {'individualNumber': 2, 'individualName': "Individual2", 'scientificName': "Arabidopsis thaliana"},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
878 {'individualNumber': 3, 'individualName': "Individual3", 'scientificName': "Arabidopsis thaliana"}]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
879
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
880 lineName2Add = "Michael Corleone"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
881 batchName = "batch1"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
882 taxon = "Arabidopsis thaliana"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
883 gene = "methyltransferase"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
884 multifasta2SNPFile = Multifasta2SNPFile(taxon, batchName, gene)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
885 try:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
886 lBatchLineResults = multifasta2SNPFile._completeBatchLineListWithCurrentIndividual(lBatchLineResults, lIndividualResults, lineName2Add)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
887 except Exception, e :
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
888 self.assertRaises(Exception, e)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
889
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
890 def test_findASubSNPInAListWithHisName(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
891 lSubSNPList = [{'subSNPName': "SubSNP_batch1_1_line2", 'position': 1, 'lineName': 2, 'allele': 2, 'batchNumber': 1, 'confidenceValue' : "A", 'type' : "DELETION"},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
892 {'subSNPName': "SubSNP_batch1_2_line1", 'position': 1, 'lineName': 1, 'allele': 1, 'batchNumber': 1, 'confidenceValue' : "A", 'type' : "DELETION"},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
893 {'subSNPName': "SubSNP_batch1_6_line1", 'position': 6, 'lineName': 1, 'allele': 3, 'batchNumber': 1, 'confidenceValue' : "A", 'type' : "SNP"}]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
894 name = "SubSNP_batch1_2_line1"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
895
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
896 dExpSubSNP = {'subSNPName': "SubSNP_batch1_2_line1", 'position': 1, 'lineName': 1, 'allele': 1, 'batchNumber': 1, 'confidenceValue' : "A", 'type' : "DELETION"}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
897 expIndice = 1
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
898
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
899 multifasta2SNPFile = Multifasta2SNPFile("batch1", "gene1", "mouse")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
900
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
901 dObsSubSNP, obsIndice = multifasta2SNPFile.findASubSNPInAListWithHisName(name, lSubSNPList)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
902
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
903 self.assertEquals(expIndice, obsIndice)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
904 self.assertEquals(dExpSubSNP, dObsSubSNP)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
905
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
906 def test_findASubSNPInAListWithHisName_SubSNP_not_found(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
907 lSubSNPList = [{'subSNPName': "SubSNP_batch1_1_line2", 'position': 1, 'lineName': 2, 'allele': 2, 'batchNumber': 1, 'confidenceValue' : "A", 'type' : "DELETION"},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
908 {'subSNPName': "SubSNP_batch1_2_line1", 'position': 1, 'lineName': 1, 'allele': 1, 'batchNumber': 1, 'confidenceValue' : "A", 'type' : "DELETION"},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
909 {'subSNPName': "SubSNP_batch1_6_line1", 'position': 6, 'lineName': 1, 'allele': 3, 'batchNumber': 1, 'confidenceValue' : "A", 'type' : "SNP"}]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
910 name = "SubSNP_fake"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
911
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
912 multifasta2SNPFile = Multifasta2SNPFile("batch1", "gene1", "mouse")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
913
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
914 try:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
915 dObsSubSNP, obsIndice = multifasta2SNPFile.findASubSNPInAListWithHisName(name, lSubSNPList)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
916 except Exception, e :
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
917 self.assertRaises(Exception, e)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
918
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
919 def test_clusteriseIndels(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
920 multifasta2SNPFile = Multifasta2SNPFile("batch1", "gene1", "mouse")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
921 lObsIndelsList = [{'name' : "indel1", 'start': 1, 'end': 6},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
922 {'name' : "indel2", 'start': 12, 'end': 15},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
923 {'name' : "indel3",'start': 5, 'end': 10}]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
924 dIndel = {'start': 1, 'end': 6}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
925
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
926 lObsIndelsList = multifasta2SNPFile.clusteriseIndels(dIndel, lObsIndelsList)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
927 lexpIndelsList = [{'name' : "indel1", 'start': 1, 'end': 10},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
928 {'name' : "indel2", 'start': 12, 'end': 15},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
929 {'name' : "indel3", 'start': 1, 'end': 10}]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
930
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
931 self.assertEquals(lexpIndelsList, lObsIndelsList)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
932
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
933 def test_clusteriseIndels_no_overlap(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
934 multifasta2SNPFile = Multifasta2SNPFile("batch1", "gene1", "mouse")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
935 lObsIndelsList = [{'name' : "indel1", 'start': 1, 'end': 6},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
936 {'name' : "indel2", 'start': 12, 'end': 15},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
937 {'name' : "indel3",'start': 25, 'end': 30}]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
938 dIndel = {'start': 1, 'end': 6}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
939
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
940 lObsIndelsList = multifasta2SNPFile.clusteriseIndels(dIndel, lObsIndelsList)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
941 lexpIndelsList = [{'name' : "indel1", 'start': 1, 'end': 6},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
942 {'name' : "indel2", 'start': 12, 'end': 15},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
943 {'name' : "indel3", 'start': 25, 'end': 30}]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
944
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
945 self.assertEquals(lexpIndelsList, lObsIndelsList)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
946
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
947 def test_clusteriseIndels_many_overlaps_complicated(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
948 multifasta2SNPFile = Multifasta2SNPFile("batch1", "gene1", "mouse")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
949 lObsIndelsList = [{'name' : "indel1", 'start': 1, 'end': 6},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
950 {'name' : "indel2", 'start': 12, 'end': 15},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
951 {'name' : "indel3",'start': 5, 'end': 10},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
952 {'name' : "indel4",'start': 9, 'end': 40}]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
953 dIndel = {'start': 5, 'end': 10}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
954
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
955 lObsIndelsList = multifasta2SNPFile.clusteriseIndels(dIndel, lObsIndelsList)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
956 lexpIndelsList = [{'name' : "indel1", 'start': 1, 'end': 40},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
957 {'name' : "indel2", 'start': 1, 'end': 40},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
958 {'name' : "indel3", 'start': 1, 'end': 40},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
959 {'name' : "indel4",'start': 1, 'end': 40}]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
960
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
961 self.assertEquals(lexpIndelsList, lObsIndelsList)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
962
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
963 def test_updateBoundsForAnIndelInAnIndelList(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
964 lIndelsList = [{'name' : "indel1", 'start': 1, 'end': 6},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
965 {'name' : "indel2", 'start': 12, 'end': 15},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
966 {'name' : "indel3",'start': 5, 'end': 10},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
967 {'name' : "indel4",'start': 9, 'end': 40}]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
968 dIndelWithNewBounds = {'name': "indel2", 'start': 7, 'end': 19}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
969 multifasta2SNPFile = Multifasta2SNPFile("batch1", "gene1", "mouse")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
970 lObsNewIndelsList = multifasta2SNPFile.updateBoundsForAnIndelInAnIndelList(lIndelsList, dIndelWithNewBounds)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
971 lExpNewIndelsList = [{'name' : "indel1", 'start': 1, 'end': 6},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
972 {'name' : "indel2", 'start': 7, 'end': 19},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
973 {'name' : "indel3",'start': 5, 'end': 10},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
974 {'name' : "indel4",'start': 9, 'end': 40}]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
975 self.assertEquals(lExpNewIndelsList, lObsNewIndelsList)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
976
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
977 def test_updateBoundsForAnIndelInAnIndelList_no_update_to_do(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
978 lIndelsList = [{'name' : "indel1", 'start': 1, 'end': 6},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
979 {'name' : "indel2", 'start': 12, 'end': 15},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
980 {'name' : "indel3",'start': 5, 'end': 10},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
981 {'name' : "indel4",'start': 9, 'end': 40}]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
982 dIndelWithNewBounds = {'name': "indel2", 'start': 12, 'end': 15}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
983 multifasta2SNPFile = Multifasta2SNPFile("batch1", "gene1", "mouse")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
984 lObsNewIndelsList = multifasta2SNPFile.updateBoundsForAnIndelInAnIndelList(lIndelsList, dIndelWithNewBounds)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
985 lExpNewIndelsList = [{'name' : "indel1", 'start': 1, 'end': 6},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
986 {'name' : "indel2", 'start': 12, 'end': 15},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
987 {'name' : "indel3",'start': 5, 'end': 10},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
988 {'name' : "indel4",'start': 9, 'end': 40}]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
989 self.assertEquals(lExpNewIndelsList, lObsNewIndelsList)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
990
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
991 def test_updateBoundsForAnIndelInAnIndelList_indel_2_update_does_not_exist(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
992 lIndelsList = [{'name' : "indel1", 'start': 1, 'end': 6},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
993 {'name' : "indel2", 'start': 12, 'end': 15},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
994 {'name' : "indel3",'start': 5, 'end': 10},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
995 {'name' : "indel4",'start': 9, 'end': 40}]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
996 dIndelWithNewBounds = {'name': "DeNiro", 'start': 12, 'end': 15}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
997 multifasta2SNPFile = Multifasta2SNPFile("batch1", "gene1", "mouse")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
998 try:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
999 lObsNewIndelsList = multifasta2SNPFile.updateBoundsForAnIndelInAnIndelList(lIndelsList, dIndelWithNewBounds)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1000 except Exception, e :
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1001 self.assertRaises(Exception, e)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1002
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1003 def test_mergeBoundsFor2Indels(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1004 multifasta2SNPFile = Multifasta2SNPFile("batch1", "gene1", "mouse")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1005 dIndel1 = {'start': 1, 'end': 4}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1006 dIndel2 = {'start': 2, 'end': 15}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1007 dIndel1, dIndel2 = multifasta2SNPFile.mergeBoundsForTwoOverlappingIndels(dIndel1, dIndel2)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1008 dExpIndel1 = {'start': 1, 'end': 15}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1009 dExpIndel2 = {'start': 1, 'end': 15}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1010 self.assertEquals(dExpIndel1, dIndel1)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1011 self.assertEquals(dExpIndel2, dIndel2)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1012
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1013 def test_mergeBoundsFor2Indels_no_overlap(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1014 multifasta2SNPFile = Multifasta2SNPFile("batch1", "gene1", "mouse")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1015 dIndel1 = {'start': 1, 'end': 4}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1016 dIndel2 = {'start': 5, 'end': 15}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1017 dIndel1, dIndel2 = multifasta2SNPFile.mergeBoundsForTwoOverlappingIndels(dIndel1, dIndel2)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1018 dExpIndel1 = {'start': 1, 'end': 4}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1019 dExpIndel2 = {'start': 5, 'end': 15}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1020 self.assertEquals(dExpIndel1, dIndel1)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1021 self.assertEquals(dExpIndel2, dIndel2)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1022
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1023 def test_getUngappedPositionInRefSeq(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1024 multifasta2SNPFile = Multifasta2SNPFile("batch1", "gene1", "mouse")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1025 refBioseq = Bioseq()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1026 alignedBioseqDB = BioseqDB()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1027 refBioseq.sequence = "A--TTACC-GAA"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1028 refBioseq.header = "reference"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1029 bs1 = Bioseq( "line1", "AACTTTCCAGAA" )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1030 bs2 = Bioseq( "line2", "AACTTACC-GAA" )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1031
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1032 alignedBioseqDB.setData( [ bs1, bs2 ] )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1033
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1034 multifasta2SNPFile._wrapper = ReferenceBioseqAndLinesBioseqDBWrapper(refBioseq, alignedBioseqDB, multifasta2SNPFile._logFile, self._inFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1035
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1036 expUngappedPositionFor1 = 1
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1037 obsUngappedPositionFor1 = multifasta2SNPFile.getUngappedPositionInRefSeq(1)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1038 expUngappedPositionFor5 = 3
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1039 obsUngappedPositionFor5 = multifasta2SNPFile.getUngappedPositionInRefSeq(5)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1040 expUngappedPositionFor10 = 7
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1041 obsUngappedPositionFor10 = multifasta2SNPFile.getUngappedPositionInRefSeq(10)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1042
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1043 self.assertEquals(expUngappedPositionFor1, obsUngappedPositionFor1)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1044 self.assertEquals(expUngappedPositionFor5, obsUngappedPositionFor5)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1045 self.assertEquals(expUngappedPositionFor10, obsUngappedPositionFor10)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1046
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1047 def test_getUngappedPositionInRefSeq_no_gap(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1048 multifasta2SNPFile = Multifasta2SNPFile("batch1", "gene1", "mouse")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1049 refBioseq = Bioseq()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1050 alignedBioseqDB = BioseqDB()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1051 refBioseq.sequence = "AACTTACCAGAA"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1052 refBioseq.header = "reference"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1053 bs1 = Bioseq( "line1", "AACTTTCCAGAA" )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1054 bs2 = Bioseq( "line2", "AACTTACC-GAA" )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1055
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1056 alignedBioseqDB.setData( [ bs1, bs2 ] )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1057
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1058 multifasta2SNPFile._wrapper = ReferenceBioseqAndLinesBioseqDBWrapper(refBioseq, alignedBioseqDB, multifasta2SNPFile._logFile, self._inFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1059
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1060 expUngappedPositionFor1 = 1
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1061 obsUngappedPositionFor1 = multifasta2SNPFile.getUngappedPositionInRefSeq(1)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1062 expUngappedPositionFor5 = 5
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1063 obsUngappedPositionFor5 = multifasta2SNPFile.getUngappedPositionInRefSeq(5)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1064 expUngappedPositionFor10 = 10
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1065 obsUngappedPositionFor10 = multifasta2SNPFile.getUngappedPositionInRefSeq(10)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1066
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1067 self.assertEquals(expUngappedPositionFor1, obsUngappedPositionFor1)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1068 self.assertEquals(expUngappedPositionFor5, obsUngappedPositionFor5)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1069 self.assertEquals(expUngappedPositionFor10, obsUngappedPositionFor10)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1070
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1071 def test_checkAllSeq_sequences_with_different_sizes_one_seq_longer(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1072 multifasta2SNPFile = Multifasta2SNPFile("batch1", "gene1", "mouse")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1073 refBioseq = Bioseq()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1074 alignedBioseqDB = BioseqDB()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1075 refBioseq.sequence = "AACTTACCAGAA"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1076 refBioseq.header = "reference"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1077 bs1 = Bioseq( "line1", "AACTTTCCAGAA" )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1078 bs2 = Bioseq( "line2", "AACTTACC-GAATTTC" )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1079
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1080 alignedBioseqDB.setData( [ bs1, bs2 ] )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1081
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1082 try:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1083 multifasta2SNPFile._wrapper = ReferenceBioseqAndLinesBioseqDBWrapper(refBioseq, alignedBioseqDB, multifasta2SNPFile._logFile, self._inFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1084 except Exception, e :
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1085 self.assertRaises(Exception, e)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1086 obsMsg = e.message
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1087 expMsg = "File: " + self._inFileName + ", problem with the sequence " + bs2.header + ": its length is different from the reference seq! All the sequences must have the same length.\n"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1088 expMsg += "refseq length: " + str(len(refBioseq.sequence)) + "\n"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1089 expMsg += "seq length: " + str(len(bs2.sequence)) + "\n"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1090 self.assertEquals(expMsg, obsMsg)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1091
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1092 def test_checkAllSeq_sequences_with_different_sizes_one_seq_shorter(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1093 multifasta2SNPFile = Multifasta2SNPFile("batch1", "gene1", "mouse")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1094 refBioseq = Bioseq()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1095 alignedBioseqDB = BioseqDB()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1096 refBioseq.sequence = "AACTTACCAGAA"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1097 refBioseq.header = "reference"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1098 bs1 = Bioseq( "line1", "AACTTTCCAGAA" )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1099 bs2 = Bioseq( "line2", "AACTTACC" )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1100
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1101 alignedBioseqDB.setData( [ bs1, bs2 ] )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1102
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1103 try:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1104 multifasta2SNPFile._wrapper = ReferenceBioseqAndLinesBioseqDBWrapper(refBioseq, alignedBioseqDB, multifasta2SNPFile._logFile, self._inFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1105 except Exception, e :
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1106 self.assertRaises(Exception, e)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1107 obsMsg = e.message
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1108 expMsg = "File: " + self._inFileName + ", problem with the sequence " + bs2.header + ": its length is different from the reference seq! All the sequences must have the same length.\n"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1109 expMsg += "refseq length: " + str(len(refBioseq.sequence)) + "\n"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1110 expMsg += "seq length: " + str(len(bs2.sequence)) + "\n"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1111 self.assertEquals(expMsg, obsMsg)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1112
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1113
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1114 def test_getFlanksOfASubSNP(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1115 refBioseq = Bioseq()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1116 alignedBioseqDB = BioseqDB()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1117 refBioseq.sequence = "AACTTACCAGAA"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1118 refBioseq.header = "reference"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1119 bs1 = Bioseq( "line1", "AACTTTCCAGAA" )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1120 bs2 = Bioseq( "line2", "AACTTACC-GAA" )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1121 alignedBioseqDB.setData( [ bs1, bs2 ] )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1122 multifasta2SNPFile = Multifasta2SNPFile("batch1", "gene1", "mouse")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1123 multifasta2SNPFile._wrapper = ReferenceBioseqAndLinesBioseqDBWrapper(refBioseq, alignedBioseqDB, multifasta2SNPFile._logFile, self._inFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1124 subsnpPosition = 3
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1125 polymLength = 3
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1126 lineName = "line1"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1127 exp5flank = "AA"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1128 exp3flank = "TCCAGAA"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1129
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1130 obs5flank, obs3flank = multifasta2SNPFile.getFlanksOfASubSNP(lineName, subsnpPosition, polymLength, 7)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1131 self.assertEquals(exp5flank, obs5flank)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1132 self.assertEquals(exp3flank, obs3flank)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1133
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1134 def test_getFlanksOfASubSNP_flank_truncated(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1135 refBioseq = Bioseq()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1136 alignedBioseqDB = BioseqDB()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1137 refBioseq.sequence = "AACTTACCAGAA"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1138 refBioseq.header = "reference"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1139 bs1 = Bioseq( "line1", "AACTTTCCAGAA" )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1140 bs2 = Bioseq( "line2", "AACTTACC-GAA" )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1141 alignedBioseqDB.setData( [ bs1, bs2 ] )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1142 multifasta2SNPFile = Multifasta2SNPFile("batch1", "gene1", "mouse")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1143 multifasta2SNPFile._wrapper = ReferenceBioseqAndLinesBioseqDBWrapper(refBioseq, alignedBioseqDB, multifasta2SNPFile._logFile, self._inFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1144 subsnpPosition = 3
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1145 polymLength = 3
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1146 lineName = "line1"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1147 exp5flank = "AA"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1148 exp3flank = "TCCAGAA"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1149
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1150 obs5flank, obs3flank = multifasta2SNPFile.getFlanksOfASubSNP(lineName, subsnpPosition, polymLength, 500)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1151 self.assertEquals(exp5flank, obs5flank)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1152 self.assertEquals(exp3flank, obs3flank)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1153
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1154 def test_getFlanksOfASubSNP_empty_seq(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1155 refBioseq = Bioseq()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1156 alignedBioseqDB = BioseqDB()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1157 refBioseq.sequence = ""
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1158 refBioseq.header = "reference"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1159 bs1 = Bioseq( "line1", "" )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1160 bs2 = Bioseq( "line2", "" )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1161 alignedBioseqDB.setData( [ bs1, bs2 ] )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1162 multifasta2SNPFile = Multifasta2SNPFile("batch1", "gene1", "mouse")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1163 multifasta2SNPFile._wrapper = ReferenceBioseqAndLinesBioseqDBWrapper(refBioseq, alignedBioseqDB, multifasta2SNPFile._logFile, self._inFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1164 subsnpPosition = 3
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1165 polymLength = 3
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1166 lineName = "line1"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1167 exp5flank = ""
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1168 exp3flank = ""
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1169
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1170 obs5flank, obs3flank = multifasta2SNPFile.getFlanksOfASubSNP(lineName, subsnpPosition, polymLength, 500)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1171 self.assertEquals(exp5flank, obs5flank)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1172 self.assertEquals(exp3flank, obs3flank)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1173
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1174 def test_getFlanksOfASubSNP_flank_of_first_base(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1175 refBioseq = Bioseq()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1176 alignedBioseqDB = BioseqDB()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1177 refBioseq.sequence = "AACTTACCAGAA"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1178 refBioseq.header = "reference"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1179 bs1 = Bioseq( "line1", "AACTTTCCAGAA" )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1180 bs2 = Bioseq( "line2", "AACTTACC-GAA" )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1181 alignedBioseqDB.setData( [ bs1, bs2 ] )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1182 multifasta2SNPFile = Multifasta2SNPFile("batch1", "gene1", "mouse")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1183 multifasta2SNPFile._wrapper = ReferenceBioseqAndLinesBioseqDBWrapper(refBioseq, alignedBioseqDB, multifasta2SNPFile._logFile, self._inFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1184 subsnpPosition = 1
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1185 polymLength = 1
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1186 lineName = "line1"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1187 exp5flank = ""
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1188 exp3flank = "ACTTTCCAGAA"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1189
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1190 obs5flank, obs3flank = multifasta2SNPFile.getFlanksOfASubSNP(lineName, subsnpPosition, polymLength, 500)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1191 self.assertEquals(exp5flank, obs5flank)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1192 self.assertEquals(exp3flank, obs3flank)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1193
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1194 def test_getFlanksOfASubSNP_flank_of_first_base_with_polym_on_all_sequence(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1195 refBioseq = Bioseq()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1196 alignedBioseqDB = BioseqDB()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1197 refBioseq.sequence = "AACTTACCAGAA"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1198 refBioseq.header = "reference"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1199 bs1 = Bioseq( "line1", "AACTTTCCAGAA" )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1200 bs2 = Bioseq( "line2", "AACTTACC-GAA" )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1201 alignedBioseqDB.setData( [ bs1, bs2 ] )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1202 multifasta2SNPFile = Multifasta2SNPFile("batch1", "gene1", "mouse")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1203 multifasta2SNPFile._wrapper = ReferenceBioseqAndLinesBioseqDBWrapper(refBioseq, alignedBioseqDB, multifasta2SNPFile._logFile, self._inFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1204 subsnpPosition = 1
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1205 polymLength = 12
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1206 lineName = "line1"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1207 exp5flank = ""
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1208 exp3flank = ""
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1209 obs5flank, obs3flank = multifasta2SNPFile.getFlanksOfASubSNP(lineName, subsnpPosition, polymLength, 500)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1210 self.assertEquals(exp5flank, obs5flank)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1211 self.assertEquals(exp3flank, obs3flank)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1212
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1213 def test_getFlanksOfASubSNP_flank_of_last_base_with_polym_on_all_sequence(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1214 refBioseq = Bioseq()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1215 alignedBioseqDB = BioseqDB()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1216 refBioseq.sequence = "AACTTACCAGAA"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1217 refBioseq.header = "reference"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1218 bs1 = Bioseq( "line1", "AACTTTCCAGAA" )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1219 bs2 = Bioseq( "line2", "AACTTACC-GAA" )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1220 alignedBioseqDB.setData( [ bs1, bs2 ] )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1221 multifasta2SNPFile = Multifasta2SNPFile("batch1", "gene1", "mouse")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1222 multifasta2SNPFile._wrapper = ReferenceBioseqAndLinesBioseqDBWrapper(refBioseq, alignedBioseqDB, multifasta2SNPFile._logFile, self._inFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1223 subsnpPosition = 12
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1224 polymLength = 1
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1225 lineName = "line1"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1226 exp5flank = "AACTTTCCAGA"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1227 exp3flank = ""
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1228 obs5flank, obs3flank = multifasta2SNPFile.getFlanksOfASubSNP(lineName, subsnpPosition, polymLength, 500)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1229 self.assertEquals(exp5flank, obs5flank)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1230 self.assertEquals(exp3flank, obs3flank)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1231 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1232 def test_subSNPExistsInSubSNPList_subSNP_exists(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1233 batchName = "batch1"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1234 lSubSNP = [{'subSNPName': batchName + "_DEL_1_line2", 'position': 1, 'lineName': 2, 'allele': 3, '5flank': "", '3flank': "CCGAA", 'batchNumber': 1, 'confidenceValue' : "A", 'type' : "DELETION", 'length': 4},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1235 {'subSNPName': batchName + "_DEL_1_line1", 'position': 1, 'lineName': 1, 'allele': 2, '5flank': "", '3flank': "CCGAA",'batchNumber': 1, 'confidenceValue' : "A", 'type' : "DELETION", 'length': 4},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1236 {'subSNPName': batchName + "_SNP_8_line3", 'position': 8, 'lineName': 3, 'allele': 1, '5flank': "ATTACCG", '3flank': "A", 'batchNumber': 1, 'confidenceValue' : "A", 'type' : "SNP", 'length': 1},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1237 {'subSNPName': batchName + "_SNP_8_line1", 'position': 8, 'lineName': 1, 'allele': 6, '5flank': "A--ACCG", '3flank': "A", 'batchNumber': 1, 'confidenceValue' : "A", 'type' : "SNP", 'length': 1},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1238 {'subSNPName': batchName + "_SNP_8_line2", 'position': 8, 'lineName': 2, 'allele': 6, '5flank': "---ACCG", '3flank': "A", 'batchNumber': 1, 'confidenceValue' : "A", 'type' : "SNP", 'length': 1},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1239 {'subSNPName': batchName + "_SNP_8_line4", 'position': 8, 'lineName': 4, 'allele': 6, '5flank': "----CCG", '3flank': "A", 'batchNumber': 1, 'confidenceValue' : "A", 'type' : "SNP", 'length': 1},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1240 {'subSNPName': batchName + "_DEL_1_line4", 'position': 1, 'lineName': 4, 'allele': 4, '5flank': "", '3flank': "CCGAA",'batchNumber': 1, 'confidenceValue' : "A", 'type' : "DELETION", 'length': 4},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1241 {'subSNPName': batchName + "_DEL_1_line3", 'position': 1, 'lineName': 3, 'allele': 5, '5flank': "", '3flank': "CCGGA",'batchNumber': 1, 'confidenceValue' : "A", 'type' : "DELETION", 'length': 4}]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1242 multifasta2SNPFile = Multifasta2SNPFile(batchName, "gene1", "mouse")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1243
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1244 dSearchedSubSNP = {'subSNPName': batchName + "_DEL_1_line1", 'position': 1, 'lineName': 1, 'allele': 2, '5flank': "", '3flank': "CCGAA",'batchNumber': 1, 'confidenceValue' : "A", 'type' : "DELETION", 'length': 4}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1245
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1246 expResult = multifasta2SNPFile.subSNPExistsInSubSNPList(dSearchedSubSNP, lSubSNP)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1247 obsResult = True
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1248
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1249 self.assertEquals(expResult, obsResult)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1250
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1251 def test_subSNPExistsInSubSNPList_subSNP_does_not_exist(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1252 batchName = "batch1"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1253 lSubSNP = [{'subSNPName': batchName + "_DEL_1_line2", 'position': 1, 'lineName': 2, 'allele': 3, '5flank': "", '3flank': "CCGAA", 'batchNumber': 1, 'confidenceValue' : "A", 'type' : "DELETION", 'length': 4},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1254 {'subSNPName': batchName + "_DEL_1_line1", 'position': 1, 'lineName': 1, 'allele': 2, '5flank': "", '3flank': "CCGAA",'batchNumber': 1, 'confidenceValue' : "A", 'type' : "DELETION", 'length': 4},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1255 {'subSNPName': batchName + "_SNP_8_line3", 'position': 8, 'lineName': 3, 'allele': 1, '5flank': "ATTACCG", '3flank': "A", 'batchNumber': 1, 'confidenceValue' : "A", 'type' : "SNP", 'length': 1},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1256 {'subSNPName': batchName + "_SNP_8_line1", 'position': 8, 'lineName': 1, 'allele': 6, '5flank': "A--ACCG", '3flank': "A", 'batchNumber': 1, 'confidenceValue' : "A", 'type' : "SNP", 'length': 1},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1257 {'subSNPName': batchName + "_SNP_8_line2", 'position': 8, 'lineName': 2, 'allele': 6, '5flank': "---ACCG", '3flank': "A", 'batchNumber': 1, 'confidenceValue' : "A", 'type' : "SNP", 'length': 1},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1258 {'subSNPName': batchName + "_SNP_8_line4", 'position': 8, 'lineName': 4, 'allele': 6, '5flank': "----CCG", '3flank': "A", 'batchNumber': 1, 'confidenceValue' : "A", 'type' : "SNP", 'length': 1},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1259 {'subSNPName': batchName + "_DEL_1_line4", 'position': 1, 'lineName': 4, 'allele': 4, '5flank': "", '3flank': "CCGAA",'batchNumber': 1, 'confidenceValue' : "A", 'type' : "DELETION", 'length': 4},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1260 {'subSNPName': batchName + "_DEL_1_line3", 'position': 1, 'lineName': 3, 'allele': 5, '5flank': "", '3flank': "CCGGA",'batchNumber': 1, 'confidenceValue' : "A", 'type' : "DELETION", 'length': 4}]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1261 multifasta2SNPFile = Multifasta2SNPFile(batchName, "gene1", "mouse")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1262
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1263 dSearchedSubSNP = {'subSNPName': batchName + "_DEL_12_line1", 'position': 12, 'lineName': 1, 'allele': 2, '5flank': "", '3flank': "CCGAA",'batchNumber': 1, 'confidenceValue' : "A", 'type' : "DELETION", 'length': 4}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1264
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1265 expResult = multifasta2SNPFile.subSNPExistsInSubSNPList(dSearchedSubSNP, lSubSNP)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1266 obsResult = False
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1267
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1268 self.assertEquals(expResult, obsResult)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1269
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1270 def _writeExpSubSNPFile(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1271 expFileHandle = open(self._expSubSNPFileName, "w")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1272 expFileHandle.write("SubSNPName;ConfidenceValue;Type;Position;5flank;3flank;Length;BatchNumber;IndividualNumber;PrimerType;PrimerNumber;Forward_or_Reverse;AlleleNumber\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1273 expFileHandle.write("Batch1_SNP_4_Line1;A;SNP;4;CCT;AGCCATTGCTTGGTGACTATGAAGGCAGTAGGCAAACCTCCACAATC;1;1;1;Sequence;;;1\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1274 expFileHandle.write("Batch1_SNP_4_Line2;A;SNP;4;CCT;AGCCATTGCTTGGTGACTATCAAGGCAGTAGCCAAACCTCCACAATA;1;1;2;Sequence;;;4\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1275 expFileHandle.write("Batch1_SNP_21_Line1;A;SNP;21;CCTTAGCCATTGCTTGGTGA;TATGAAGGCAGTAGGCAAACCTCCACAATC;1;1;1;Sequence;;;2\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1276 expFileHandle.write("Batch1_SNP_21_Line2;A;SNP;21;CCTAAGCCATTGCTTGGTGA;TATCAAGGCAGTAGCCAAACCTCCACAATA;1;1;2;Sequence;;;2\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1277 expFileHandle.write("Batch1_SNP_25_Line1;A;SNP;25;CCTTAGCCATTGCTTGGTGACTAT;AAGGCAGTAGGCAAACCTCCACAATC;1;1;1;Sequence;;;3\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1278 expFileHandle.write("Batch1_SNP_25_Line2;A;SNP;25;CCTAAGCCATTGCTTGGTGACTAT;AAGGCAGTAGCCAAACCTCCACAATA;1;1;2;Sequence;;;2\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1279 expFileHandle.write("Batch1_SNP_36_Line1;A;SNP;36;CCTTAGCCATTGCTTGGTGACTATGAAGGCAGTAG;CAAACCTCCACAATC;1;1;1;Sequence;;;3\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1280 expFileHandle.write("Batch1_SNP_36_Line2;A;SNP;36;CCTAAGCCATTGCTTGGTGACTATCAAGGCAGTAG;CAAACCTCCACAATA;1;1;2;Sequence;;;2\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1281 expFileHandle.write("Batch1_SNP_51_Line1;A;SNP;51;CCTTAGCCATTGCTTGGTGACTATGAAGGCAGTAGGCAAACCTCCACAAT;;1;1;1;Sequence;;;2\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1282 expFileHandle.write("Batch1_SNP_51_Line2;A;SNP;51;CCTAAGCCATTGCTTGGTGACTATCAAGGCAGTAGCCAAACCTCCACAAT;;1;1;2;Sequence;;;4\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1283 expFileHandle.close()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1284
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1285 def _writeExpSubSNPFileWithSnpsAndIndels(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1286 expFileHandle = open(self._expSubSNPFileName, "w")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1287 expFileHandle.write("SubSNPName;ConfidenceValue;Type;Position;5flank;3flank;Length;BatchNumber;IndividualNumber;PrimerType;PrimerNumber;Forward_or_Reverse;AlleleNumber\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1288 expFileHandle.write("Batch1_INS_1_Line1;A;INSERTION;1;C;TAGCCA---CTTGGTGACTATGAAGGCAGTAGGCAAACCTCCACAATC;2;1;1;Sequence;;;8\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1289 expFileHandle.write("Batch1_INS_1_Line2;A;INSERTION;1;C;AAGCCATT-CTTGGTGACTATCAAGGCAGTAGCCAAACCTCCACAATA;2;1;2;Sequence;;;6\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1290 expFileHandle.write("Batch1_SNP_2_Line1;A;SNP;2;C--;AGCCA---CTTGGTGACTATGAAGGCAGTAGGCAAACCTCCACAATC;1;1;1;Sequence;;;1\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1291 expFileHandle.write("Batch1_SNP_2_Line2;A;SNP;2;CCT;AGCCATT-CTTGGTGACTATCAAGGCAGTAGCCAAACCTCCACAATA;1;1;2;Sequence;;;4\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1292 expFileHandle.write("Batch1_DEL_8_Line1;A;DELETION;8;C--TAGCCA;CTTGGTGACTATGAAGGCAGTAGGCAAACCTCCACAATC;3;1;1;Sequence;;;5\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1293 expFileHandle.write("Batch1_DEL_8_Line2;A;DELETION;8;CCTAAGCCA;CTTGGTGACTATCAAGGCAGTAGCCAAACCTCCACAATA;3;1;2;Sequence;;;7\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1294 expFileHandle.write("Batch1_SNP_19_Line1;A;SNP;19;C--TAGCCA---CTTGGTGA;TATGAAGGCAGTAGGCAAACCTCCACAATC;1;1;1;Sequence;;;2\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1295 expFileHandle.write("Batch1_SNP_19_Line2;A;SNP;19;CCTAAGCCATT-CTTGGTGA;TATCAAGGCAGTAGCCAAACCTCCACAATA;1;1;2;Sequence;;;2\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1296 expFileHandle.write("Batch1_SNP_23_Line1;A;SNP;23;C--TAGCCA---CTTGGTGACTAT;AAGGCAGTAGGCAAACCTCCACAATC;1;1;1;Sequence;;;3\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1297 expFileHandle.write("Batch1_SNP_23_Line2;A;SNP;23;CCTAAGCCATT-CTTGGTGACTAT;AAGGCAGTAGCCAAACCTCCACAATA;1;1;2;Sequence;;;2\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1298 expFileHandle.write("Batch1_SNP_34_Line1;A;SNP;34;C--TAGCCA---CTTGGTGACTATGAAGGCAGTAG;CAAACCTCCACAATC;1;1;1;Sequence;;;3\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1299 expFileHandle.write("Batch1_SNP_34_Line2;A;SNP;34;CCTAAGCCATT-CTTGGTGACTATCAAGGCAGTAG;CAAACCTCCACAATA;1;1;2;Sequence;;;2\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1300 expFileHandle.write("Batch1_SNP_49_Line1;A;SNP;49;C--TAGCCA---CTTGGTGACTATGAAGGCAGTAGGCAAACCTCCACAAT;;1;1;1;Sequence;;;2\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1301 expFileHandle.write("Batch1_SNP_49_Line2;A;SNP;49;CCTAAGCCATT-CTTGGTGACTATCAAGGCAGTAGCCAAACCTCCACAAT;;1;1;2;Sequence;;;4\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1302 expFileHandle.close()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1303
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1304 def _writeExpSubSNPFileSeveralBatches(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1305 expFileHandle = open(self._expSubSNPFileName, "w")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1306 expFileHandle.write("SubSNPName;ConfidenceValue;Type;Position;5flank;3flank;Length;BatchNumber;IndividualNumber;PrimerType;PrimerNumber;Forward_or_Reverse;AlleleNumber\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1307 expFileHandle.write("Batch_Gene1_SNP_4_Line1;A;SNP;4;CCT;AGCCATTGCTTGGTGACTATGAAGGCAGTAGGCAAACCTCCACAATC;1;1;1;Sequence;;;1\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1308 expFileHandle.write("Batch_Gene1_SNP_4_Line2;A;SNP;4;CCT;AGCCATTGCTTGGTGACTATCAAGGCAGTAGCCAAACCTCCACAATA;1;1;2;Sequence;;;4\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1309 expFileHandle.write("Batch_Gene1_SNP_21_Line1;A;SNP;21;CCTTAGCCATTGCTTGGTGA;TATGAAGGCAGTAGGCAAACCTCCACAATC;1;1;1;Sequence;;;2\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1310 expFileHandle.write("Batch_Gene1_SNP_21_Line2;A;SNP;21;CCTAAGCCATTGCTTGGTGA;TATCAAGGCAGTAGCCAAACCTCCACAATA;1;1;2;Sequence;;;2\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1311 expFileHandle.write("Batch_Gene1_SNP_25_Line1;A;SNP;25;CCTTAGCCATTGCTTGGTGACTAT;AAGGCAGTAGGCAAACCTCCACAATC;1;1;1;Sequence;;;3\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1312 expFileHandle.write("Batch_Gene1_SNP_25_Line2;A;SNP;25;CCTAAGCCATTGCTTGGTGACTAT;AAGGCAGTAGCCAAACCTCCACAATA;1;1;2;Sequence;;;2\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1313 expFileHandle.write("Batch_Gene1_SNP_36_Line1;A;SNP;36;CCTTAGCCATTGCTTGGTGACTATGAAGGCAGTAG;CAAACCTCCACAATC;1;1;1;Sequence;;;3\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1314 expFileHandle.write("Batch_Gene1_SNP_36_Line2;A;SNP;36;CCTAAGCCATTGCTTGGTGACTATCAAGGCAGTAG;CAAACCTCCACAATA;1;1;2;Sequence;;;2\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1315 expFileHandle.write("Batch_Gene1_SNP_51_Line1;A;SNP;51;CCTTAGCCATTGCTTGGTGACTATGAAGGCAGTAGGCAAACCTCCACAAT;;1;1;1;Sequence;;;2\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1316 expFileHandle.write("Batch_Gene1_SNP_51_Line2;A;SNP;51;CCTAAGCCATTGCTTGGTGACTATCAAGGCAGTAGCCAAACCTCCACAAT;;1;1;2;Sequence;;;4\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1317
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1318 expFileHandle.write("Batch_Gene2_INS_1_Line1;A;INSERTION;1;C;TAGCCA---CTTGGTGACTATGAAGGCAGTAGGCAAACCTCCACAATC;2;2;1;Sequence;;;8\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1319 expFileHandle.write("Batch_Gene2_INS_1_Line2;A;INSERTION;1;C;AAGCCATT-CTTGGTGACTATCAAGGCAGTAGCCAAACCTCCACAATA;2;2;2;Sequence;;;6\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1320 expFileHandle.write("Batch_Gene2_SNP_2_Line1;A;SNP;2;C--;AGCCA---CTTGGTGACTATGAAGGCAGTAGGCAAACCTCCACAATC;1;2;1;Sequence;;;1\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1321 expFileHandle.write("Batch_Gene2_SNP_2_Line2;A;SNP;2;CCT;AGCCATT-CTTGGTGACTATCAAGGCAGTAGCCAAACCTCCACAATA;1;2;2;Sequence;;;4\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1322 expFileHandle.write("Batch_Gene2_DEL_8_Line1;A;DELETION;8;C--TAGCCA;CTTGGTGACTATGAAGGCAGTAGGCAAACCTCCACAATC;3;2;1;Sequence;;;5\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1323 expFileHandle.write("Batch_Gene2_DEL_8_Line2;A;DELETION;8;CCTAAGCCA;CTTGGTGACTATCAAGGCAGTAGCCAAACCTCCACAATA;3;2;2;Sequence;;;7\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1324 expFileHandle.write("Batch_Gene2_SNP_19_Line1;A;SNP;19;C--TAGCCA---CTTGGTGA;TATGAAGGCAGTAGGCAAACCTCCACAATC;1;2;1;Sequence;;;2\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1325 expFileHandle.write("Batch_Gene2_SNP_19_Line2;A;SNP;19;CCTAAGCCATT-CTTGGTGA;TATCAAGGCAGTAGCCAAACCTCCACAATA;1;2;2;Sequence;;;2\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1326 expFileHandle.write("Batch_Gene2_SNP_23_Line1;A;SNP;23;C--TAGCCA---CTTGGTGACTAT;AAGGCAGTAGGCAAACCTCCACAATC;1;2;1;Sequence;;;3\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1327 expFileHandle.write("Batch_Gene2_SNP_23_Line2;A;SNP;23;CCTAAGCCATT-CTTGGTGACTAT;AAGGCAGTAGCCAAACCTCCACAATA;1;2;2;Sequence;;;2\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1328 expFileHandle.write("Batch_Gene2_SNP_34_Line1;A;SNP;34;C--TAGCCA---CTTGGTGACTATGAAGGCAGTAG;CAAACCTCCACAATC;1;2;1;Sequence;;;3\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1329 expFileHandle.write("Batch_Gene2_SNP_34_Line2;A;SNP;34;CCTAAGCCATT-CTTGGTGACTATCAAGGCAGTAG;CAAACCTCCACAATA;1;2;2;Sequence;;;2\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1330 expFileHandle.write("Batch_Gene2_SNP_49_Line1;A;SNP;49;C--TAGCCA---CTTGGTGACTATGAAGGCAGTAGGCAAACCTCCACAAT;;1;2;1;Sequence;;;2\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1331 expFileHandle.write("Batch_Gene2_SNP_49_Line2;A;SNP;49;CCTAAGCCATT-CTTGGTGACTATCAAGGCAGTAGCCAAACCTCCACAAT;;1;2;2;Sequence;;;4\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1332 expFileHandle.close()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1333
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1334 def _writeExpSubSNPFileSeveralBatches_different_lines_between_files(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1335 expFileHandle = open(self._expSubSNPFileName, "w")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1336 expFileHandle.write("SubSNPName;ConfidenceValue;Type;Position;5flank;3flank;Length;BatchNumber;IndividualNumber;PrimerType;PrimerNumber;Forward_or_Reverse;AlleleNumber\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1337 expFileHandle.write("Batch_Gene1_SNP_4_Line1;A;SNP;4;CCT;AGCCATTGCTTGGTGACTATGAAGGCAGTAGGCAAACCTCCACAATC;1;1;1;Sequence;;;1\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1338 expFileHandle.write("Batch_Gene1_SNP_4_Line2;A;SNP;4;CCT;AGCCATTGCTTGGTGACTATCAAGGCAGTAGCCAAACCTCCACAATA;1;1;2;Sequence;;;4\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1339 expFileHandle.write("Batch_Gene1_SNP_21_Line1;A;SNP;21;CCTTAGCCATTGCTTGGTGA;TATGAAGGCAGTAGGCAAACCTCCACAATC;1;1;1;Sequence;;;2\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1340 expFileHandle.write("Batch_Gene1_SNP_21_Line2;A;SNP;21;CCTAAGCCATTGCTTGGTGA;TATCAAGGCAGTAGCCAAACCTCCACAATA;1;1;2;Sequence;;;2\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1341 expFileHandle.write("Batch_Gene1_SNP_25_Line1;A;SNP;25;CCTTAGCCATTGCTTGGTGACTAT;AAGGCAGTAGGCAAACCTCCACAATC;1;1;1;Sequence;;;3\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1342 expFileHandle.write("Batch_Gene1_SNP_25_Line2;A;SNP;25;CCTAAGCCATTGCTTGGTGACTAT;AAGGCAGTAGCCAAACCTCCACAATA;1;1;2;Sequence;;;2\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1343 expFileHandle.write("Batch_Gene1_SNP_36_Line1;A;SNP;36;CCTTAGCCATTGCTTGGTGACTATGAAGGCAGTAG;CAAACCTCCACAATC;1;1;1;Sequence;;;3\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1344 expFileHandle.write("Batch_Gene1_SNP_36_Line2;A;SNP;36;CCTAAGCCATTGCTTGGTGACTATCAAGGCAGTAG;CAAACCTCCACAATA;1;1;2;Sequence;;;2\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1345 expFileHandle.write("Batch_Gene1_SNP_51_Line1;A;SNP;51;CCTTAGCCATTGCTTGGTGACTATGAAGGCAGTAGGCAAACCTCCACAAT;;1;1;1;Sequence;;;2\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1346 expFileHandle.write("Batch_Gene1_SNP_51_Line2;A;SNP;51;CCTAAGCCATTGCTTGGTGACTATCAAGGCAGTAGCCAAACCTCCACAAT;;1;1;2;Sequence;;;4\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1347
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1348 expFileHandle.write("Batch_Gene2_INS_1_Line3;A;INSERTION;1;C;TAGCCA---CTTGGTGACTATGAAGGCAGTAGGCAAACCTCCACAATC;2;2;3;Sequence;;;8\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1349 expFileHandle.write("Batch_Gene2_INS_1_Line4;A;INSERTION;1;C;AAGCCATT-CTTGGTGACTATCAAGGCAGTAGCCAAACCTCCACAATA;2;2;4;Sequence;;;6\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1350 expFileHandle.write("Batch_Gene2_SNP_2_Line3;A;SNP;2;C--;AGCCA---CTTGGTGACTATGAAGGCAGTAGGCAAACCTCCACAATC;1;2;3;Sequence;;;1\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1351 expFileHandle.write("Batch_Gene2_SNP_2_Line4;A;SNP;2;CCT;AGCCATT-CTTGGTGACTATCAAGGCAGTAGCCAAACCTCCACAATA;1;2;4;Sequence;;;4\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1352 expFileHandle.write("Batch_Gene2_DEL_8_Line3;A;DELETION;8;C--TAGCCA;CTTGGTGACTATGAAGGCAGTAGGCAAACCTCCACAATC;3;2;3;Sequence;;;5\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1353 expFileHandle.write("Batch_Gene2_DEL_8_Line4;A;DELETION;8;CCTAAGCCA;CTTGGTGACTATCAAGGCAGTAGCCAAACCTCCACAATA;3;2;4;Sequence;;;7\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1354 expFileHandle.write("Batch_Gene2_SNP_19_Line3;A;SNP;19;C--TAGCCA---CTTGGTGA;TATGAAGGCAGTAGGCAAACCTCCACAATC;1;2;3;Sequence;;;2\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1355 expFileHandle.write("Batch_Gene2_SNP_19_Line4;A;SNP;19;CCTAAGCCATT-CTTGGTGA;TATCAAGGCAGTAGCCAAACCTCCACAATA;1;2;4;Sequence;;;2\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1356 expFileHandle.write("Batch_Gene2_SNP_23_Line3;A;SNP;23;C--TAGCCA---CTTGGTGACTAT;AAGGCAGTAGGCAAACCTCCACAATC;1;2;3;Sequence;;;3\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1357 expFileHandle.write("Batch_Gene2_SNP_23_Line4;A;SNP;23;CCTAAGCCATT-CTTGGTGACTAT;AAGGCAGTAGCCAAACCTCCACAATA;1;2;4;Sequence;;;2\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1358 expFileHandle.write("Batch_Gene2_SNP_34_Line3;A;SNP;34;C--TAGCCA---CTTGGTGACTATGAAGGCAGTAG;CAAACCTCCACAATC;1;2;3;Sequence;;;3\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1359 expFileHandle.write("Batch_Gene2_SNP_34_Line4;A;SNP;34;CCTAAGCCATT-CTTGGTGACTATCAAGGCAGTAG;CAAACCTCCACAATA;1;2;4;Sequence;;;2\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1360 expFileHandle.write("Batch_Gene2_SNP_49_Line3;A;SNP;49;C--TAGCCA---CTTGGTGACTATGAAGGCAGTAGGCAAACCTCCACAAT;;1;2;3;Sequence;;;2\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1361 expFileHandle.write("Batch_Gene2_SNP_49_Line4;A;SNP;49;CCTAAGCCATT-CTTGGTGACTATCAAGGCAGTAGCCAAACCTCCACAAT;;1;2;4;Sequence;;;4\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1362 expFileHandle.close()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1363
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1364 def _writeExpSubSNPFileSeveralLineSeq(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1365 expFileHandle = open(self._expSubSNPFileName, "w")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1366 expFileHandle.write("SubSNPName;ConfidenceValue;Type;Position;5flank;3flank;Length;BatchNumber;IndividualNumber;PrimerType;PrimerNumber;Forward_or_Reverse;AlleleNumber\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1367 expFileHandle.write("Batch1_SNP_4_Line1;A;SNP;4;CCT;AGCCATTGCTTGGTGACTATGAAGGCAGTAGGCAAACCTCCACAATCCGCAGTAGCCAAACCTCCACAATA;1;1;1;Sequence;;;1\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1368 expFileHandle.write("Batch1_SNP_4_Line2;A;SNP;4;CCT;AGCCATTGCTTGGTGACTATCAAGGCAGTAGCCAAACCTCCACAATACGCAGTAGCCAAACCTCCACAATA;1;1;2;Sequence;;;4\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1369 expFileHandle.write("Batch1_SNP_21_Line1;A;SNP;21;CCTTAGCCATTGCTTGGTGA;TATGAAGGCAGTAGGCAAACCTCCACAATCCGCAGTAGCCAAACCTCCACAATA;1;1;1;Sequence;;;2\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1370 expFileHandle.write("Batch1_SNP_21_Line2;A;SNP;21;CCTAAGCCATTGCTTGGTGA;TATCAAGGCAGTAGCCAAACCTCCACAATACGCAGTAGCCAAACCTCCACAATA;1;1;2;Sequence;;;2\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1371 expFileHandle.write("Batch1_SNP_25_Line1;A;SNP;25;CCTTAGCCATTGCTTGGTGACTAT;AAGGCAGTAGGCAAACCTCCACAATCCGCAGTAGCCAAACCTCCACAATA;1;1;1;Sequence;;;3\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1372 expFileHandle.write("Batch1_SNP_25_Line2;A;SNP;25;CCTAAGCCATTGCTTGGTGACTAT;AAGGCAGTAGCCAAACCTCCACAATACGCAGTAGCCAAACCTCCACAATA;1;1;2;Sequence;;;2\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1373 expFileHandle.write("Batch1_SNP_36_Line1;A;SNP;36;CCTTAGCCATTGCTTGGTGACTATGAAGGCAGTAG;CAAACCTCCACAATCCGCAGTAGCCAAACCTCCACAATA;1;1;1;Sequence;;;3\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1374 expFileHandle.write("Batch1_SNP_36_Line2;A;SNP;36;CCTAAGCCATTGCTTGGTGACTATCAAGGCAGTAG;CAAACCTCCACAATACGCAGTAGCCAAACCTCCACAATA;1;1;2;Sequence;;;2\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1375 expFileHandle.write("Batch1_SNP_51_Line1;A;SNP;51;CCTTAGCCATTGCTTGGTGACTATGAAGGCAGTAGGCAAACCTCCACAAT;CGCAGTAGCCAAACCTCCACAATA;1;1;1;Sequence;;;2\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1376 expFileHandle.write("Batch1_SNP_51_Line2;A;SNP;51;CCTAAGCCATTGCTTGGTGACTATCAAGGCAGTAGCCAAACCTCCACAAT;CGCAGTAGCCAAACCTCCACAATA;1;1;2;Sequence;;;4\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1377 expFileHandle.close()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1378
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1379
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1380 def _writeExpAlleleFile(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1381 expFileHandle = open(self._expAlleleFileName, "w")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1382 expFileHandle.write("AlleleNumber;Value;Motif;NbCopy;Comment\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1383 expFileHandle.write("1;T;;;\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1384 expFileHandle.write("2;C;;;\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1385 expFileHandle.write("3;G;;;\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1386 expFileHandle.write("4;A;;;\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1387 expFileHandle.close()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1388
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1389 def _writeExpAlleleFileWithSnpsAndIndels(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1390 expFileHandle = open(self._expAlleleFileName, "w")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1391 expFileHandle.write("AlleleNumber;Value;Motif;NbCopy;Comment\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1392 expFileHandle.write("1;T;;;\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1393 expFileHandle.write("2;C;;;\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1394 expFileHandle.write("3;G;;;\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1395 expFileHandle.write("4;A;;;\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1396 expFileHandle.write("5;---;;;\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1397 expFileHandle.write("6;CT;;;\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1398 expFileHandle.write("7;TT-;;;\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1399 expFileHandle.write("8;--;;;\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1400 expFileHandle.close()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1401
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1402
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1403 def _writeExpAlleleFileSeveralBatches(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1404 expFileHandle = open(self._expAlleleFileName, "w")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1405 expFileHandle.write("AlleleNumber;Value;Motif;NbCopy;Comment\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1406 expFileHandle.write("1;T;;;\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1407 expFileHandle.write("2;C;;;\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1408 expFileHandle.write("3;G;;;\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1409 expFileHandle.write("4;A;;;\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1410 expFileHandle.write("5;---;;;\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1411 expFileHandle.write("6;CT;;;\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1412 expFileHandle.write("7;TT-;;;\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1413 expFileHandle.write("8;--;;;\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1414 expFileHandle.close()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1415
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1416 def _writeExpIndividualFile(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1417 expFileHandle = open(self._expIndividualFileName, "w")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1418 expFileHandle.write("IndividualNumber;IndividualName;Description;AberrAneuploide;FractionLength;DeletionLineSynthesis;UrlEarImage;TypeLine;ChromNumber;ArmChrom;DeletionBin;ScientificName;local_germplasm_name;submitter_code;local_institute;donor_institute;donor_acc_id\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1419 expFileHandle.write("1;Line1;;;;;;;;;;Arabidopsis thaliana;;;;;\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1420 expFileHandle.write("2;Line2;;;;;;;;;;Arabidopsis thaliana;;;;;\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1421 expFileHandle.close()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1422
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1423 def _writeExpIndividualFile_different_lines_between_files(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1424 expFileHandle = open(self._expIndividualFileName, "w")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1425 expFileHandle.write("IndividualNumber;IndividualName;Description;AberrAneuploide;FractionLength;DeletionLineSynthesis;UrlEarImage;TypeLine;ChromNumber;ArmChrom;DeletionBin;ScientificName;local_germplasm_name;submitter_code;local_institute;donor_institute;donor_acc_id\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1426 expFileHandle.write("1;Line1;;;;;;;;;;Arabidopsis thaliana;;;;;\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1427 expFileHandle.write("2;Line2;;;;;;;;;;Arabidopsis thaliana;;;;;\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1428 expFileHandle.write("3;Line3;;;;;;;;;;Arabidopsis thaliana;;;;;\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1429 expFileHandle.write("4;Line4;;;;;;;;;;Arabidopsis thaliana;;;;;\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1430 expFileHandle.close()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1431
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1432 def _writeExpSequenceFile(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1433 SequenceFSAFileHandle = open(self._expSequenceFSAFileName, "w")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1434 SequenceFSAFileHandle.write(">Sequence_de_Reference\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1435 SequenceFSAFileHandle.write("CCTAAGCCATTGCTTGGTGATTATGAAGGCAGTAGTCAAACCTCCACAATC\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1436 SequenceCSVFileHandle = open(self._expSequenceCSVFileName, "w")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1437 SequenceCSVFileHandle.write("SequenceName;SeqType;BankName;BankVersion;ACNumber;Locus;ScientificName\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1438 SequenceCSVFileHandle.write("Sequence_de_Reference;Reference;;;;;Arabidopsis thaliana\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1439
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1440 def _writeExpSequenceFileSeveralLineSeq(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1441 SequenceFSAFileHandle = open(self._expSequenceFSAFileName, "w")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1442 SequenceFSAFileHandle.write(">Sequence_de_Reference\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1443 SequenceFSAFileHandle.write("CCTAAGCCATTGCTTGGTGATTATGAAGGCAGTAGTCAAACCTCCACAATCCGCAGTAGCCAAACCTCCACAATA\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1444 SequenceCSVFileHandle = open(self._expSequenceCSVFileName, "w")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1445 SequenceCSVFileHandle.write("SequenceName;SeqType;BankName;BankVersion;ACNumber;Locus;ScientificName\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1446 SequenceCSVFileHandle.write("Sequence_de_Reference;Reference;;;;;Arabidopsis thaliana\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1447
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1448 def _writeExpSequenceFileWithDeletion(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1449 SequenceFSAFileHandle = open(self._expSequenceFSAFileName, "w")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1450 SequenceFSAFileHandle.write(">Sequence_de_Reference\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1451 SequenceFSAFileHandle.write("CAAGCCATTGCTTGGTGATTATGAAGGCAGTAGTCAAACCTCCACAATC\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1452 SequenceCSVFileHandle = open(self._expSequenceCSVFileName, "w")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1453 SequenceCSVFileHandle.write("SequenceName;SeqType;BankName;BankVersion;ACNumber;Locus;ScientificName\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1454 SequenceCSVFileHandle.write("Sequence_de_Reference;Reference;;;;;Arabidopsis thaliana\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1455
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1456 def _writeExpSequenceSeveralBatches(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1457 SequenceFSAFileHandle = open(self._expSequenceFSAFileName, "w")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1458 SequenceFSAFileHandle.write(">Sequence_de_Reference1\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1459 SequenceFSAFileHandle.write("CCTAAGCCATTGCTTGGTGATTATGAAGGCAGTAGTCAAACCTCCACAATC\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1460 SequenceFSAFileHandle.write(">Sequence_de_Reference2\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1461 SequenceFSAFileHandle.write("CAAGCCATTGCTTGGTGATTATGAAGGCAGTAGTCAAACCTCCACAATC\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1462 SequenceCSVFileHandle = open(self._expSequenceCSVFileName, "w")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1463 SequenceCSVFileHandle.write("SequenceName;SeqType;BankName;BankVersion;ACNumber;Locus;ScientificName\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1464 SequenceCSVFileHandle.write("Sequence_de_Reference1;Reference;;;;;Arabidopsis thaliana\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1465 SequenceCSVFileHandle.write("Sequence_de_Reference2;Reference;;;;;Arabidopsis thaliana\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1466
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1467 def _writeExpSequenceSeveralBatchesForSameRefSeq(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1468 SequenceFSAFileHandle = open(self._expSequenceFSAFileName, "w")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1469 SequenceFSAFileHandle.write(">Sequence_de_Reference1\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1470 SequenceFSAFileHandle.write("CCTAAGCCATTGCTTGGTGATTATGAAGGCAGTAGTCAAACCTCCACAATC\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1471 SequenceFSAFileHandle.write(">Sequence_de_Reference1\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1472 SequenceFSAFileHandle.write("CAAGCCATTGCTTGGTGATTATGAAGGCAGTAGTCAAACCTCCACAATC\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1473 SequenceCSVFileHandle = open(self._expSequenceCSVFileName, "w")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1474 SequenceCSVFileHandle.write("SequenceName;SeqType;BankName;BankVersion;ACNumber;Locus;ScientificName\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1475 SequenceCSVFileHandle.write("Sequence_de_Reference1;Reference;;;;;Arabidopsis thaliana\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1476 SequenceCSVFileHandle.write("Sequence_de_Reference1;Reference;;;;;Arabidopsis thaliana\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1477
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1478 def _writeExpBatchFile(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1479 BatchFileHandle = open(self._expBatchFileName, "w")