コード例 #1
0
 def test_writeToFile(self):
     """FlowgramCollection.writeToFile should write in correct format"""
     a = [
         Flowgram('0.5 1.0 4.0 0.0 1.5 0.0 0.0 2.0',
                  Name='a',
                  header_info={
                      'Bases': 'TACCCCTTGG',
                      'Name Length': '14'
                  }),
         Flowgram('1.5 1.0 0.0 0.0 2.5 1.0 2.0 1.0',
                  Name='b',
                  header_info={
                      'Bases': 'TTATTTACCG',
                      'Name Length': '14'
                  })
     ]
     f = FlowgramCollection(a, header_info={'Flow Chars': 'TACG'})
     fn = mktemp(suffix='.sff')
     f.writeToFile(fn)
     result = open(fn, 'U').read()
     self.assertEqual(
         result,
         """Common Header:\n  Flow Chars:\tTACG\n\n>a\n  Name Length:\t14\nBases:\tTACCCCTTGG\nFlowgram:\t0.5\t1.0\t4.0\t0.0\t1.5\t0.0\t0.0\t2.0\n\n>b\n  Name Length:\t14\nBases:\tTTATTTACCG\nFlowgram:\t1.5\t1.0\t0.0\t0.0\t2.5\t1.0\t2.0\t1.0\n"""
     )
     remove(fn)
コード例 #2
0
 def test_writeToFile(self):
     """FlowgramCollection.writeToFile should write in correct format"""
     a = [Flowgram('0.5 1.0 4.0 0.0 1.5 0.0 0.0 2.0', Name='a',
                   header_info = {'Bases':'TACCCCTTGG','Name Length':'14'}),
          Flowgram('1.5 1.0 0.0 0.0 2.5 1.0 2.0 1.0', Name = 'b',
           header_info = {'Bases':'TTATTTACCG','Name Length':'14'})]
     f = FlowgramCollection(a, header_info = {'Flow Chars':'TACG'})
     fn = mktemp(suffix='.sff')
     f.writeToFile(fn)
     result = open(fn, 'U').read()
     self.assertEqual(result, """Common Header:\n  Flow Chars:\tTACG\n\n>a\n  Name Length:\t14\nBases:\tTACCCCTTGG\nFlowgram:\t0.5\t1.0\t4.0\t0.0\t1.5\t0.0\t0.0\t2.0\n\n>b\n  Name Length:\t14\nBases:\tTTATTTACCG\nFlowgram:\t1.5\t1.0\t0.0\t0.0\t2.5\t1.0\t2.0\t1.0\n""")
     remove(fn)
コード例 #3
0
 def test_writeToFile(self):
     """FlowgramCollection.writeToFile should write in correct format"""
     a = [
         Flowgram(
             "0.5 1.0 4.0 0.0 1.5 0.0 0.0 2.0", Name="a", header_info={"Bases": "TACCCCTTGG", "Name Length": "14"}
         ),
         Flowgram(
             "1.5 1.0 0.0 0.0 2.5 1.0 2.0 1.0", Name="b", header_info={"Bases": "TTATTTACCG", "Name Length": "14"}
         ),
     ]
     f = FlowgramCollection(a, header_info={"Flow Chars": "TACG"})
     fn = mktemp(suffix=".sff")
     f.writeToFile(fn)
     result = open(fn, "U").read()
     self.assertEqual(
         result,
         """Common Header:\n  Flow Chars:\tTACG\n\n>a\n  Name Length:\t14\nBases:\tTACCCCTTGG\nFlowgram:\t0.5\t1.0\t4.0\t0.0\t1.5\t0.0\t0.0\t2.0\n\n>b\n  Name Length:\t14\nBases:\tTTATTTACCG\nFlowgram:\t1.5\t1.0\t0.0\t0.0\t2.5\t1.0\t2.0\t1.0\n""",
     )
     remove(fn)