# Path: hgvs/utils/reftranscriptdata.py
# class RefTranscriptData(object):
#     def __init__(self, hdp, tx_ac, pro_ac):
#         """helper for generating RefTranscriptData from for c_to_p"""
#         tx_info = hdp.get_tx_identity_info(tx_ac)
#         tx_seq = hdp.get_seq(tx_ac)
# 
#         if tx_info is None or tx_seq is None:
#             raise HGVSDataNotAvailableError(
#                 "Missing transcript data for accession: {}".format(tx_ac))
# 
#         # use 1-based hgvs coords
#         cds_start = tx_info["cds_start_i"] + 1
#         cds_stop = tx_info["cds_end_i"]
# 
#         # coding sequences that are not divisable by 3 are not yet supported
#         tx_seq_to_translate = tx_seq[cds_start - 1:cds_stop]
#         if len(tx_seq_to_translate) % 3 != 0:
#             raise NotImplementedError(
#                 "Transcript {} is not supported because its sequence length of {} is not divisible by 3."
#                 .format(tx_ac, len(tx_seq_to_translate)))
# 
#         protein_seq = translate_cds(tx_seq_to_translate)
# 
#         if pro_ac is None:
#             # get_acs... will always return at least the MD5_ accession
#             # TODO: drop get_acs_for_protein_seq; use known mapping or digest (wo/pro ac inference)
#             pro_ac = (hdp.get_pro_ac_for_tx_ac(tx_ac)
#                       or hdp.get_acs_for_protein_seq(protein_seq)[0])
# 
#         self.transcript_sequence = tx_seq
#         self.aa_sequence = protein_seq
#         self.cds_start = cds_start
#         self.cds_stop = cds_stop
#         self.protein_accession = pro_ac


import os
import unittest
import hgvs.parser
import hgvs.utils.altseqbuilder as altseqbuilder
import support.mock_input_source as mock_input_data_source
from hgvs.utils.reftranscriptdata import RefTranscriptData
        hgvsc = "NM_999999.1:c.16_24dup"
        expected_sequence = "AAAATCAAAATGAAAGCGAAAGCGTTTCGCGCGTTTCGCGCGAAATAGGGG"
        self._run_comparison(hgvsc, expected_sequence)

    def test_delete_gene(self):
        hgvsc = "NM_999999.1:c.-3_*1del"
        expected_sequence = ""
        self._run_comparison(hgvsc, expected_sequence)

    def test_sequence_with_length_that_is_not_divisible_by_3(self):
        hgvsc = "NM_999992.2:c.1del"
        expected_sequence = "AAAATCAAATGGGGTAGGCCCGGCAGCCAGCTTTATAGAGGAGGCAGTTTCGCC"
        with self.assertRaises(NotImplementedError):
            ac_p = "DUMMY"
            var = self._parser.parse_hgvs_variant(hgvsc)
            transcript_data = RefTranscriptData(hdp=self._datasource, tx_ac=var.ac, pro_ac=ac_p)

    # def test_2_substitutions(self):
    #     pass
    #
    # def test_2_indel_no_net_frameshift(self):
    #     pass
    #
    # def test_2_indel_net_frameshift(self):
    #     pass

    def _run_comparison(self, hgvsc, expected_sequence):

        ac_p = "DUMMY"
        var = self._parser.parse_hgvs_variant(hgvsc)

# Path: hgvs/utils/reftranscriptdata.py
# class RefTranscriptData(object):
#     def __init__(self, hdp, tx_ac, pro_ac):
#         """helper for generating RefTranscriptData from for c_to_p"""
#         tx_info = hdp.get_tx_identity_info(tx_ac)
#         tx_seq = hdp.get_seq(tx_ac)
# 
#         if tx_info is None or tx_seq is None:
#             raise HGVSDataNotAvailableError(
#                 "Missing transcript data for accession: {}".format(tx_ac))
# 
#         # use 1-based hgvs coords
#         cds_start = tx_info["cds_start_i"] + 1
#         cds_stop = tx_info["cds_end_i"]
# 
#         # coding sequences that are not divisable by 3 are not yet supported
#         tx_seq_to_translate = tx_seq[cds_start - 1:cds_stop]
#         if len(tx_seq_to_translate) % 3 != 0:
#             raise NotImplementedError(
#                 "Transcript {} is not supported because its sequence length of {} is not divisible by 3."
#                 .format(tx_ac, len(tx_seq_to_translate)))
# 
#         protein_seq = translate_cds(tx_seq_to_translate)
# 
#         if pro_ac is None:
#             # get_acs... will always return at least the MD5_ accession
#             # TODO: drop get_acs_for_protein_seq; use known mapping or digest (wo/pro ac inference)
#             pro_ac = (hdp.get_pro_ac_for_tx_ac(tx_ac)
#                       or hdp.get_acs_for_protein_seq(protein_seq)[0])
# 
#         self.transcript_sequence = tx_seq
#         self.aa_sequence = protein_seq
#         self.cds_start = cds_start
#         self.cds_stop = cds_stop
#         self.protein_accession = pro_ac


# Path: tests/test_hgvs_variantmapper_cp_altseqbuilder.py
import os
import unittest
import hgvs.parser
import hgvs.utils.altseqbuilder as altseqbuilder
import support.mock_input_source as mock_input_data_source
from hgvs.utils.reftranscriptdata import RefTranscriptData

        hgvsc = "NM_999999.1:c.16_24dup"
        expected_sequence = "AAAATCAAAATGAAAGCGAAAGCGTTTCGCGCGTTTCGCGCGAAATAGGGG"
        self._run_comparison(hgvsc, expected_sequence)

    def test_delete_gene(self):
        hgvsc = "NM_999999.1:c.-3_*1del"
        expected_sequence = ""
        self._run_comparison(hgvsc, expected_sequence)

    def test_sequence_with_length_that_is_not_divisible_by_3(self):
        hgvsc = "NM_999992.2:c.1del"
        expected_sequence = "AAAATCAAATGGGGTAGGCCCGGCAGCCAGCTTTATAGAGGAGGCAGTTTCGCC"
        with self.assertRaises(NotImplementedError):
            ac_p = "DUMMY"
            var = self._parser.parse_hgvs_variant(hgvsc)
            transcript_data = RefTranscriptData(hdp=self._datasource, tx_ac=var.ac, pro_ac=ac_p)

    # def test_2_substitutions(self):
    #     pass
    #
    # def test_2_indel_no_net_frameshift(self):
    #     pass
    #
    # def test_2_indel_net_frameshift(self):
    #     pass

    def _run_comparison(self, hgvsc, expected_sequence):

        ac_p = "DUMMY"
        var = self._parser.parse_hgvs_variant(hgvsc)

        transcript_data = RefTranscriptData(hdp=self._datasource, tx_ac=var.ac, pro_ac=ac_p)