greenelab / connectivity-search-backend

Django backend for hetnet connectivity search
https://search-api.het.io
BSD 3-Clause "New" or "Revised" License
6 stars 2 forks source link

random-node-pair endpoint for nodes with metapaths #48

Closed dhimmel closed 5 years ago

dhimmel commented 5 years ago

Response is like:

{
    "source_id": 28996,
    "target_id": 25994,
    "random_index": 45687697,
    "n_pathcounts": 1
}
dhimmel commented 5 years ago

As of https://github.com/greenelab/hetmech-backend/pull/48/commits/0b493648801f0a55de5157c0a53a960c5ceb346f, the output is like:

{
    "source_id": 28735,
    "target_id": 40330,
    "n_metapaths": 3,
    "pathcount_table_random_id": 154386408,
    "pathcount_table_max_id": 166199174
}

@vincerubinetti does this look good to you.

Also I posted the method for selecting a random instance from a Django model on StackOverflow.

dhimmel commented 5 years ago

It is also trivial to implement the following return structure which uses the existing NodeSerializer:

{
    "source": {
        "id": 20528,
        "identifier": "6927",
        "identifier_type": "int",
        "name": "HNF1A",
        "data": {
            "url": "http://identifiers.org/ncbigene/6927",
            "source": "Entrez Gene",
            "license": "CC0 1.0",
            "chromosome": "12",
            "description": "HNF1 homeobox A"
        },
        "metanode": "Gene"
    },
    "target": {
        "id": 2137,
        "identifier": "3554",
        "identifier_type": "int",
        "name": "IL1R1",
        "data": {
            "url": "http://identifiers.org/ncbigene/3554",
            "source": "Entrez Gene",
            "license": "CC0 1.0",
            "chromosome": "2",
            "description": "interleukin 1 receptor, type I"
        },
        "metanode": "Gene"
    },
    "n_metapaths": 1,
    "pathcount_table_random_id": 105421750,
    "pathcount_table_max_id": 166199174
}

@vincerubinetti do you prefer this?