def test_fa_to_bed(self): # test with and without offsets # start with block of FASTA formatted sequence: # two blocks on same chromosome # additional block on next chromosome # additional block on next chromosome # two blocks on chrA, one on chrB # test without offset self.maxDiff = None reader = cStringIO.StringIO(CROSSMAP_BLOCK) # test without offset blocks1 = list(fa_to_bed(reader, 25, offset=0)) self.assertListEqual(blocks1, CROSSMAP1) # test with offset reader = cStringIO.StringIO(CROSSMAP_BLOCK) blocks2 = list(fa_to_bed(reader, 25, offset=1000)) self.assertListEqual(blocks2, CROSSMAP2)
def test_fa_to_bed(self): # test with and without offsets # start with block of FASTA formatted sequence: # two blocks on same chromosome # additional block on next chromosome # additional block on next chromosome # two blocks on chrA, one on chrB # test without offset self.maxDiff = None reader = cStringIO.StringIO(CROSSMAP_BLOCK) # test without offset blocks1 = list(fa_to_bed(reader,25,offset=0)) self.assertListEqual(blocks1,CROSSMAP1) # test with offset reader = cStringIO.StringIO(CROSSMAP_BLOCK) blocks2 = list(fa_to_bed(reader,25,offset=1000)) self.assertListEqual(blocks2,CROSSMAP2)
def test_fa_to_bed_throws_expected_error(self): # test with and without offsets # start with unsorted FASTA block # grab chrA only and randomize order reads = cStringIO.StringIO(SHORT_FASTA_KMERS).read().split("\n") reads = reads[40:50] + reads[30:40] + reads[0:16] + reads[20:30] reads = "\n".join(reads) reader = cStringIO.StringIO(reads) # fa_to_bed is a generator, so we need to create a callable to make # it a list for it to actually raise the error tfunc = lambda x, y, z: list(fa_to_bed(x, y, offset=z)) self.assertRaises(MalformedFileError, tfunc, reader, 25, 0) reader = cStringIO.StringIO(reads) self.assertRaises(MalformedFileError, tfunc, reader, 25, 1000) reader = cStringIO.StringIO(reads) self.assertRaises(MalformedFileError, tfunc, reader, 15, 0)
def test_fa_to_bed_throws_expected_error(self): # test with and without offsets # start with unsorted FASTA block # grab chrA only and randomize order reads = cStringIO.StringIO(SHORT_FASTA_KMERS).read().split("\n") reads = reads[40:50] + reads[30:40] + reads[0:16] + reads[20:30] reads = "\n".join(reads) reader = cStringIO.StringIO(reads) # fa_to_bed is a generator, so we need to create a callable to make # it a list for it to actually raise the error tfunc = lambda x,y,z: list(fa_to_bed(x,y,offset=z)) self.assertRaises(MalformedFileError,tfunc,reader,25,0) reader = cStringIO.StringIO(reads) self.assertRaises(MalformedFileError,tfunc,reader,25,1000) reader = cStringIO.StringIO(reads) self.assertRaises(MalformedFileError,tfunc,reader,15,0)