Exemplo n.º 1
0
def convert(hca_data: dict):
    use_spec = deepcopy(spec)
    is_specimen = ('describedBy' in hca_data.get('biomaterial', {}).get(
        'content', {}) and get_concrete_type(
            hca_data['biomaterial']['content']['describedBy'])
                   == 'specimen_from_organism')

    if 'releaseDate' not in hca_data.get('project', {}):
        use_spec['releaseDate'] = ['biomaterial.submissionDate', format_date]

    if is_specimen and 'organ' in hca_data['biomaterial']['content']:
        use_spec['attributes']['Organ'] = [
            'biomaterial.content.organ', dsp_ontology
        ]

    converted_data = JsonMapper(hca_data).map(use_spec)

    if is_specimen and 'organ_parts' in hca_data['biomaterial']['content']:
        organ_parts = hca_data['biomaterial']['content']['organ_parts']
        if len(organ_parts) == 1:
            converted_data['attributes']['Organ Part'] = dsp_ontology(
                organ_parts[0])
        elif len(organ_parts) > 1:
            for index, organ_part in enumerate(organ_parts):
                converted_data['attributes'][
                    f'Organ Part - {index}'] = dsp_ontology(organ_parts[index])

    return converted_data
Exemplo n.º 2
0
 def convert(self, entity: Entity, xml_spec: dict = None) -> Element:
     if not xml_spec:
         xml_spec = deepcopy(self.xml_spec)
     self.add_alias(xml_spec, entity)
     xml_map = JsonMapper(entity.attributes).map(xml_spec)
     root = etree.Element(self.ena_type.upper())
     self.add_children(parent=root, children=xml_map)
     self.post_conversion(entity, root)
     return root
Exemplo n.º 3
0
def convert_sequencing_run(hca_data: dict):
    mapper = JsonMapper(hca_data)
    converted_data = mapper.map({
        '$on':
        'process',
        # being overwritten 'alias': ['uuid.uuid', prefix_with, _sq_run_alias_prefix],
        'title': ['content.process_core.process_name', default_to, ''],
        'description':
        ['content.process_core.process_description', default_to, ''],
        # being overwritten 'assayRefs': ['uuid.uuid', _sq_run_assay_ref]
    })

    converted_files = mapper.map({
        '$on': 'files',
        'name': ['content.file_core.file_name'],
        'format': ['content.file_core.format'],
        'uuid': ['uuid.uuid'],
        'lane_index': ['content.lane_index'],
        'read_index': ['content.read_index']
    })

    converted_data['attributes'] = _sq_run_file_attributes(converted_files)
    converted_data['files'] = _sq_run_files(converted_files, hca_data)
    return converted_data
Exemplo n.º 4
0
def convert_project(hca_data: dict):
    return JsonMapper(hca_data).map(project_spec)
Exemplo n.º 5
0
def convert_study(hca_data: dict):
    return JsonMapper(hca_data).map(study_spec)
Exemplo n.º 6
0
def convert_sequencing_experiment(hca_data: dict):
    return JsonMapper(hca_data).map(sq_experiment_spec)
Exemplo n.º 7
0
def convert(hca_data: dict):
    # added these for easier typing
    sp = 'sequencing_protocol'
    lp = 'library_preparation_protocol'
    ib = 'input_biomaterial'
    spec = {
        'alias': [f'{sp}.content.protocol_core.protocol_id'],
        'title': [f'{sp}.content.protocol_core.protocol_name'],
        'description': [f'{sp}.content.protocol_core.protocol_description'],
        'sampleUses':
        json_array({'sampleRef': {
            'alias': '{sampleAlias.placeholder}'
        }}),
        'studyRef':
        json_object({'alias': '{studyAlias.placeholder}'}),
        'attributes': {
            'HCA Input Biomaterial UUID': [f'{ib}.uuid.uuid', dsp_attribute],
            'HCA Library Preparation Protocol UUID':
            [f'{lp}.uuid.uuid', dsp_attribute],
            'HCA Process UUID': ['process.uuid.uuid', dsp_attribute],
            'HCA Sequencing Protocol UUID': [f'{sp}.uuid.uuid', dsp_attribute],
            'Input Biomaterial - Biomaterial Core - Biomaterial Id':
            [f'{ib}.content.biomaterial_core.biomaterial_id', dsp_attribute],
            'Input Biomaterial - Biomaterial Core - Ncbi Taxon Id - 0': [
                f'{ib}.content.biomaterial_core.ncbi_taxon_id',
                taxon_id_attribute
            ],
            'Library Preparation Protocol - End Bias':
            [f'{lp}.content.end_bias', dsp_attribute],
            'Library Preparation Protocol - Library Construction Method':
            [f'{lp}.content.library_construction_method', dsp_ontology],
            'Library Preparation Protocol - Nucleic Acid Source':
            [f'{lp}.content.nucleic_acid_source', dsp_attribute],
            'Library Preparation Protocol - Primer':
            [f'{lp}.content.primer', dsp_attribute],
            'Library Preparation Protocol - Protocol Core - Protocol Id':
            [f'{lp}.content.protocol_core.protocol_id', dsp_attribute],
            'Library Preparation Protocol - Strand':
            [f'{lp}.content.strand', dsp_attribute],
            'Process - Process Core - Process Id':
            ['process.content.process_core.process_id', dsp_attribute],
            'Sequencing Protocol - Paired End':
            [f'{sp}.content.paired_end', dsp_attribute],
            'Sequencing Protocol - Protocol Core - Protocol Id':
            [f'{sp}.content.protocol_core.protocol_id', dsp_attribute],
            'Sequencing Protocol - Sequencing Approach':
            [f'{sp}.content.sequencing_approach', dsp_ontology],
            'library_strategy': ['', fixed_dsp_attribute, 'OTHER'],
            'library_source': [
                '', fixed_dsp_attribute, 'TRANSCRIPTOMIC SINGLE CELL'
            ],
            'library_selection': [f'{lp}.content.primer', map_primer],
            'library_layout': [
                f'{sp}.content.paired_end', library_layout_attribute
            ],
            'library_name': [
                f'{ib}.content.biomaterial_core.biomaterial_id', dsp_attribute
            ],
            'instrument_model': [
                f'{sp}.content.instrument_manufacturer_model.text',
                instrument_model
            ],
            'platform_type': ['', fixed_dsp_attribute, 'ILLUMINA'],
            'design_description': ['', fixed_dsp_attribute, 'unspecified'],
            # TODO if library_layout is SINGLE, this is "0"
            'nominal_length': [f'{lp}.content.nominal_length', nominal_value],
            'nominal_sdev': [f'{lp}.content.nominal_sdev', nominal_value]
        }
    }

    return JsonMapper(hca_data).map(spec)
Exemplo n.º 8
0
 def convert_study(entity: Entity):
     submission_payload = JsonMapper(entity.attributes).map(BIO_STUDY_SPEC)
     return BioStudyConverter.__add_accession(entity, submission_payload)
Exemplo n.º 9
0
 def __add_attributes(sample: Sample, biomaterial: dict):
     converted_attributes = JsonMapper(biomaterial).map(ATTRIBUTE_SPEC)
     for name, value in converted_attributes.items():
         sample.attributes.append(Attribute(name, value))
     BioSamplesConverter.__add_project_attribute(sample)