1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616
|
__author__ = "Julia Goodrich"
__copyright__ = "Copyright 2007-2012, The Cogent Project"
__credits__ = ["Jens Reeder","Julia Goodrich"]
__license__ = "GPL"
__version__ = "1.5.3"
__maintainer__ = "Julia Goodrich"
__email__ = "julia.goodrich@colorado.edu"
__Status__ = "Development"
from cogent.util.unit_test import TestCase, main
from types import GeneratorType
from numpy import array, transpose
from cogent.core.sequence import Sequence
from cogent.parse.flowgram_collection import FlowgramCollection, flows_from_array,\
flows_from_generic,flows_from_kv_pairs,flows_from_empty,flows_from_dict,\
flows_from_sff,assign_sequential_names,flows_from_flowCollection,\
pick_from_prob_density, seqs_to_flows
from cogent.parse.flowgram import Flowgram
from cogent.core.alignment import SequenceCollection
from tempfile import mktemp
from os import remove
class flowgram_tests(TestCase):
"""Tests of top-level functions."""
def test_flows_from_array(self):
"""flows_from_array should return chars, and successive indices."""
a = array([[0,1,2],[2,1,0]]) #three 2-char seqs
obs_a, obs_labels, obs_info = flows_from_array(a)
#note transposition
self.assertEqual(obs_a, [array([0,2]), array([1,1]), array([2,0])])
self.assertEqual(obs_labels, None)
self.assertEqual(obs_info, None)
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])
def test_flows_from_flowCollection(self):
"""flows_from_flowCollection should init from existing collection"""
c = FlowgramCollection({'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_flowCollection(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])
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])
def test_flows_from_empty(self):
"""flowss_from_empty should always raise ValueError"""
self.assertRaises(ValueError, flows_from_empty, 'xyz')
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])
def test_pick_from_prob_density(self):
"""Should take bin probabilitys and bin size and return random"""
i = pick_from_prob_density([0,1.0,0,0],1)
self.assertEqual(i,1)
i = pick_from_prob_density([1.0,0,0,0],.01)
self.assertEqual(i,0.0)
def test_seqs_to_flows(self):
"""seqs_to_flows should take a list of seqs and probs and return """
seqs = [('a','ATCGT'), ('b','ACCCAG'), ('c','GTAATG')]
a = SequenceCollection(seqs)
flows = seqs_to_flows(a.items())
assert isinstance(flows,FlowgramCollection)
for f,i in zip(flows,['0.0 1.0 0.0 0.0 1.0 0.0 1.0 1.0 1.0 0.0 0.0 0.0',
'0.0 1.0 3.0 0.0 0.0 1.0 0.0 1.0',
'0.0 0.0 0.0 1.0 1.0 2.0 0.0 0.0 1.0 0.0 0.0 1.0']):
self.assertEqual(f,i)
probs ={0:[1.0,0,0,0,0],1:[0,1.0,0,0,0],2:[0,0,1.0,0,0],3:[0,0,0,1.0,0]}
flows = seqs_to_flows(a.items(), probs = probs, bin_size = 1.0)
assert isinstance(flows,FlowgramCollection)
for f,i in zip(flows,['0.0 1.0 0.0 0.0 1.0 0.0 1.0 1.0 1.0 0.0 0.0 0.0',
'0.0 1.0 3.0 0.0 0.0 1.0 0.0 1.0',
'0.0 0.0 0.0 1.0 1.0 2.0 0.0 0.0 1.0 0.0 0.0 1.0']):
self.assertEqual(f,i)
class FlowgramCollectionTests(TestCase):
"""Tests sff parser functions"""
Class = FlowgramCollection
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')
def test_init_pairs(self):
"""FlowgramCollection init from list of (key,val) should work"""
Flows = [['a','0.0 1.1 3.0 1.0'],['b','0.5 1.0 4.0 0.0']]
a = self.Class(Flows)
self.assertEqual(len(a.NamedFlows), 2)
self.assertEqual(a.NamedFlows['a'], '0.0 1.1 3.0 1.0')
self.assertEqual(a.NamedFlows['b'], '0.5 1.0 4.0 0.0')
self.assertEqual(a.Names, ['a','b'])
self.assertEqual(list(a.flows), ['0.0 1.1 3.0 1.0','0.5 1.0 4.0 0.0'])
def test_init_aln(self):
"""FlowgramCollection should init from existing Collections"""
start = self.Class([['a','0.0 1.1 3.0 1.0'],['b','0.5 1.0 4.0 0.0']])
exp = self.Class([['a','0.0 1.1 3.0 1.0'],['b','0.5 1.0 4.0 0.0']])
f = self.Class(start)
self.assertEqual(f, exp)
test_init_aln.__doc__ = Class.__name__ + test_init_aln.__doc__
def test_init_dict(self):
"""FlowgramCollection init from dict should work as expected"""
d = {'a':'0.0 1.1 3.0 1.0','b':'0.5 1.0 4.0 0.0'}
a = self.Class(d)
self.assertEqual(a, d)
self.assertEqual(a.NamedFlows.items(), d.items())
def test_init_name_mapped(self):
"""FlowgramCollection init should allow name mapping function"""
d = {'a':'0.0 1.1 3.0 1.0','b':'0.5 1.0 4.0 0.0'}
f = lambda x: x.upper()
a = self.Class(d, name_conversion_f=f)
self.assertNotEqual(a, d)
self.assertNotEqual(a.NamedFlows.items(), d.items())
d_upper = {'A':'0.0 1.1 3.0 1.0','B':'0.5 1.0 4.0 0.0'}
self.assertEqual(a, d_upper)
self.assertEqual(a.NamedFlows.items(), d_upper.items())
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'])
def test_flows_from_sff(self):
"""flow_from_sff should init from sff iterator"""
s = self.rec
f = self.Class(s)
self.assertEqual(f.NamedFlows['FIQU8OX05GCVRO'], self.flow)
def test_init_duplicate_keys(self):
"""FlowgramCollection init from kv pairs should fail on dup. keys"""
f = [['a','0.0 1.1 3.0 1.0'],['b','0.5 1.0 4.0 0.0'],
['b','1.5 2.0 0.0 0.5']]
self.assertRaises(ValueError, self.Class, f)
self.assertEqual(self.Class(f, remove_duplicate_names=True).Names,
['a','b'])
def test_init_ordered(self):
"""FlowgramCollection should iter over flows correctly, ordered too"""
first = self.ordered1
sec = self.ordered2
un = self.unordered
self.assertEqual(first.Names, ['a','b'])
self.assertEqual(sec.Names, ['b', 'a'])
self.assertEqual(un.Names, un.NamedFlows.keys())
first_list = list(first.flow_str)
sec_list = list(sec.flow_str)
un_list = list(un.flow_str)
self.assertEqual(first_list, ['0.0 1.1 3.0 1.0','0.5 1.0 4.0 0.0'])
self.assertEqual(sec_list, ['0.5 1.0 4.0 0.0', '0.0 1.1 3.0 1.0'])
#check that the unordered seq matches one of the lists
self.assertTrue((un_list == first_list) or (un_list == sec_list))
self.assertNotEqual(first_list, sec_list)
def test_flow_str(self):
"""FlowgramCollection flow_str prop returns flows in correct order."""
first = self.ordered1
sec = self.ordered2
un = self.unordered
first_list = list(first.flow_str)
sec_list = list(sec.flow_str)
un_list = list(un.flow_str)
self.assertEqual(first_list, ['0.0 1.1 3.0 1.0','0.5 1.0 4.0 0.0'])
self.assertEqual(sec_list, ['0.5 1.0 4.0 0.0', '0.0 1.1 3.0 1.0'])
#check that the unordered seq matches one of the lists
self.assertTrue((un_list == first_list) or (un_list == sec_list))
self.assertNotEqual(first_list, sec_list)
def test_iter(self):
"""FlowgramCollection __iter__ method should yield flows inorder"""
f = self.Class(['0.0 1.1 3.0 1.0','0.5 1.0 4.0 0.0','1.5 0.0 2.0 1.0'], \
Names=['a','b','c'])
for i,b in zip(f,['0.0 1.1 3.0 1.0','0.5 1.0 4.0 0.0',
'1.5 0.0 2.0 1.0']):
self.assertEqual(i,b)
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""")
def test_len(self):
"""len(FlowgramCollection) returns length of longest sequence"""
a = [('a','0.5 1.0 4.0 0.0 1.5 0.0 0.0 2.0'),
('b','1.5 1.0 0.0 0.0 2.5 1.0 2.0 1.0'),
('c','2.5 0.0 4.0 0.0 0.5 1.0 0.0 1.0')]
f = FlowgramCollection(a)
self.assertEqual(len(f), 3)
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)
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""")
def test_toFasta(self):
"""FlowgramCollection should return correct FASTA string"""
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'})
self.assertEqual(f.toFasta(), '>seq_0\nTACCCCTTGG\n>seq_1\nTTATTTACCG\n>seq_2\nTTTCCCCTAG\n>seq_3\nAGGGTTACGG')
#NOTE THE FOLLOWING SURPRISING BEHAVIOR BECAUSE OF THE TWO-ITEM
#SEQUENCE RULE:
aln = self.Class(['0.5 1.0 0.0 0.0','0.0 1.0 1.0 0.0'],
header_info = {'Flow Chars':'TACG'})
self.assertEqual(aln.toFasta(), '>A\nC\n>T\nA')
def test_toPhylip(self):
"""FlowgramCollection should return PHYLIP string format correctly"""
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'})
phylip_str, id_map = f.toPhylip()
self.assertEqual(phylip_str, """4 10\nseq0000001 TACCCCTTGG\nseq0000002 TTATTTACCG\nseq0000003 TTTCCCCTAG\nseq0000004 AGGGTTACGG""")
self.assertEqual(id_map, {'seq0000004':'seq_3', 'seq0000001':'seq_0', \
'seq0000003': 'seq_2', 'seq0000002': 'seq_1'})
def test_toNexus(self):
"""FlowgramCollection should return correct Nexus string format"""
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'})
expect = '#NEXUS\n\nbegin data;\n dimensions ntax=4 nchar=10;\n'+\
' format datatype=dna interleave=yes missing=? gap=-;\n'+\
' matrix\n seq_1 TTATTTACCG\n seq_0'+\
' TACCCCTTGG\n seq_3 AGGGTTACGG\n '+\
' seq_2 TTTCCCCTAG\n\n ;\nend;'
self.assertEqual(f.toNexus('dna'), expect)
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)
def test_addFlows(self):
"""addFlows should return an alignment with the new sequences appended"""
a = [('s4', '0.5 1.0 4.0 0.0 1.5 0.0 0.0 2.0'),
('s3', '1.5 1.0 0.0 0.0 2.5 1.0 2.0 1.0')]
b = [('s1','2.5 0.0 4.0 0.0 0.5 1.0 0.0 1.0'),
('s2', '0.0 1.0 0.0 3.0 1.5 1.0 1.0 2.0')]
f1 = self.Class(a, header_info = {'Flow Chars':'TACG'})
f2 = self.Class(b, header_info = {'Flow Chars':'TACG'})
self.assertEqual(f1.addFlows(f2).toFasta(),
self.Class(a+b, header_info = {'Flow Chars':'TACG'}).toFasta())
def test_iterFlows(self):
"""FlowgramCollection iterFlows() method should support reordering"""
f = self.Class(['0.0 1.1 3.0 1.0','0.5 1.0 4.0 0.0','1.5 0.0 2.0 1.0'], \
Names=['a','b','c'])
flows = map(str,list(f.iterFlows()))
self.assertEqual(flows, ['0.0\t1.1\t3.0\t1.0',
'0.5\t1.0\t4.0\t0.0','1.5\t0.0\t2.0\t1.0'])
flows = list(f.iterFlows(flow_order=['b','a','a']))
self.assertEqual(map(str,flows), ['0.5\t1.0\t4.0\t0.0',
'0.0\t1.1\t3.0\t1.0',
'0.0\t1.1\t3.0\t1.0'])
self.assertSameObj(flows[1], flows[2])
self.assertSameObj(flows[0], f.NamedFlows['b'])
def test_Items(self):
"""FlowgramCollection Items should iterate over items in specified order."""
#should work if one row
self.assertEqual(list(self.one_seq.Items), [0.0, 1.1, 3.0, 1.0])
#should take order into account
self.assertEqual(list(self.ordered1.Items),
[0.0, 1.1, 3.0, 1.0] + [0.5, 1.0, 4.0, 0.0])
self.assertEqual(list(self.ordered2.Items),
[0.5, 1.0, 4.0, 0.0] + [0.0, 1.1, 3.0, 1.0])
def test_takeFlows(self):
"""takeFlows should return new FlowgramCollection with selected seqs."""
f = self.Class(['0.0 1.1 3.0 1.0','0.5 1.0 4.0 0.0','1.5 0.0 2.0 1.0'], \
Names=['a','b','c'])
a = f.takeFlows('bc')
self.assertTrue(isinstance(a, FlowgramCollection))
self.assertEqual(a, {'b':'0.5 1.0 4.0 0.0','c':'1.5 0.0 2.0 1.0'})
#should be able to negate
a = f.takeFlows('bc', negate=True)
self.assertEqual(a, {'a':'0.0 1.1 3.0 1.0'})
def test_getFlowIndices(self):
"""FlowgramCollection getSeqIndices should return names of seqs where f(row) is True"""
f = self.ambiguous
is_long = lambda x: len(x) > 10
is_med = lambda x: len(str(x).replace('N','')) > 7 #strips gaps
is_any = lambda x: len(x) > 0
self.assertEqual(f.getFlowIndices(is_long,Bases = True), [])
f.Names = 'cba'
self.assertEqual(f.getFlowIndices(is_med,Bases = True), ['c','a'])
f.Names = 'bac'
self.assertEqual(f.getFlowIndices(is_med,Bases = True), ['a','c'])
self.assertEqual(f.getFlowIndices(is_any,Bases = True), ['b','a','c'])
#should be able to negate
self.assertEqual(f.getFlowIndices(is_med,Bases = True, negate=True),
['b'])
self.assertEqual(f.getFlowIndices(is_any, Bases = True,negate=True), [])
def test_takeFlowsIf(self):
"""FlowgramCollection takeFlowsIf should return flows where f(row) is True"""
is_long = lambda x: len(x) > 10
is_med = lambda x: len(str(x).replace('N','')) > 7
is_any = lambda x: len(x) > 0
f = self.ambiguous
self.assertEqual(f.takeFlowsIf(is_long, Bases = True), {})
self.assertEqual(f.takeFlowsIf(is_med, Bases = True), \
{'a':'0.5 1.0 4.0 0.0 1.5 0.0 0.0 2.0',
'c':'1.5 1.0 2.0 0.0 1.5 0.0 0.0 2.0'})
self.assertEqual(f.takeFlowsIf(is_any, Bases = True), f)
self.assertTrue(isinstance(f.takeFlowsIf(is_med, Bases = True),
FlowgramCollection))
#should be able to negate
self.assertEqual(f.takeFlowsIf(is_med, Bases = True,negate=True), \
{'b':'0.0 0.0 0.0 0.0 2.0 1.0 2.0 2.0'})
def test_getFlow(self):
"""FlowgramCollection.getFlow should return specified flow"""
a = [('a','0.5 1.0 4.0 0.0 1.5 0.0 0.0 2.0'),
('b','1.5 1.0 0.0 0.0 2.5 1.0 2.0 1.0'),
('c','2.5 0.0 4.0 0.0 0.5 1.0 0.0 1.0')]
f = FlowgramCollection(a)
self.assertEqual(f.getFlow('a'), '0.5 1.0 4.0 0.0 1.5 0.0 0.0 2.0')
self.assertRaises(KeyError, f.getFlow, 'd')
def test_getIntMap(self):
"""FlowgramCollection.getIntMap should return correct mapping."""
f = self.Class({'seq1':'0.5 1.0 2.0 0.0',
'seq2':'1.5 0.0 0.0 2.0','seq3':'0.0 3.0 0.1 1.0'})
int_keys = {'seq_0':'seq1','seq_1':'seq2','seq_2':'seq3'}
int_map = {'seq_0':'0.5 1.0 2.0 0.0','seq_1':'1.5 0.0 0.0 2.0',
'seq_2':'0.0 3.0 0.1 1.0'}
im,ik = f.getIntMap()
self.assertEqual(ik,int_keys)
self.assertEqual(im,int_map)
#test change prefix from default 'seq_'
prefix='seqn_'
int_keys = {'seqn_0':'seq1','seqn_1':'seq2','seqn_2':'seq3'}
int_map = {'seqn_0':'0.5 1.0 2.0 0.0','seqn_1':'1.5 0.0 0.0 2.0',
'seqn_2':'0.0 3.0 0.1 1.0'}
im,ik = f.getIntMap(prefix=prefix)
self.assertEqual(ik,int_keys)
self.assertEqual(im,int_map)
def test_toDict(self):
"""FlowgramCollection.toDict should return dict of strings (not obj)"""
f = self.Class({'a': '0.5 1.0 4.0 0.0 1.5 0.0 0.0 2.0'
, 'b': '1.5 1.0 0.0 0.0 2.5 1.0 2.0 1.0'})
self.assertEqual(f.toDict(), {'a':'0.5 1.0 4.0 0.0 1.5 0.0 0.0 2.0'
,'b':'1.5 1.0 0.0 0.0 2.5 1.0 2.0 1.0'})
for i in f.toDict().values():
assert isinstance(i, str)
def test_omitAmbiguousFlows(self):
"""FlowgramCollection omitAmbiguousFlows should return flows w/o N's"""
self.assertEqual(self.ambiguous.omitAmbiguousFlows(Bases=True),
{'a':'0.5 1.0 4.0 0.0 1.5 0.0 0.0 2.0',
'c':'1.5 1.0 2.0 0.0 1.5 0.0 0.0 2.0'})
self.assertEqual(self.ambiguous.omitAmbiguousFlows(Bases=False),
{'a':'0.5 1.0 4.0 0.0 1.5 0.0 0.0 2.0',
'c':'1.5 1.0 2.0 0.0 1.5 0.0 0.0 2.0'})
#check new object creation
self.assertNotSameObj(self.ambiguous.omitAmbiguousFlows(),
self.ambiguous)
self.assertTrue(isinstance(self.ambiguous.omitAmbiguousFlows(
Bases = True), FlowgramCollection))
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)
def setUp(self):
"""Define some standard data"""
self.rec = """Common Header:
Magic Number: 0x2E736666
Version: 0001
Index Offset: 96099976
Index Length: 1158685
# of Reads: 57902
Header Length: 440
Key Length: 4
# of Flows: 400
Flowgram Code: 1
Flow Chars: TACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACG
Key Sequence: TCAG
>FIQU8OX05GCVRO
Run Prefix: R_2008_10_15_16_11_02_
Region #: 5
XY Location: 2489_3906
Run Name: R_2008_10_15_16_11_02_FLX04070166_adminrig_1548jinnescurtisstanford
Analysis Name: /data/2008_10_15/R_2008_10_15_16_11_02_FLX04070166_adminrig_1548jinnescurtisstanford/D_2008_10_15_15_12_26_FLX04070166_1548jinnescurtisstanford_FullAnalysis
Full Path: /data/2008_10_15/R_2008_10_15_16_11_02_FLX04070166_adminrig_1548jinnescurtisstanford/D_2008_10_15_15_12_26_FLX04070166_1548jinnescurtisstanford_FullAnalysis
Read Header Len: 32
Name Length: 14
# of Bases: 104
Clip Qual Left: 5
Clip Qual Right: 85
Clip Adap Left: 0
Clip Adap Right: 0
Flowgram: 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 1.08 0.12 1.08 0.18 0.08 1.00 0.13 0.98 0.15 0.87 0.13 0.19 1.01 3.06 0.17 0.11 1.04 0.09 1.03 0.10 0.11 2.02 0.16 0.11 1.04 0.04 0.09 1.87 0.13 2.09 0.13 0.10 0.97 0.17 0.08 0.08 0.04 0.12 0.05 0.08 0.07 0.08 0.05 0.07 0.06 0.07 0.03 0.05 0.04 0.09 0.04 0.07 0.04 0.07 0.06 0.03 0.06 0.06 0.06 0.06 0.07 0.09 0.04 0.05 0.08 0.05 0.04 0.09 0.06 0.03 0.02 0.08 0.04 0.06 0.05 0.08 0.03 0.08 0.05 0.05 0.05 0.10 0.05 0.05 0.07 0.06 0.04 0.06 0.05 0.03 0.04 0.05 0.06 0.04 0.04 0.07 0.04 0.04 0.05 0.05 0.04 0.07 0.06 0.05 0.03 0.08 0.05 0.06 0.04 0.06 0.05 0.04 0.04 0.04 0.05 0.06 0.04 0.05 0.04 0.05 0.05 0.06 0.05 0.06 0.04 0.06 0.07 0.06 0.05 0.05 0.05 0.06 0.06 0.04 0.05 0.06 0.03 0.06 0.04 0.06 0.05 0.03 0.06 0.06 0.05 0.06 0.04 0.03 0.06 0.06 0.06 0.03 0.04 0.05 0.05 0.07 0.04 0.05 0.06 0.07 0.07 0.05 0.07 0.06 0.05 0.06 0.05 0.07 0.06 0.05 0.06 0.07 0.05 0.06 0.04 0.06 0.05 0.05 0.06 0.04 0.06 0.04 0.03 0.06 0.05 0.05 0.04 0.05 0.05 0.04 0.04 0.05 0.06 0.06 0.04 0.04 0.05 0.06 0.04 0.04 0.04 0.05 0.05 0.04 0.05 0.05 0.03 0.06 0.06 0.06 0.04 0.07 0.05 0.05 0.04 0.06 0.06 0.05 0.05 0.07 0.04 0.06 0.06 0.06 0.04 0.06 0.03 0.06 0.04 0.06 0.04 0.09 0.05 0.05 0.05 0.07 0.06 0.05 0.05 0.06 0.05 0.05 0.05 0.04 0.04 0.06 0.05 0.05 0.05 0.05 0.04 0.05 0.05 0.06 0.04 0.05 0.05 0.05 0.05 0.05 0.04 0.06 0.04 0.05 0.05 0.04 0.05 0.05 0.05 0.04
Flow Indexes: 1 3 6 8 8 11 13 14 14 15 17 20 21 22 22 23 23 23 25 27 29 29 32 32 35 38 39 39 39 42 43 45 46 46 46 47 48 51 51 54 54 57 59 61 61 64 67 69 72 72 74 76 77 80 81 81 81 82 83 83 86 88 88 91 94 95 95 95 98 100 103 106 106 109 112 113 116 118 118 121 122 124 125 127 130 131 133 136 138 140 143 144 144 144 147 149 152 152 155 158 158 160 160 163
Bases: tcagGCTAACTGTAACCCTCTTGGCACCCACTAAACGCCAATCTTGCTGGAGTGTTTACCAGGCACCCAGCAATGTGAATAGTCActgagcgggctggcaaggc
Quality Scores: 37 37 37 37 37 37 37 37 37 37 37 37 37 40 40 40 40 37 37 37 37 37 39 39 39 39 24 24 24 37 34 28 24 24 24 28 34 39 39 39 39 39 39 39 39 39 39 39 39 40 40 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37
>FIQU8OX05F8ILF
Run Prefix: R_2008_10_15_16_11_02_
Region #: 5
XY Location: 2440_0913
Run Name: R_2008_10_15_16_11_02_FLX04070166_adminrig_1548jinnescurtisstanford
Analysis Name: /data/2008_10_15/R_2008_10_15_16_11_02_FLX04070166_adminrig_1548jinnescurtisstanford/D_2008_10_15_15_12_26_FLX04070166_1548jinnescurtisstanford_FullAnalysis
Full Path: /data/2008_10_15/R_2008_10_15_16_11_02_FLX04070166_adminrig_1548jinnescurtisstanford/D_2008_10_15_15_12_26_FLX04070166_1548jinnescurtisstanford_FullAnalysis
Read Header Len: 32
Name Length: 14
# of Bases: 206
Clip Qual Left: 5
Clip Qual Right: 187
Clip Adap Left: 0
Clip Adap Right: 0
Flowgram: 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 1.05 0.14 1.03 0.13 0.03 1.10 0.10 0.96 0.11 0.99 0.12 0.05 0.94 2.83 0.14 0.12 0.96 0.00 1.00 0.11 0.14 1.98 0.08 0.11 1.04 0.01 0.11 2.03 0.15 2.05 0.10 0.03 0.93 0.01 0.08 0.12 0.00 0.16 0.05 0.07 0.08 0.11 0.07 0.05 0.04 0.10 0.05 0.05 0.03 0.07 0.03 0.04 0.04 0.06 0.03 0.05 0.04 0.09 0.03 0.08 0.03 0.07 0.02 0.05 0.02 0.06 0.01 0.05 0.04 0.06 0.02 0.04 0.04 0.04 0.03 0.03 0.06 0.06 0.03 0.02 0.02 0.08 0.03 0.01 0.01 0.06 0.03 0.01 0.03 0.04 0.02 0.00 0.02 0.05 0.00 0.02 0.02 0.03 0.00 0.02 0.02 0.04 0.01 0.00 0.01 0.05
Flow Indexes: 1 3 6 8 10 12 14 15 16 19 22 23 25 27 30 30 33 33 34 37 37 37 39 39 42 45 46 48 51 53 53 56 56 56 57 58 60 61 64 65 67 70 70 73 74 74 77 80 83 85 88 91 93 94 97 100 102 102 103 106 109 112 112 112 114 116 117 118 119 122 122 122 125 126 129 129 131 133 133 135 138 138 140 142 145 146 147 149 152 154 157 159 161 163 166 169 169 169 171 171 173 173 173 174 176 178 181 182 185 186 189 190 191 191 191 194 196 198 198 200 201 204 206 206 206 209 209 211 211 213 216 216 218 221 223 226 227 230 233 234 236 237 238 240 241 241 243 245 246 249 249 249 249 249 250 253 253 253 256 258 261 264 266 268 270 270 270 271 273 273 273 274 277 278 279 281 282 285 285 285 285 285 287 290 293 294 294 295 297 300 302 304 307 308 308 308 311 313 316 316 319 322 322 324 324 327
Bases: tcagAGACGCACTCAATTATTTCCATAGCTTGGGTAGTGTCAATAATGCTGCTATGAACATGGGAGTACAAATATTCTTCAAGATACTGATCTCATTTCCTTTAGATATATACCCAGAAGTGAAATTCCTGGATCACATAGTAGTTCTATTTTTATTTGATGAGAAACTTTATACTATTTTTCATAActgagcgggctggcaaggc
Quality Scores: 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 38 38 38 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 34 34 34 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 36 36 36 36 36 38 25 25 25 38 37 37 37 37 37 37 33 33 34 37 37 37 37 37 37 37 38 34 20 20 26 26 20 34 38 37 37 37 37 37 37 37 37 37 38 38 38 37 37 37 37 37 37 37 37 37 37
""".split('\n')
self.flow = """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 1.08 0.12 1.08 0.18 0.08 1.00 0.13 0.98 0.15 0.87 0.13 0.19 1.01 3.06 0.17 0.11 1.04 0.09 1.03 0.10 0.11 2.02 0.16 0.11 1.04 0.04 0.09 1.87 0.13 2.09 0.13 0.10 0.97 0.17 0.08 0.08 0.04 0.12 0.05 0.08 0.07 0.08 0.05 0.07 0.06 0.07 0.03 0.05 0.04 0.09 0.04 0.07 0.04 0.07 0.06 0.03 0.06 0.06 0.06 0.06 0.07 0.09 0.04 0.05 0.08 0.05 0.04 0.09 0.06 0.03 0.02 0.08 0.04 0.06 0.05 0.08 0.03 0.08 0.05 0.05 0.05 0.10 0.05 0.05 0.07 0.06 0.04 0.06 0.05 0.03 0.04 0.05 0.06 0.04 0.04 0.07 0.04 0.04 0.05 0.05 0.04 0.07 0.06 0.05 0.03 0.08 0.05 0.06 0.04 0.06 0.05 0.04 0.04 0.04 0.05 0.06 0.04 0.05 0.04 0.05 0.05 0.06 0.05 0.06 0.04 0.06 0.07 0.06 0.05 0.05 0.05 0.06 0.06 0.04 0.05 0.06 0.03 0.06 0.04 0.06 0.05 0.03 0.06 0.06 0.05 0.06 0.04 0.03 0.06 0.06 0.06 0.03 0.04 0.05 0.05 0.07 0.04 0.05 0.06 0.07 0.07 0.05 0.07 0.06 0.05 0.06 0.05 0.07 0.06 0.05 0.06 0.07 0.05 0.06 0.04 0.06 0.05 0.05 0.06 0.04 0.06 0.04 0.03 0.06 0.05 0.05 0.04 0.05 0.05 0.04 0.04 0.05 0.06 0.06 0.04 0.04 0.05 0.06 0.04 0.04 0.04 0.05 0.05 0.04 0.05 0.05 0.03 0.06 0.06 0.06 0.04 0.07 0.05 0.05 0.04 0.06 0.06 0.05 0.05 0.07 0.04 0.06 0.06 0.06 0.04 0.06 0.03 0.06 0.04 0.06 0.04 0.09 0.05 0.05 0.05 0.07 0.06 0.05 0.05 0.06 0.05 0.05 0.05 0.04 0.04 0.06 0.05 0.05 0.05 0.05 0.04 0.05 0.05 0.06 0.04 0.05 0.05 0.05 0.05 0.05 0.04 0.06 0.04 0.05 0.05 0.04 0.05 0.05 0.05 0.04"""
self.unordered = self.Class({'a':'0.0 1.1 3.0 1.0',
'b':'0.5 1.0 4.0 0.0'})
self.ordered1 = self.Class({'a':'0.0 1.1 3.0 1.0',\
'b':'0.5 1.0 4.0 0.0'}, Names=['a','b'])
self.ordered2 = self.Class({'a':'0.0 1.1 3.0 1.0',\
'b':'0.5 1.0 4.0 0.0'}, Names=['b','a'])
self.one_seq = self.Class({'a':'0.0 1.1 3.0 1.0'})
self.ambiguous = 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 0.0 0.0 0.0 2.0 1.0 2.0 2.0', Name = 'b',
header_info = {'Bases':'NTTACCGG'}),
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'})
if __name__ == "__main__":
main()
|