Exemplo n.º 1
0
def addSampleSummary(data):
    samples = data[SAMPLES]
    for sample in samples:
        biospecimenTermId = getFromDict(sample, BIOSPECIMEN_CLASS_PATH)
        if biospecimenTermId in SAMPLE_TYPE_MAPPING:
            sampleTypeVal = getFromDict(sample, SAMPLE_TYPE_MAPPING[biospecimenTermId])
            if TERM_LABEL in sampleTypeVal:
                summary = sampleTypeVal[TERM_LABEL]
                details = []

                try:
                    organismPart = getFromDict(sample, SAMPLE_ORGANISM_PART_PATH)
                    if summary != organismPart:
                        details.append(organismPart)
                except KeyError:
                    pass

                try:
                    sample_details = getFromDict(sample, SAMPLE_DETAILS_PATH)
                    details.append(sample_details)
                except KeyError:
                    pass

                if details:
                    summary = "{} ({})".format(summary, ', '.join(details))

                setInDict(sample, SAMPLE_TYPE_SUMMARY_PATH, summary)
        else:
            abort(400, 'Unexpected biospecimen_class term_id: ' + biospecimenTermId)
Exemplo n.º 2
0
def addTargetSummary(data):
    experiments = data[EXPERIMENTS]
    val = ''
    for exp in experiments:
        for path in EXPERIMENT_TARGET_PATHS:
            try:
                val = getFromDict(exp, path)
                break
            except KeyError:
                continue

        if val:
            details = ''
            try:
                details = getFromDict(exp, TARGET_DETAILS_PATH)
            except KeyError:
                pass

            if details:
                val += ' (' + details + ')'
            setInDict(exp, TARGET_SUMMARY_PATH, val)
Exemplo n.º 3
0
def generateTermLabels(data, appData):
    for category in data:
        if not isinstance(data[category], list):
            continue
        for item in data[category]:
            for path, ontologyUrls in appData.getPathsWithOntologyUrls():
                if path[0] != category:
                    continue

                try:
                    termIdVal = getFromDict(item, path[1:])
                except KeyError:
                    continue

                termLabelVal = searchOntologiesForTermId(tuple(ontologyUrls), termIdVal, appData)

                if termLabelVal:
                    setInDict(item, path[1:-1] + [TERM_LABEL], termLabelVal)
                else:
                    abort(400, 'Item ' + termIdVal + ' not found in ontologies ' + str(ontologyUrls)
                          + ' (path in json: ' + makeStrPathFromList(path, category) + ')')
Exemplo n.º 4
0
def addSpeciesName(data):
    samples = data[SAMPLES]
    for sample in samples:
        speciesId = getFromDict(sample, SPECIES_ID_PATH)
        speciesName = getSpeciesNameFromId(speciesId)
        setInDict(sample, SPECIES_NAME_PATH, speciesName)
Exemplo n.º 5
0
def addFileName(data):
    tracks = data[TRACKS]
    for track in tracks:
        fileUrl = getFromDict(track, TRACK_FILE_URL_PATH)
        fileName = getFilenameFromUrl(fileUrl)
        setInDict(track, TRACK_FILE_URL_PATH[:-1] + [FILE_NAME], fileName)