예제 #1
0
    def test_len(self):
        """returns the length of the flowgram"""
        f = Flowgram('0.5 1.0 4.0 0.0')
        self.assertEqual(len(f), 4)

        f = Flowgram()
        self.assertEqual(len(f), 0)
예제 #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_append_to_flowgram_file(self):
        """append_to_flowgram_file appends a flowgram to a flowgram file."""

        fh, tmp_filename = init_flowgram_file(n=100, l=400)
        self.assert_(exists(tmp_filename))
        self.tmp_filename = tmp_filename

        flow1 = Flowgram("0 1.2 2.1 3.4 0.02 0.01 1.02 0.08")
        append_to_flowgram_file("test_id", flow1, fh)

        flow2 = Flowgram('0.5 1.0 4.1 0.0 0.0 1.23 0.0 3.1',
                         Name='a',
                         floworder="TACG",
                         header_info={
                             'Bases': 'TACCCCAGGG',
                             'Clip Qual Right': 7,
                             'Flow Indexes': "1\t2\t3\t3\t3\t3\t6\t8\t8\t8"
                         })
        append_to_flowgram_file("test_id2", flow2, fh, trim=True)
        # close and re-open to read from start, seek might work as well here...
        fh.close()
        fh = open(tmp_filename)
        result_file_content = list(fh)
        self.assertEqual(result_file_content, [
            "100 400\n", "test_id 8 0.0 1.2 2.1 3.4 0.02 0.01 1.02 0.08\n",
            "test_id2 6 0.5 1.0 4.1 0.0 0.0 1.23\n"
        ])
예제 #4
0
    def test_hash(self):
        """__hash__ behaves like the flowgram string for dict lookup."""
        f = Flowgram('0.5 1.0 4.0 0.0', floworder="TACG")
        self.assertEqual(hash(f), hash('0.5 1.0 4.0 0.0'))

        f = Flowgram()
        self.assertEqual(hash(f), hash(''))
