コード例 #1
0
 def test_mutation_site(self):
     mutation1 = "A"
     pos = 2
     snps_in_mind = ["A2G", "A2C", "A2T"]
     snp_output = RNAsnp.mutation_one_site(mutation1, pos)
     for snp in snps_in_mind:
         self.assertIn(snp, snp_output)
コード例 #2
0
 def test_mutation_site(self):
     mutation1 = "A"
     pos = 2
     snps_in_mind = ["A2G", "A2C", "A2T"]
     snp_output = RNAsnp.mutation_one_site(mutation1, pos)
     for snp in snps_in_mind:
         self.assertIn(snp, snp_output)
コード例 #3
0
    def test_rebuild_sequence(self):
        pass
        #give a sequence
        seq_given = "ATGTGTGCCCTTGAAACCCC"
        # here we build fake snp file
        tmp_file_name = "./fake_snp.rnasnp"
        tmp_file_with_line = "./snp_line.rnasnp"
        table_head = "SNP	w	Slen	GC	interval	d	pvalue1	ewin	interval	d_max	pvalue2"
        describe_line_one = "200	2463	0.5373	1-26	0.0361	0.0943	200	1-53	0.0072	0.4643"
        snp_line_picked_out = "200	2463	0.5373	1-26	0.0361	0.0943	200	1-53	0.0072	0.0643"
        p2_less = 0.0643
        line_num_pick = 9
        with open(tmp_file_name, "w") as snp_faker:
            snp_faker.write(table_head)

            snps = []
            for index_nt, nt in enumerate(seq_given):
                snps.extend(RNAsnp.mutation_one_site(nt, index_nt + 1))

            snp_faker.write("\n".join(snps))

        with open(tmp_file_with_line, "w") as snps_add_line:
            snps_add_line.write(table_head)

            snp_lines = []
            for snp in snps:
                if snps.index(snp) == line_num_pick:
                    snp_lines.append("\t".join([snp, snp_line_picked_out]))
                else:
                    snp_lines.append("\t".join([snp, describe_line_one]))

            snps_add_line.writelines("\n".join(snp_lines))

        # use this file as input for pyRNAsnp.get_snp_list.
        rebuilded_seq = RNAsnp.rebuild_seq(tmp_file_name)
        self.assertEqual(seq_given, rebuilded_seq)

        # test how to pick out a line with less p-value
        picked_collected = []
        with open(tmp_file_with_line, "r") as reader:
            for line in reader.readlines():
                parts = line.split()
                p2 = float(parts[-1])
                if p2 < 0.1:
                    print line
                    picked_collected.append(p2)

        self.assertIn(p2_less, picked_collected)
コード例 #4
0
    def test_rebuild_sequence(self):
        pass
        #give a sequence
        seq_given = "ATGTGTGCCCTTGAAACCCC"
        # here we build fake snp file
        tmp_file_name = "./fake_snp.rnasnp"
        tmp_file_with_line = "./snp_line.rnasnp"
        table_head = "SNP	w	Slen	GC	interval	d	pvalue1	ewin	interval	d_max	pvalue2"
        describe_line_one = "200	2463	0.5373	1-26	0.0361	0.0943	200	1-53	0.0072	0.4643"
        snp_line_picked_out = "200	2463	0.5373	1-26	0.0361	0.0943	200	1-53	0.0072	0.0643"
        p2_less = 0.0643
        line_num_pick = 9
        with open(tmp_file_name, "w") as snp_faker:
            snp_faker.write(table_head)

            snps = []
            for index_nt, nt in enumerate(seq_given):
                snps.extend(RNAsnp.mutation_one_site(nt, index_nt+1))

            snp_faker.write("\n".join(snps))

        with open(tmp_file_with_line, "w") as snps_add_line:
            snps_add_line.write(table_head)

            snp_lines = []
            for snp in snps:
                if snps.index(snp) == line_num_pick:
                    snp_lines.append("\t".join([snp, snp_line_picked_out]))
                else:
                    snp_lines.append("\t".join([snp, describe_line_one]))

            snps_add_line.writelines("\n".join(snp_lines))

        # use this file as input for pyRNAsnp.get_snp_list.
        rebuilded_seq = RNAsnp.rebuild_seq(tmp_file_name)
        self.assertEqual(seq_given, rebuilded_seq)

        # test how to pick out a line with less p-value
        picked_collected = []
        with open(tmp_file_with_line, "r") as reader:
            for line in reader.readlines():
                parts = line.split()
                p2 = float(parts[-1])
                if p2 < 0.1:
                    print line
                    picked_collected.append(p2)

        self.assertIn(p2_less, picked_collected)