def test_get_promoters(self): upstream_tss = 1000 downstream_tss = 50 seq_record = create_fake_record() genes, ignored_genes = cassis.ignore_overlapping( seq_record.get_genes()) # ignore ignored_genes # see cassis/promoterregions.png for details # [[start_prom1, end_prom1], [start_prom2, end_prom2], ...] expected_promoters = [ [0, 150], [301, 550], [1450, 1999], [2150, 3049], [4001, 4371], [8950, 9603], ] promoters = get_promoters(seq_record, genes, upstream_tss, downstream_tss) self.assertEqual(list(map(lambda x: [x.start, x.end], promoters)), expected_promoters) cassis.write_promoters_to_file(self.options.output_dir, seq_record.name, promoters) # read expected files and save to string variable expected_sequences_file = "" with open( path.get_full_path( __file__, "data", "expected_promoter_sequences.fasta")) as handle: expected_sequences_file = handle.read() expected_sequences_file = convert_newline( expected_sequences_file.rstrip()) expected_positions_file = "" with open( path.get_full_path( __file__, "data", "expected_promoter_positions.csv")) as handle: expected_positions_file = handle.read() expected_positions_file = convert_newline( expected_positions_file.rstrip()) # read test files and save to string variable sequences_file = "" with open( os.path.join(self.options.output_dir, seq_record.name + "_promoter_sequences.fasta")) as handle: sequences_file = handle.read() sequences_file = convert_newline(sequences_file.rstrip()) positions_file = "" with open( os.path.join(self.options.output_dir, seq_record.name + "_promoter_positions.csv")) as handle: positions_file = handle.read() positions_file = convert_newline(positions_file.rstrip()) self.assertEqual(sequences_file, expected_sequences_file) self.assertEqual(positions_file, expected_positions_file)
def test_ignore_overlapping(self): expected_not_ignored = ["gene1", "gene4", "gene5", "gene6", "gene7", "gene8", "gene9"] expected_ignored = ["gene2", "gene3"] seq_record = create_fake_record() not_ignored, ignored = cassis.ignore_overlapping(seq_record.get_genes()) self.assertEqual([x.locus_tag for x in ignored], expected_ignored) self.assertEqual([x.locus_tag for x in not_ignored], expected_not_ignored)