예제 #5
0
 def test_str(self):
     """FlowgramCollection __str__ should return sff 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'})
     
     self.assertEqual(str(f), """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""")        
예제 #6
0
    def test_createCommonHeader(self):
        """create_commor_header should return lines for sff common header"""
        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'})

        self.assertEqual('\n'.join(f.createCommonHeader()),
                         """Common Header:\n  Flow Chars:\tTACG""")
예제 #7
0
   def test_within_length(self):
      """within_length checks whether a flowgram is within a given length."""

      flow1 = Flowgram("0 1.2 2.1 3.4 0.02 0.01 1.02 0.08") # len 7
      flow2 = Flowgram('0.5 1.0 4.1 0.0 0.0 1.23 0.0 3.1')  # len 10

      self.assertTrue(within_length(flow1, 0,10))
      self.assertFalse(within_length(flow1, 10,20))
      self.assertFalse(within_length(flow2, 0,5))
      self.assertTrue(within_length(flow2, 5,20))
      self.assertTrue(within_length(flow2, 5,11))
예제 #8
0
    def test_cmpSeqToString(self):
        """Sequence should compare equal to same string."""
        f = Flowgram('0.5 1.0 4.0 0.0',
                     Name='a',
                     floworder="TACG",
                     header_info={'Bases': 'TACCCC'})
        self.assertTrue(f.cmpSeqToString('TACCCC'))
        self.assertFalse(f.cmpSeqToString('TACCC'))

        f = Flowgram('0.5 1.0 4.0 0.0', floworder="TACG")
        self.assertTrue(f.cmpSeqToString('TACCCC'))
        self.assertFalse(f.cmpSeqToString('TACCC'))
예제 #9
0
    def test_cmp(self):
        """_cmp_ should compare the flowgram strings."""

        f1 = Flowgram(['1 2 3 4'])
        f2 = Flowgram(['2 2 3 4'])
        self.assertNotEqual(f1, f2)
        self.assertEqual(f1, f1)

        #works also with string
        self.assertNotEqual(f1, "1 2 3 5")
        self.assertEqual(f1, "1 2 3 4")
        self.assertNotEqual(f1, "")
예제 #10
0
 def test_init_flow(self):
     """FlowgramCollection init from list of flowgrams should use indices
     as keys"""
     f1 = Flowgram('0.0 1.1 3.0 1.0')
     f2 = Flowgram('0.5 1.0 4.0 0.0')
     flows = [f1,f2]
     a = self.Class(flows)
     self.assertEqual(len(a.NamedFlows), 2)
     self.assertEqual(a.NamedFlows['seq_0'], '0.0 1.1 3.0 1.0')
     self.assertEqual(a.NamedFlows['seq_1'], '0.5 1.0 4.0 0.0')
     self.assertEqual(a.Names, ['seq_0','seq_1'])
     self.assertEqual(list(a.Flows), ['0.0 1.1 3.0 1.0','0.5 1.0 4.0 0.0'])
예제 #11
0
    def test_flows_from_dict(self):
        """flows_from_dict should init from dictionary"""
        c = {'a':'0.0 1.1 3.0 1.0','b':'0.5 1.0 4.0 0.0'}
        obs_a, obs_labels, obs_info = flows_from_dict(c)
        self.assertEqual(map(str,obs_a), ['0.0 1.1 3.0 1.0','0.5 1.0 4.0 0.0'])
        self.assertEqual(obs_labels, ['a','b'])
        self.assertEqual(obs_info, [None,None])

        c ={'a':Flowgram('0.0 1.1 3.0 1.0'),'b':Flowgram('0.5 1.0 4.0 0.0')}
        obs_a, obs_labels, obs_info = flows_from_dict(c)
        self.assertEqual(map(str,obs_a), ['0.0\t1.1\t3.0\t1.0','0.5\t1.0\t4.0\t0.0'])
        self.assertEqual(obs_labels, ['a','b'])
        self.assertEqual(obs_info, [None,None])
예제 #12
0
 def test_cmp_flow_to_string(self):
     """Sequence should compare equal to same string."""
     f = Flowgram('0.5 1.0 4.0 0.0',
                  Name='a',
                  floworder="TACG",
                  header_info={'Bases': 'TACCCC'})
     self.assertEqual(f, '0.5 1.0 4.0 0.0')
     self.assertNotEqual(f, '0.5 1.0 4.0')
     f2 = Flowgram('0.5 1.0 4.0 0.0',
                   Name='a',
                   floworder="TACG",
                   header_info={'Bases': 'TACCCC'})
     self.assertEqual(f, f2)
예제 #13
0
    def test_flows_from_kv_pairs(self):
        """seqs_from_kv_pairs should initialize from key-value pairs"""
        c = [['a','0.0 1.1 3.0 1.0'],['b','0.5 1.0 4.0 0.0']]
        obs_a, obs_labels, obs_info = flows_from_kv_pairs(c)
        self.assertEqual(map(str,obs_a), ['0.0 1.1 3.0 1.0','0.5 1.0 4.0 0.0'])
        self.assertEqual(obs_labels, ['a','b'])
        self.assertEqual(obs_info, [None,None])

        c =[['a',Flowgram('0.0 1.1 3.0 1.0')],['b',Flowgram('0.5 1.0 4.0 0.0')]]
        obs_a, obs_labels, obs_info = flows_from_kv_pairs(c)
        self.assertEqual(map(str,obs_a), ['0.0\t1.1\t3.0\t1.0','0.5\t1.0\t4.0\t0.0'])
        self.assertEqual(obs_labels, ['a','b'])
        self.assertEqual(obs_info, [None,None])
예제 #14
0
    def test_setBases(self):
        """FlowgramCollection setBases should set Bases property correctly"""
        f = self.Class([Flowgram('0.5 1.0 4.0 0.0 1.5 0.0 0.0 2.0', Name='a',
                                 header_info = {'Bases':'TACCCCTTGG'}),
                        Flowgram('0.0 1.0 0.0 0.0 2.0 1.0 2.0 2.0', Name='b',
                                 header_info = {'Bases':'ATTACCGG'}),
                        Flowgram('1.5 1.0 2.0 0.0 1.5 0.0 0.0 2.0', Name='c',
                                 header_info = {'Bases':'TTACCTTGG'})],
                       header_info = {'Flow Chars':'TACG'})

        f.setBases()

        for i,b in zip(f,['TACCCCTTGG','ATTACCGG','TTACCTTGG']):
            self.assertEqual(i.Bases,b)
예제 #15
0
   def test_check_ambigous(self):
      """check_ambigous detects stretches of ambigous Flows."""

      flow0 = Flowgram("")
      flow1 = Flowgram("0 1.2 2.1 3.4 0.02 0.01 1.02 0.08 0.5 1.0 4.1 0.0 0.0 1.23 0.0 3.1")
      flow2 = Flowgram("0 1.2 2.1 3.4 0.02 0.01 1.02 0.08 0.5 1.0 4.1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.23 0.0 3.1")
      flow3 = Flowgram("0 1.2 2.1 3.4 0.02 0.0 0.0 0.01 1.02 0.08 0.5 1.0 4.1 0.0 0.0 0.0 0.0 1.23 0.0 3.1")

      self.assertEqual(check_ambigous(flow0, 4), False)
      self.assertEqual(check_ambigous(flow1, 4), False)
      self.assertEqual(check_ambigous(flow2, 4), True)
      self.assertEqual(check_ambigous(flow2, 7), True)
      self.assertEqual(check_ambigous(flow2, 8), False)
      self.assertEqual(check_ambigous(flow3, 3), True)
      self.assertEqual(check_ambigous(flow3, 4), False)
예제 #16
0
 def test_guess_input_type(self):
     """  _guess_input_type should figure out data type correctly"""
     git = self.unordered._guess_input_type
     self.assertEqual(git(self.unordered), 'flowcoll')
     self.assertEqual(git(['0.0 1.1 3.0 1.0','0.5 1.0 4.0 0.0']), 'generic')
     self.assertEqual(git([Flowgram('0.0 1.1 3.0 1.0'),
                           Flowgram('0.5 1.0 4.0 0.0')]), 'generic')
     self.assertEqual(git([[1,2],[4,5]]), 'kv_pairs') #precedence over generic
     self.assertEqual(git([('a',Flowgram('0.0 1.1 3.0 1.0')),
                           ('b',Flowgram('0.5 1.0 4.0 0.0'))]), 'kv_pairs')
     self.assertEqual(git([[1,2,3],[4,5,6]]), 'generic')
     self.assertEqual(git(array([[1,2,3],[4,5,6]])), 'array')
     self.assertEqual(git({'a':'0.0 1.1 3.0 1.0'}), 'dict')
     self.assertEqual(git({'a':Flowgram('0.0 1.1 3.0 1.0')}), 'dict')
     self.assertEqual(git([]), 'empty')
     self.assertEqual(git('Common Header'), 'sff')
예제 #17
0
    def test_flows_from_generic(self):
        """flows_from_flow should initialize from list of flowgram objects"""
        c = Flowgram('0.0 1.1 3.0 1.0', Name='a')
        b = Flowgram('0.5 1.0 4.0 0.0', Name = 'b')
        obs_a, obs_labels, obs_info = flows_from_generic([c,b])
        self.assertEqual(map(str,obs_a), ['0.0\t1.1\t3.0\t1.0',
                                          '0.5\t1.0\t4.0\t0.0'])
        self.assertEqual(obs_labels, ['a','b'])
        self.assertEqual(obs_info, [None,None])

        f = ['0.0 1.1 3.0 1.0','0.5 1.0 4.0 0.0']
        obs_a, obs_labels, obs_info = flows_from_generic(f)
        self.assertEqual(map(str,obs_a), ['0.0 1.1 3.0 1.0',
                                          '0.5 1.0 4.0 0.0'])
        self.assertEqual(obs_labels, [None,None])
        self.assertEqual(obs_info, [None,None])
예제 #18
0
def _average_flowgrams(mapping, flowgrams, sample_keys):
    """average flowgrams according to cluster mapping.

    mapping: a dictionary of lists as cluster mapping

    flowgrams:  an iterable flowgram source, all flowgram ids from this source must be in the mapping

    sample_keys: the keys that should be averaged over for each cluster.
    """

    flows = defaultdict(list) # accumulates flowgram for each key until sample for this key is empty
    invert_map = invert_mapping(mapping)
    for f in flowgrams:
        key = invert_map[f.Name]
        samples = sample_keys[key]
        if (f.Name in samples):
            flows[key].append(f.flowgram)
            samples.remove(f.Name)
            if (len(samples)==0):
                #we gathered all sampled flowgrams for this cluster,
                #now average
                ave_flowgram = build_averaged_flowgram(flows[key])
                ave_f = Flowgram(ave_flowgram, Name=key)
               
                del(flows[key])
                yield ave_f, key
예제 #19
0
 def test_cmpByName(self):
     """Flowgrams should be the same if name, bases, or to_seqs are equal"""
     f = Flowgram('0.5 1.0 4.0 0.0',
                  Name='a',
                  floworder="TACG",
                  header_info={'Bases': 'TACCCC'})
     f2 = Flowgram('0.5 1.0 4.0 0.0',
                   Name='a',
                   floworder="TACG",
                   header_info={'Bases': 'TACCCC'})
     self.assertEqual(f.cmpByName(f2), 0)
     self.assertEqual(f.cmpByName(f), 0)
     f2 = Flowgram('0.5 1.0 4.0 0.0',
                   Name='b',
                   floworder="TACG",
                   header_info={'Bases': 'TACCCC'})
     self.assertNotEqual(f.cmpByName(f2), 0)
예제 #20
0
 def test_contains(self):
     """Flowgram contains should return correct result"""
     f = Flowgram('0.5 1.0 4.0 0.0',
                  Name='a',
                  floworder="TACG",
                  header_info={'Bases': 'TACCCC'})
     assert '0.5' in f
     assert '0.5 1.0' in f
     assert '2.0' not in f
     assert '5.0' not in f
예제 #21
0
def _sff_parser(handle, header):
    for s in handle:
        t = split_summary(s)
        flowgram = t["Flowgram"]
        del t["Flowgram"]
        flowgram = Flowgram(flowgram,
                            Name=t["Name"],
                            KeySeq=header["Key Sequence"],
                            floworder=header["Flow Chars"],
                            header_info=t)

        yield flowgram
예제 #22
0
    def test_createFlowHeader(self):
        """header_info dict turned into flowgram header"""
        f = 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'
                     })

        self.assertEqual(
            f.createFlowHeader(),
            """>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"""
        )
예제 #23
0
    def test_init_data(self):
        """Flowgram init with data should set data in correct location"""
        f = Flowgram('0.5 1.0 4.0 0.0',
                     Name='a',
                     KeySeq="ATCG",
                     floworder="TACG",
                     header_info={'Bases': 'TACCCC'})
        self.assertEqual(f._flowgram, '0.5 1.0 4.0 0.0')
        self.assertEqual(f.flowgram, [0.5, 1.0, 4.0, 0.0])
        self.assertEqual(f.Name, 'a')
        self.assertEqual(f.keySeq, "ATCG")
        self.assertEqual(f.floworder, "TACG")
        self.assertEqual(f.Bases, 'TACCCC')
        self.assertEqual(f.header_info, {'Bases': 'TACCCC'})

        f = Flowgram([0.5, 1.0, 4.0, 0.0],
                     Name='a',
                     KeySeq="ATCG",
                     floworder="TACG",
                     header_info={'Bases': 'TACCCC'})
        self.assertEqual(f._flowgram, '0.5 1.0 4.0 0.0')
        self.assertEqual(f.flowgram, [0.5, 1.0, 4.0, 0.0])
예제 #24
0
    def test_toSequenceCollection(self):
        """toSequenceCollection should return sequence collection from flows"""
        f = self.Class( [  '0.5 1.0 4.0 0.0 1.5 0.0 0.0 2.0',
                                     '1.5 1.0 0.0 0.0 2.5 1.0 2.0 1.0',
                                     '2.5 0.0 4.0 0.0 0.5 1.0 0.0 1.0',
                                     '0.0 1.0 0.0 3.0 1.5 1.0 1.0 2.0'                                  
                                     ], header_info = {'Flow Chars':'TACG'})
        s = f.toSequenceCollection()
        assert isinstance(s,SequenceCollection)
        for i,j in zip(s.iterSeqs(),['TACCCCTTGG','TTATTTACCG','TTTCCCCTAG',
                                   'AGGGTTACGG']):
            self.assertEqual(i,j)
            
        a = [Flowgram('0.5 1.0 4.0 0.0 1.5 0.0 0.0 2.0', Name='a',
                      header_info = {'Bases':'TACTTGG','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':'TTATTTG','Name Length':'14'})]

        f = self.Class(a)
        s = f.toSequenceCollection(Bases = True)
        assert isinstance(s,SequenceCollection)
        for i,j in zip(s.iterSeqs(),['TACTTGG','TTATTTG']):
            self.assertEqual(i,j)
예제 #25
0
    def test_toFasta(self):
        """Flowgram toFasta() should return Fasta-format string"""
        even = '0.5 1.0 4.0 0.0'
        odd = '0.5 1.0 4.0 1.0'
        even_f = Flowgram(even, Name='even', floworder="TACG")
        odd_f = Flowgram(odd, Name='odd', floworder="TACG")
        self.assertEqual(even_f.toFasta(), '>even\nTACCCC')
        #set line wrap to small number so we can test that it works
        self.assertEqual(even_f.toFasta(LineWrap=2), '>even\nTA\nCC\nCC')
        self.assertEqual(odd_f.toFasta(LineWrap=2), '>odd\nTA\nCC\nCC\nG')

        even_f = Flowgram(even,
                          Name='even',
                          floworder="TACG",
                          header_info={'Bases': 'TACCCG'})
        odd_f = Flowgram(odd,
                         Name='odd',
                         floworder="TACG",
                         header_info={'Bases': 'TACCCGG'})
        self.assertEqual(even_f.toFasta(), '>even\nTACCCG')
        #set line wrap to small number so we can test that it works
        self.assertEqual(even_f.toFasta(LineWrap=2), '>even\nTA\nCC\nCG')
        self.assertEqual(odd_f.toFasta(LineWrap=2), '>odd\nTA\nCC\nCG\nG')
예제 #26
0
    def test_average_flowgrams(self):
        """_average_flowgrams computes an averaged flowgram for each cluster."""

        fc = FlowgramCollection({
            'a': '1.0 0.0 0.0 1.0 1.0 1.2 1.2 0.8',
            'b': '1.2 1.0 0.0 0.8 1.2 2.4 1.0 0.0'
        })

        #return the centroid unmodified if sample_mapping = 1
        actual = list(_average_flowgrams({'a': 'b'}, fc, {'a': ['a']}))
        self.assertEqual(actual, [(fc.getFlow('a'), 'a')])

        actual = list(_average_flowgrams({'a': 'b'}, fc, {'a': ['a', 'b']}))
        self.assertEqual(
            actual, [(Flowgram(['1.1 0.5 0.0 0.9 1.1 1.8 1.1 0.4']), 'a')])
예제 #27
0
    def test_toSeq(self):
        """toSeq should Translate flowgram to sequence"""
        f = Flowgram('0.5 1.0 4.0 0.0',
                     Name='a',
                     floworder="TACG",
                     header_info={'Bases': 'TACCCG'})
        self.assertEqual(f.toSeq(), 'TACCCG')
        self.assertEqual(isinstance(f.toSeq(), Sequence), True)
        self.assertEqual(f.toSeq(Bases=False), 'TACCCC')

        f = Flowgram('0.5 1.0 4.0 0.0 0.0 1.23 0.0 6.1',
                     Name='a',
                     floworder="TACG",
                     header_info={'Bases': 'TACCCG'})
        self.assertEqual(f.toSeq(), 'TACCCG')
        self.assertEqual(f.toSeq(Bases=False), 'TACCCCAGGGGGG')

        f = Flowgram('0.5 1.0 4.0 0.0',
                     Name='a',
                     floworder="TACG",
                     header_info={})
        self.assertEqual(f.toSeq(), 'TACCCC')
        self.assertEqual(isinstance(f.toSeq(), Sequence), True)
        self.assertEqual(f.toSeq(Bases=False), 'TACCCC')

        f = Flowgram('0.5 1.0 4.0 0.0 0.0 1.23 0.0 6.1',
                     Name='a',
                     floworder="TACG",
                     header_info={})
        self.assertEqual(f.toSeq(Bases=True), 'TACCCCAGGGGGG')

        f = Flowgram('0.4 0.0 0.0 0.0 0.0 1.23 0.0 1.1',
                     Name='a',
                     floworder="TACG",
                     header_info={})
        self.assertEqual(f.toSeq(), 'NAG')
예제 #28
0
def parse_sff(lines):
    """Creates list of flowgram objects from a SFF file
    """
    head = get_header_info(lines)
    summaries = get_all_summaries(lines)

    flows = []
    for s in summaries:
        t = split_summary(s)
        flowgram = t["Flowgram"]
        del t["Flowgram"]
        flows.append(
            Flowgram(flowgram,
                     Name=t["Name"],
                     floworder=head["Flow Chars"],
                     header_info=t))
    return flows, head
예제 #29
0
    def test_getQualityTrimmedFlowgram(self):
        """getQualityTrimmedFlowgram trims the flowgram correctly"""
        f = Flowgram('0.5 1.0 4.1 0.0 0.0 1.23 0.0 3.1',
                     Name='a',
                     floworder="TACG",
                     header_info={
                         'Bases': 'TACCCCAGGG',
                         'Clip Qual Right': 7,
                         'Flow Indexes': "1\t2\t3\t3\t3\t3\t6\t8\t8\t8"
                     })
        trimmed = f.getQualityTrimmedFlowgram()

        self.assertEqual(trimmed.toSeq(), "TACCCCA")
        self.assertEqual(str(trimmed), "0.5\t1.0\t4.1\t0.0\t0.0\t1.23")

        # tests on real data
        flow1 = self.flows[0]
        flow2 = self.flows[1]

        flow1_trimmed = flow1.getQualityTrimmedFlowgram()
        self.assertEqual(
            str(flow1_trimmed),
            "1.06	0.08	1.04	0.08	0.05	0.94	0.10	2.01	0.10	0.07	0.96	0.09	1.04	1.96	1.07	0.10	1.01	0.13	0.08	1.01	1.06	1.83	2.89	0.18	0.96	0.13	0.99	0.11	1.94	0.12	0.13	1.92	0.21	0.07	0.94	0.17	0.03	0.97	2.76	0.15	0.05	1.02	1.14	0.10	0.98	2.54	1.13	0.96	0.15	0.21	1.90	0.16	0.07	1.78	0.22	0.07	0.93	0.22	0.97	0.08	2.02	0.15	0.19	1.02	0.19	0.09	1.02	0.17	0.99	0.09	0.18	1.84	0.16	0.91	0.10	1.10	1.00	0.20	0.09	1.11	3.01	1.07	1.98	0.14	0.22	1.09	0.17	1.99	0.15	0.20	0.92	0.17	0.07	1.01	2.96	0.15	0.07	1.06	0.20	1.00	0.10	0.12	1.00	0.15	0.08	1.90	0.19	0.10	0.99	0.18	0.09	0.99	1.08	0.15	0.07	1.06	0.14	1.84	0.13	0.11	0.95	1.05	0.13	1.04	1.10	0.18	0.94	0.14	0.10	0.97"
        )
        self.assertEqual(
            flow1_trimmed.Bases,
            "tcagGCTAACTGTAACCCTCTTGGCACCCACTAAACGCCAATCTTGCTGGAGTGTTTACCAGGCACCCAGCAATGTGAATAGTCA"
        )

        flow2_trimmed = flow2.getQualityTrimmedFlowgram()
        self.assertEqual(
            str(flow2_trimmed),
            "1.04	0.00	1.01	0.00	0.00	1.00	0.00	1.00	0.00	1.05	0.00	0.91	0.10	1.07	0.95	1.01	0.00	0.06	0.93	0.02	0.03	1.06	1.18	0.09	1.00	0.05	0.90	0.11	0.07	1.99	0.11	0.02	1.96	1.04	0.13	0.01	2.83	0.10	1.97	0.06	0.11	1.04	0.13	0.03	0.98	1.15	0.07	1.00	0.07	0.08	0.98	0.11	1.92	0.05	0.04	2.96	1.02	1.02	0.04	0.93	1.00	0.13	0.04	1.00	1.03	0.08	0.97	0.13	0.11	1.88	0.09	0.05	1.02	1.89	0.07	0.11	0.98	0.05	0.07	1.01	0.08	0.05	1.01	0.13	1.00	0.07	0.10	1.04	0.10	0.04	0.98	0.12	1.03	0.96	0.11	0.07	1.00	0.09	0.03	1.03	0.11	1.95	1.06	0.13	0.05	1.00	0.13	0.11	1.00	0.09	0.03	2.89	0.08	0.95	0.09	1.03	1.02	1.05	1.07	0.08	0.12	2.81	0.08	0.08	1.00	1.07	0.07	0.05	1.86	0.12	0.98	0.06	2.00	0.11	1.02	0.11	0.08	1.88	0.13	1.03	0.13	0.98	0.15	0.11	1.03	1.03	1.04	0.18	0.98	0.13	0.15	1.04	0.11	1.01	0.13	0.06	1.01	0.06	1.02	0.08	0.99	0.14	0.99	0.09	0.05	1.09	0.04	0.07	2.96	0.09	2.03	0.13	2.96	1.13	0.08	1.03	0.07	0.99	0.11	0.05	1.05	1.04	0.09	0.07	1.00	1.03	0.09	0.06	1.06	1.04	2.94	0.18	0.06	0.93	0.10	1.10	0.11	2.02	0.17	1.00	1.03	0.06	0.11	0.96	0.04	3.00	0.11	0.07	1.99	0.10	2.03	0.12	0.97	0.16	0.01	2.09	0.14	1.04	0.16	0.06	1.03	0.14	1.12	0.12	0.05	0.96	1.01	0.10	0.14	0.94	0.03	0.12	1.10	0.92	0.09	1.10	1.04	1.02	0.12	0.97	2.00	0.15	1.08	0.04	1.03	1.04	0.03	0.09	5.16	1.02	0.09	0.13	2.66	0.09	0.05	1.06	0.07	0.89	0.05	0.12	1.10	0.16	0.06	1.01	0.13	1.00	0.14	0.98	0.09	2.92	1.28	0.03	2.95	0.98	0.16	0.08	0.95	0.96	1.09	0.08	1.07	1.01	0.16	0.06	4.52	0.12	1.03	0.07	0.09	1.03	0.14	0.03	1.01	1.99"
        )
        self.assertEqual(
            flow2_trimmed.Bases,
            "tcagAGACGCACTCAATTATTTCCATAGCTTGGGTAGTGTCAATAATGCTGCTATGAACATGGGAGTACAAATATTCTTCAAGATACTGATCTCATTTCCTTTAGATATATACCCAGAAGTGAAATTCCTGGATCACATAGTAGTTCTATTTTTATTTGATGAGAAACTTTATACTATTTTTCATAA"
        )
예제 #30
0
flowgram = Flowgram("0.99	0.00	0.99	0.00	0.00	1.02	0.00	1.00	1.00	1.12\t\t"+\
                        "0.01	0.01	1.89	0.01	0.95	0.95	0.97	0.00	0.02	0.98\t"+\
                        "0.97	0.00	0.97	0.05	0.01	1.06	0.03	0.97	0.00	0.03\t"+\
                        "0.97	0.02	0.00	1.09	0.02	0.01	0.96	0.00	0.00	1.01\t"+\
                        "0.04	0.00	0.99	0.06	0.97	0.00	0.09	0.97	0.04	0.00\t"+\
                        "1.94	0.09	1.02	0.00	2.86	1.02	1.00	1.11	0.10	1.97\t"+\
                        "0.12	0.98	0.01	0.99	2.90	0.03	0.04	1.93	0.15	1.02\t"+\
                        "1.95	1.00	1.02	0.00	0.12	1.00	0.97	0.00	1.00	0.06\t"+\
                        "0.97	0.00	0.96	0.05	0.10	1.03	0.12	0.99	1.98	0.09\t"+\
                        "1.99	0.08	0.13	2.10	0.14	0.05	1.00	0.10	0.00	1.00\t"+\
                        "1.00	0.00	0.07	4.82	0.10	1.04	2.05	0.00	2.01	0.04\t"+\
                        "1.96	0.08	0.93	0.00	0.93	0.03	0.99	0.02	1.01	0.06\t"+\
                        "0.09	1.04	0.14	1.06	0.07	2.04	3.49	0.15	1.02	0.80\t"+\
                        "0.23	0.07	1.07	0.17	1.91	0.07	0.18	1.00	0.32	0.07\t"+\
                        "0.97	0.11	0.96	0.96	0.14	1.96	0.19	2.01	2.84	0.28\t"+\
                        "0.08	2.03	1.32	0.06	0.05	1.10	0.17	0.88	0.09	0.95\t"+\
                        "0.14	0.13	1.85	1.07	1.78	0.89	1.94	0.19	1.09	0.14\t"+\
                        "1.09	0.13	0.13	0.86	1.85	0.07	0.09	1.97	1.20	0.08\t"+\
                        "0.95	0.23	0.09	0.94	0.16	0.11	1.92	0.12	0.89	1.95\t"+\
                        "0.21	0.12	0.97	0.14	0.16	1.86	0.12	1.89	1.00	1.07\t"+\
                        "0.06	0.16	1.05	0.11	0.06	0.95	0.12	0.13	1.01	0.15\t"+\
                        "3.79	0.14	0.15	0.98	0.40	0.11	1.00	0.19	1.01	1.09\t"+\
                        "0.12	0.94	0.11	0.15	1.00	2.04	2.03	0.95	0.06	3.05\t"+\
                        "0.22	0.08	1.82	0.21	1.02	0.09	2.88	1.88	0.15	0.07\t"+\
                        "1.05	1.89	0.08	0.06	1.87	2.87	1.87	0.06	0.15	1.15\t"+\
                        "0.25	0.08	0.96	0.12	0.06	0.95	0.09	0.13	1.05	1.95\t"+\
                        "3.81	1.02	0.13	0.17	2.14	1.08	0.19	0.13	1.08	1.01\t"+\
                        "1.99	0.11	0.18	1.06	0.17	0.04	0.98	0.08	1.01	2.86\t"+\
                        "1.06	0.96	0.10	0.22	1.99	2.04	0.14	0.00	0.97	0.16\t"+\
                        "0.95	0.07	2.75	0.02	0.98	0.12	2.94	0.00	0.99	1.03\t"+\
                        "0.26	2.89	0.15	1.87	0.10	0.15	0.98	0.17	1.07	0.92\t"+\
                        "0.00	0.09	1.08	0.16	3.78	1.01	0.07	0.87	0.22	0.98\t"+\
                        "1.97	1.09	0.08	0.17	1.08	0.03	0.97	2.04	0.18	0.14\t"+\
                        "1.03	0.03	0.00	1.16	0.12	1.81	2.06	0.18	0.17	2.06\t"+\
                        "0.14	0.85	0.21	0.12	1.01	1.05	1.05	0.94	0.99	0.11\t"+\
                        "0.15	1.08	2.00	1.02	0.99	0.13	1.07	0.13	0.98	0.16\t"+\
                        "0.09	0.99	3.00	1.05	1.02	0.02	0.10	0.93	0.11	0.09\t"+\
                        "0.81	0.97	0.13	0.05	2.04	1.93	1.12	0.04	0.93	0.93\t"+\
                        "0.11	0.06	1.96	0.06	0.09	1.14	0.15	0.06	1.08	0.06\t"+\
                        "0.94	0.11	0.00	0.88	1.11	0.10	2.08	1.05	0.15	0.09")