Пример #1
0
    def get(self, datasetId, dataType):
        """
        Returns samples or metadata files for a dataset, expects: {dataset_id}/{data_type} where data_type is either 'samples' or 'metadata'.
        """
        ds = datasets.Dataset(datasetId)
        json_string = ds.isPrivate()
        json_object = json.loads(json_string)
        result = json_object[0]

        if result['datasets'][0]['private'] == True:
            return Response("Error: Private dataset",
                            mimetype="text/tsv",
                            headers={"Content-disposition": datasetId})

        if dataType == "samples":
            filename = 'attachment; filename=' + 'dataset_id_' + str(
                datasetId) + '_samples' + '.csv'
            json_string = ds.sampleTable().set_index("sample_id").to_csv()
            result = Response(json_string,
                              mimetype="text/csv",
                              headers={"Content-disposition": filename})
            return result

        elif dataType == "metadata":
            result = ds.metadataTable()
            return result
Пример #2
0
def getTable(datasetId, dataType):

    ds = datasets.Dataset(datasetId)
    json_string = ds.isPrivate()
    json_object = json.loads(json_string)
    result = json_object[0]

    if result['datasets'][0]['private'] == True:
        return Response("Error: Private dataset",
                        mimetype="text/tsv",
                        headers={"Content-disposition": datasetId})

    if dataType == "samples":
        filename = 'attachment; filename=' + 'dataset_id_' + str(
            datasetId) + '_samples' + '.csv'
        json_string = ds.sampleTable().set_index("sample_id").to_csv()
        result = Response(json_string,
                          mimetype="text/csv",
                          headers={"Content-disposition": filename})

    elif dataType == "metadata":
        result = ds.metadataTable()

    elif dataType == "expression":
        print("You chose expression")

    return result
Пример #3
0
def summary_table_search():
    data = request.get_json()
    payload = data['data']
    searchTerm = payload['searchTerm']
    datasetId = 1000
    ds = datasets.Dataset(datasetId)
    summaryTableSearch = ds.summaryTableSearch(str(searchTerm))
    return summaryTableSearch.to_json(orient="split")
Пример #4
0
def atlas_update():
    data = request.get_json()
    payload = data['data']
    print(payload)
    datasetId = payload['dataset_id']
    column = payload['column']
    rowIds = payload['rowIds']
    value = payload['value']
    ds = datasets.Dataset(datasetId)
    updateAtlasValue = ds.updateAtlasValue(column, rowIds, value)
    return updateAtlasValue
Пример #5
0
    def get(self, datasetId):
        """
        Returns samples or metadata files for a dataset, expects: {dataset_id}/{data_type} where data_type is either 'samples' or 'metadata'.
        """
        ds = datasets.Dataset(datasetId)
        json_string = ds.isPrivate()
        json_object = json.loads(json_string)
        result = json_object[0]

        if result['datasets'][0]['private'] == True:
            return Response("Private dataset"  , mimetype="text/tsv", headers={"Content-disposition": datasetId})
        elif result['datasets'][0]['private'] == False:
            return Response("Public dataset"  , mimetype="text/tsv", headers={"Content-disposition": datasetId})
Пример #6
0
def samples_grid():
    data = request.get_json()
    dataset_id = data['dataset_id']
    ds = datasets.Dataset(dataset_id)
    sampleTable = ds.sampleTable()
    jsonSampleTable = sampleTable.to_json(orient="split")

    if session["loggedIn"] == True:
        if jsonSampleTable != None:
            return jsonSampleTable
        else:
            return {
                "Message": "No samples found for dataset_id: " + dataset_id
            }
    else:
        return "Access Denied"
Пример #7
0
    def get(self, datasetId, key):
        """
        Returns expression files for a dataset, expects: {dataset_id}/{string} where string is either 'genes' or 'raw'.
        """
        dataType = "expression"
        key = key
        ds = datasets.Dataset(datasetId)
        json_string = ds.isPrivate()
        json_object = json.loads(json_string)
        result = json_object[0]

        print("debugging:")
        print(result)

        # if result['datasets'][0]['private'] == True:
        #     return Response("Error: Private dataset", mimetype="text/tsv", headers={"Content-disposition": datasetId})

        json_string = ds.expressionMatrix(key=key).to_json(orient="split")
        result = Response(json_string, mimetype="text/csv", headers={"Content-disposition": key})
        return result
Пример #8
0
def summary_table():
    datasetId = 1000
    ds = datasets.Dataset(datasetId)
    summaryTable = ds.summaryTable()
    dataset_id = summaryTable['dataset_id'].to_list()
    title = summaryTable['title'].to_list()
    authors = summaryTable['authors'].to_list()
    description = summaryTable['description'].to_list()
    generic_sample_type = summaryTable['generic_sample_type'].to_list()
    handle = summaryTable['handle'].to_list()

    date_list = []
    for item in handle:
        if item is not None:
            result = item.split("_")
            value = result[1]
            date_list.append(value)
    pubmed = summaryTable['pubmed'].to_list()

    obj_list = []
    for (a, b, c, d, e, f, g) in zip(dataset_id, title, authors, description,
                                     generic_sample_type, date_list, pubmed):
        obj = {
            "Dataset_id": a,
            "Title": b,
            "Authors": c,
            "Description": d,
            "generic_sample_type": e,
            "date": f,
            "pubmed": g
        }
        obj_list.append(obj)
    obj_list.pop(0)  # The first dict/item in the array is always null - remov.

    response_object = {"count": 10, "entries": obj_list}

    if session["loggedIn"] == True:
        return response_object
    else:
        return "Access Denied"
Пример #9
0
def atlas_samples_grid():

    data = request.get_json()
    atlas_type = data['atlas_type']
    atlas_model = atlas_type['atlas_model']
    atlas_project = atlas_type['tierModel']
    update_column = atlas_model + '_' + atlas_project
    dataset_id = data['dataset_id']
    ds = datasets.Dataset(dataset_id)
    atlasSampleTable = ds.atlasSampleTable()

    newdf = atlasSampleTable[['sample_id'] + [update_column] + [
        'annotator', 'evidence', 'phenotype', 'activation_status',
        'display_metadata', 'include_blood', 'include_imac'
    ]]  # construct a dataframe with the selected tier included in it.

    include_blood = newdf['include_blood'].unique()
    include_imac = newdf['include_imac'].unique()

    if include_blood[0] == False:
        print("drop all blood tier data")

        # finaldf = atlasSampleTable[['sample_id'] + [update_column] + ['annotator', 'evidence', 'phenotype', 'activation_status', 'display_metadata', 'include_blood', 'include_imac'] ]

    elif include_imac[0] == False:
        print("drop all imac tier data")

    elif include_blood[0] and include_imac[0] == False:
        print("drop all tier data")

    elif include_blood[0] and include_imac[0] == True:
        print("include all tier data")

    jsonSampleTable = newdf.to_json(orient="split")

    if session["loggedIn"] == True:
        return jsonSampleTable
    else:
        return "Access Denied"