Ejemplo n.º 1
0
def test_outside_cds_description_model():
    p_c = position_convert(
        description_model=to_model("NG_012337.1:27"),
        to_selector_id="NM_003002.2",
    )
    assert model_to_string(
        p_c["converted_model"]) == "NG_012337.1(NM_003002.2):c.-5035"
Ejemplo n.º 2
0
def test_to_hgvs_locations_simple(hgvs, hgvs_internal_indexing):
    r_model = generate_references({
        "id": "t1",
        "type": "mRNA",
        "inverted": False,
        "exon": [(3, 6), (8, 13), (16, 21), (24, 26)],
        "cds": (10, 19),
    })
    append_transcript(
        r_model,
        {
            "id": "t2",
            "type": "ncRNA",
            "inverted": False,
            "exon": [(3, 6), (8, 13), (16, 21), (24, 26)],
        },
    )
    model_internal_indexing = to_model(hgvs_internal_indexing)
    model_hgvs = to_model(hgvs)
    if model_hgvs["coordinate_system"] in ["c", "n"]:
        to_selector_id = model_hgvs["reference"]["selector"]["id"]
    else:
        to_selector_id = None

    hgvs_conversion = model_to_string(
        to_hgvs_locations(
            model=model_internal_indexing,
            references=r_model,
            to_coordinate_system=model_hgvs["coordinate_system"],
            to_selector_id=to_selector_id,
            degenerate=True,
        ))

    assert hgvs_conversion == hgvs
Ejemplo n.º 3
0
def test_to_internal_locations(description_in, description_expected,
                               references):
    description_model = to_model(description_in)
    description_out = model_to_string(
        to_internal_indexing(
            to_internal_coordinates(description_model, references)))
    assert description_out == description_expected
Ejemplo n.º 4
0
def test_point_shift_from_positive_strand_ro_positive_strand():
    model = to_model("NG_012337.1:1005")
    model["variants"][0]["location"]["shift"] = 4
    p_c = position_convert(
        description_model=model,
        to_selector_id="NM_003002.2",
    )
    assert model_to_string(
        p_c["converted_model"]) == "NG_012337.1(NM_003002.2):c.-4057"
Ejemplo n.º 5
0
def test_outside_cds_segmented():
    p_c = position_convert(
        reference_id="NG_012337.1",
        from_selector_id=None,
        from_coordinate_system=None,
        position="27",
        to_coordinate_system=None,
        to_selector_id="NM_003002.2",
    )
    assert model_to_string(
        p_c["converted_model"]) == "NG_012337.1(NM_003002.2):c.-5035"
Ejemplo n.º 6
0
def test_point_shift_from_positive_strand_to_negative_strand():
    """
    NM_012459.2 is on the negative strand on NG_012337.1
    """
    model = to_model("NG_012337.1:1005")
    model["variants"][0]["location"]["shift"] = 4
    p_c = position_convert(
        description_model=model,
        to_selector_id="NM_012459.2",
    )
    assert model_to_string(
        p_c["converted_model"]) == "NG_012337.1(NM_012459.2):c.*2448"
Ejemplo n.º 7
0
def test_to_hgvs_locations(description_in, description_expected, references):
    model_internal_indexing = to_model(description_in)
    model_hgvs = to_model(description_expected)
    if model_hgvs["coordinate_system"] in ["c", "n"]:
        to_selector_id = model_hgvs["reference"]["selector"]["id"]
    else:
        to_selector_id = None

    hgvs_conversion = model_to_string(
        to_hgvs_locations(
            model=model_internal_indexing,
            references=references,
            to_coordinate_system=model_hgvs["coordinate_system"],
            to_selector_id=to_selector_id,
            degenerate=True,
        ))

    assert hgvs_conversion == description_expected
Ejemplo n.º 8
0
def test_to_internal_coordinates_simple(hgvs, hgvs_internal_indexing):
    d_m = to_model(hgvs)
    r_model = generate_references({
        "id": "t1",
        "type": "mRNA",
        "inverted": False,
        "exon": [(3, 6), (8, 13), (16, 21), (24, 26)],
        "cds": (10, 19),
    })
    append_transcript(
        r_model,
        {
            "id": "t2",
            "type": "ncRNA",
            "inverted": False,
            "exon": [(3, 6), (8, 13), (16, 21), (24, 26)],
        },
    )

    hgvs_internal_indexing_conversion = model_to_string(
        to_internal_indexing(to_internal_coordinates(d_m, r_model)))

    assert hgvs_internal_indexing_conversion == hgvs_internal_indexing
Ejemplo n.º 9
0
def test_description_to_model_to_description(description):
    """
    Check if the parsed model of a description is converted back to
    the initial description.
    """
    assert model_to_string(to_model(description)) == description
Ejemplo n.º 10
0
def test_model_to_string(model, description):
    assert model_to_string(model) == description