Пример #1
0
def test_get_participants_by_pathway_returns_components_of_reaction_R_HSA_163750(
):
    df = get_participants_by_pathway("R-HSA-9634600", proteins)
    assert ((df['Id'] == "P67775") & (df['Role'] == "catalystActivity")).any()
    assert ((df['Id'] == "P30153") & (df['Role'] == "catalystActivity")).any()
    assert ((df['Id'] == "P16118") & (df['Role'] == "input")).any()
    assert ((df['Id'] == "P16118") & (df['Role'] == "output")).any()
def get_pathways_with_multiple_proteoforms(data_path, output_path):
    """
    Get list of pathways which contain proteins with multiple proteoforms
    """
    map_proteins_to_proteoforms = read_dictionary_one_to_set(
        data_path, "mapping_proteins_to_proteoforms.tsv", col_indices=(0, 1))

    # Create list of proteins that have multiple proteoforms
    selected_proteins = []
    for protein, proteoforms in map_proteins_to_proteoforms.items():
        if len(proteoforms) > 1:
            selected_proteins.append(protein)

    pathways = get_pathways()["stId"]  # Get complete list of pathways
    selected_pathways = []

    for pathway in pathways:
        participants = get_participants_by_pathway(pathway, config.proteins,
                                                   output_path)
        #     filename = get_json_filename(
        #         config.proteins, config.no_sm, output_path, pathway)
        #     if not Path(filename).exists():
        #         create_pathway_interaction_network(
        #             pathway, config.proteins, config.no_sm, output_path)
        #     G = read_graph(filename)
        if any(protein in selected_proteins
               for protein in set(participants["Id"])):
            selected_pathways.append(pathway)

    return selected_pathways
def create_pathway_interaction_network(pathway,
                                       level,
                                       method,
                                       out_path,
                                       v=True):
    """
    Get interaction network corresponding to a pathway for a certain entity level and desired method of construction.

    If the network does not exists it creates it and stores the file. 
    If the network file already exists it reads it and returns the data structure.
    """
    if level not in LEVELS:
        raise Exception(f"There is no {level} level.")

    filename = get_json_filename(level, method, out_path, pathway)
    if not Path(filename).exists():
        if v:
            print(f"    * Creating network {filename}")
        participants = {
            level: get_participants_by_pathway(pathway, level, out_path)
            for level in [level, sm]
        }
        components = {
            level: get_components_by_pathway(pathway, level, out_path)
            for level in [level, sm]
        }
        create_interaction_network(level, method, participants, components,
                                   out_path, pathway, False)
    # else:
    #     print(f"    * Network {filename} already exists..")
    G = read_graph(filename)

    missing_bridges = False
    missing_articulations = False
    if any("Bridge" not in G.edges[edge] for edge in G.edges):
        set_bridges(G)
        missing_bridges = True

    if any("Articulation Point" not in G.nodes[node] for node in G.nodes):
        set_articulation_points(G)

    if missing_articulations or missing_bridges:
        update_json_file(G, level, method, out_path, pathway)

    return G
Пример #4
0
def test_genes_no_sm_get_participants():
    participants = get_participants_by_pathway(genes, "R-HSA-9634600")
Пример #5
0
def glycolysis_genes_no_sm(glycolysis_get_participants):
    participants = get_participants_by_pathway(genes, "R-HSA-9634600")
    components = get_components(genes)
    return
Пример #6
0
def glycolysis_get_participants(tmpdir_factory):
    return get_participants_by_pathway(genes, "R-HSA-9634600")
Пример #7
0
def ras_processing_participants_sm():
    return get_participants_by_pathway("R-HSA-9648002", sm)
Пример #8
0
def ras_processing_participants_genes():
    return get_participants_by_pathway("R-HSA-9648002", genes)
Пример #9
0
def ras_processing_participants_proteoforms():
    return get_participants_by_pathway("R-HSA-9648002", proteoforms)
Пример #10
0
def glycolysis_participants_sm():
    return get_participants_by_pathway("R-HSA-70171", sm)
Пример #11
0
def glycolysis_participants_proteoforms():
    return get_participants_by_pathway("R-HSA-70171", proteoforms)
Пример #12
0
def participant_proteins_Erythrocytes_take_up_carbon_dioxide_and_release_oxygen(
):
    return get_participants_by_pathway("R-HSA-1237044", proteins)
Пример #13
0
def test_pathway_not_exists_returns_empty_dataframe():
    result = get_participants_by_pathway("blabla", genes)
    assert len(result) == 0
    assert type(result) == pd.DataFrame
    assert len(result.columns) == 0
Пример #14
0
def glycolysis_participants_genes():
    return get_participants_by_pathway("R-HSA-70171", genes)