示例#1
0
    def test_read_sequence_file(self):

        from barkley import seqrecs

        results = seqrecs.read_sequence_file(
            file_path=TARGET_FILE,
            file_format="fasta",
            ret_type="list",
            key="id",  # id gi description
            alphabet="dna",  # dna aa rna
        )

        sequence_str = "ATTTTACTCACCCACAAAGAAAATTCAAAAGTTTATTGTAGTAGAAATTATTATTACTATTATTAATCTA\
CAAAATGATGAAATCTCAAAAAAAATTGTTGATTAAGATTATTGTTGTACAATGTTTGTTAGTTCTTTGT\
GTTACATCACAAGACTTTGATTTCTTCTACTTTGTTCAACAGTGGCCAGCGTCTTATTGCGACACGAGGC\
GTAGTTGTTGTTATCCTACTACTGGAAAACCAGATGAAGATTTTAGTATTCATGGTCTATGGCCAAACTA\
CAAAGATGGTAAATGGCCACAAAATTGTGATAGGGAAAGCTCTTTGGATGAATCTGAGTTCTCAGATCTT\
ATAAGCACAATGGAAAAGAATTGGCCATCACTTGCTTGCCCTAGTAGTGATGGTTTAAAATTTTGGAGTC\
ATGAATGGCTAAAACATGGCACTTGTTCAGCTCTTAACCAACATGCCTATTTCCAAACTGCACTTGACTT\
CAAGACCAAATCTAACCTTCTTCAAAATCTTAACAATGCAGGGATTAAACCAAGGAATGGAGATTATTAT\
GGTGTAGAAAGCATTAAAAAGGCAATTGAAAAAGGAGTTGGACACACACCATTTATAGAGTGCAATGTTG\
ATTCACAAGGGAACCATCAATTATACCAAGTTTACCTATGTGTGGATTCTTCTGCATCAAAATTCATTGA\
TTGCCCAATTTTTCCACATGGAGGAAAATGTGGTTCAAAAATTGAATTCCCTTCTTTCTCCACAAATGAT\
GACCATGATGAATTTTAATTATTTTTATTAACTAATTAATTTCATCATGATCATATTGTTGATCTTTTAC\
ATTGTATTTTTAATAGGAACCCTTTCATATTTGTAATAAAATAAAATTTCATTCCAAAGGTAACAACATG\
CC"

        self.assertEqual(len(results), 1)
        self.assertEqual(str(results[0].seq), sequence_str)
示例#2
0
    def test_add_feature_to_record(self):

        from barkley import seqrecs
        from barkley import blast

        blast.make_blast_db(in_file_fasta=TARGET_FILE, db_name=BLAST_DB_NAME, out_dir=TEST_DATA_PATH)

        blast.run_blast(
            queries_file=QUERIES_FILE,
            results_file=BLAST_RESULTS_FILE,
            db=BLAST_DB_NAME,
            evalue=1e-1,
            program="blastn",
            task=None,
            blast_db_dir=TEST_DATA_PATH,
            output_format=5,
            num_threads=1,
        )

        blast_hits = blast.parse_blast_results_xml(file_name=BLAST_RESULTS_FILE)

        record = seqrecs.read_sequence_file(
            file_path=TARGET_FILE,
            file_format="fasta",
            ret_type="list",
            key="id",  # id gi description
            alphabet="dna",  # dna aa rna
        )[0]

        hsps = blast_hits["query_01"][0]

        for hsp in hsps:

            seqrecs.add_feature_to_record(
                record=record,
                f_start=hsp["sbjct_start"],
                f_end=hsp["sbjct_end"],
                f_strand=hsp["strand"],
                f_type="BLAST_HIT",
                f_qualifiers_dict=hsp,
            )

        # seqrecs.write_sequence_file(
        #     records=[record],
        #     file_path=TARGET_FILE_GB,
        #     file_format='genbank')

        self.assertEqual(len(record.features), 1)