diff options
Diffstat (limited to 'scripts/uthsc_samples')
-rw-r--r-- | scripts/uthsc_samples/.gitignore | 1 | ||||
-rw-r--r-- | scripts/uthsc_samples/template.yaml | 35 | ||||
-rw-r--r-- | scripts/uthsc_samples/uthsc_samples.py | 59 |
3 files changed, 95 insertions, 0 deletions
diff --git a/scripts/uthsc_samples/.gitignore b/scripts/uthsc_samples/.gitignore new file mode 100644 index 0000000..8786e3f --- /dev/null +++ b/scripts/uthsc_samples/.gitignore @@ -0,0 +1 @@ +yaml diff --git a/scripts/uthsc_samples/template.yaml b/scripts/uthsc_samples/template.yaml new file mode 100644 index 0000000..07e0828 --- /dev/null +++ b/scripts/uthsc_samples/template.yaml @@ -0,0 +1,35 @@ +id: placeholder + +license: + license_type: https://creativecommons.org/licenses/by/4.0/ + title: "$strain" + attribution_name: "Mariah Taylor, Colleen B. Jonsson" + attribution_url: https://www.uthsc.edu/medicine/molecular-sciences/faculty-directory/jonsson.php + +host: + host_id: "$sample_id" + host_species: http://purl.obolibrary.org/obo/NCBITaxon_9606 + +sample: + sample_id: "$sample_id" + specimen_source: [http://purl.obolibrary.org/obo/NCIT_C155831] + collection_date: "$collection_date" + collection_location: $location + +virus: + virus_species: http://purl.obolibrary.org/obo/NCBITaxon_2697049 + virus_strain: "$strain" + +technology: + sample_sequencing_technology: [http://www.ebi.ac.uk/efo/EFO_0008632] + sequence_assembly_method: https://bio.tools/BWA#! + additional_technology_information: "Oxford Nanopore MiniIon RNA long reads" + +submitter: + authors: [Mariah Taylor, Colleen B. Jonsson] + submitter_name: [Mariah Taylor, Colleen B. Jonsson, Pjotr Prins] + submitter_address: UTHSC, Memphis, Tennessee 38163, USA + originating_lab: Regional Biocontainment Laboratory, Memphis, TN + provider_sample_id: $sample_id + submitter_sample_id: $sample_id + submitter_orcid: [https://orcid.org/0000-0002-2640-7672,https://orcid.org/0000-0002-8021-9162] diff --git a/scripts/uthsc_samples/uthsc_samples.py b/scripts/uthsc_samples/uthsc_samples.py new file mode 100644 index 0000000..54c70ee --- /dev/null +++ b/scripts/uthsc_samples/uthsc_samples.py @@ -0,0 +1,59 @@ +import os +import pandas as pd +from string import Template +from dateutil.parser import parse +import re + +import sys + +# Metadata in tabular format in a spreadsheet(?!) +xlsx = '../../test/data/10_samples.xlsx' + +# Template in a text file +template_yaml = 'template.yaml' + +dir_output = 'yaml' + +if not os.path.exists(dir_output): + os.makedirs(dir_output) + +table = pd.read_excel(xlsx) + +print(table) + +for index, row in table.iterrows(): + sample = row['Sample ID'] + print(f"Processing sample {sample}...") + + with open(template_yaml) as f: + text = Template(f.read()) + with open(os.path.join(dir_output,f"{sample}.yaml"), 'w') as fw: + sample_id = sample + sample_name = sample + collection_date = parse(str(row['Collection Date'])).strftime('%Y-%m-%d') + locationx = row['City']+", "+row['State']+", USA" + location = "http://www.wikidata.org/entity/Q16563" # Memphis by default + map = { + "Pegram": "http://www.wikidata.org/entity/Q3289517", + "Alexander": "http://www.wikidata.org/entity/Q79663", + "Smithville": "http://www.wikidata.org/entity/Q2145339", + "Nashville": "http://www.wikidata.org/entity/Q23197", + "Madison": "http://www.wikidata.org/entity/Q494755" + } + + for name in map: + p = re.compile(name) + if p.match(locationx): + location = map[name] + break + + strain = f"SARS-CoV-2/human/USA/{sample}/2020" + fw.write(text.substitute(sample_id=sample_id, + sample_name=sample_name, + collection_date=collection_date, + location=location, + locationx=locationx, + strain=strain + )) + + print(f"Run: python3 bh20sequploader/main.py scripts/uthsc_samples/yaml/{sample}.yaml scripts/uthsc_samples/yaml/{sample}.fa") |