aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorlltommy2020-07-07 23:58:50 +0200
committerlltommy2020-07-07 23:58:50 +0200
commitc8ffc952a99dc0a2d1266cdc0636711ec63e8bfb (patch)
treed8672cca90c8469f07c20cb80fdbf0439913623a /scripts
parent027d7bd6dd89c62a1e81bbda0e6ef7f27cbb3920 (diff)
parentb994b59963248a301e1248f792f21d9ab2ea8a3f (diff)
downloadbh20-seq-resource-c8ffc952a99dc0a2d1266cdc0636711ec63e8bfb.tar.gz
bh20-seq-resource-c8ffc952a99dc0a2d1266cdc0636711ec63e8bfb.tar.lz
bh20-seq-resource-c8ffc952a99dc0a2d1266cdc0636711ec63e8bfb.zip
Merge branch 'master' of https://github.com/arvados/bh20-seq-resource
Diffstat (limited to 'scripts')
-rw-r--r--scripts/create_sra_metadata/SraExperimentPackage.2020.07.05.xml.gzbin0 -> 6502056 bytes
-rw-r--r--scripts/create_sra_metadata/create_sra_metadata.py (renamed from scripts/download_sra_data/download_sra_data.py)52
-rw-r--r--scripts/dict_ontology_standardization/ncbi_countries.csv37
-rw-r--r--scripts/dict_ontology_standardization/ncbi_host_species.csv1
-rw-r--r--scripts/dict_ontology_standardization/ncbi_sequencing_technology.csv23
-rw-r--r--scripts/docker/Dockerfile4
-rwxr-xr-xscripts/download_genbank_data/from_genbank_to_fasta_and_yaml.py125
-rw-r--r--scripts/download_sra_data/SraExperimentPackage.2020.06.08.xml.gzbin3227724 -> 0 bytes
-rw-r--r--scripts/fetch_from_genbank.cwl49
-rw-r--r--scripts/import.cwl2
-rw-r--r--scripts/import_from_genbank.cwl27
-rw-r--r--scripts/import_to_arvados.py2
-rw-r--r--scripts/split_into_arrays.cwl30
-rw-r--r--scripts/upload.cwl13
14 files changed, 284 insertions, 81 deletions
diff --git a/scripts/create_sra_metadata/SraExperimentPackage.2020.07.05.xml.gz b/scripts/create_sra_metadata/SraExperimentPackage.2020.07.05.xml.gz
new file mode 100644
index 0000000..88acb18
--- /dev/null
+++ b/scripts/create_sra_metadata/SraExperimentPackage.2020.07.05.xml.gz
Binary files differ
diff --git a/scripts/download_sra_data/download_sra_data.py b/scripts/create_sra_metadata/create_sra_metadata.py
index 9145a43..ef0d119 100644
--- a/scripts/download_sra_data/download_sra_data.py
+++ b/scripts/create_sra_metadata/create_sra_metadata.py
@@ -8,9 +8,11 @@ import gzip
dir_yaml = 'yaml'
-date = '2020.06.08'
+date = '2020.07.05'
-# Query on SRA: 'txid2697049[Organism]' (https://www.ncbi.nlm.nih.gov/sra/?term=txid2697049%5BOrganism%5D) -> Send to -> File -> Full XML -> Create File
+# Query on SRA: 'txid2697049[Organism]' (https://www.ncbi.nlm.nih.gov/sra/?term=txid2697049%5BOrganism%5D)
+# Query on SRA: 'txid2697049[Organism:noexp] NOT 0[Mbases ' (https://www.ncbi.nlm.nih.gov/sra/?term=txid2697049%5BOrganism:noexp%5D%20NOT%200[Mbases)
+# -> Send to -> File -> Full XML -> Create File
path_sra_metadata_xml = 'SraExperimentPackage.{}.xml.gz'.format(date)
dir_dict_ontology_standardization = '../dict_ontology_standardization/'
@@ -70,14 +72,14 @@ for i, EXPERIMENT_PACKAGE in enumerate(EXPERIMENT_PACKAGE_SET):
accession = RUN.attrib['accession']
run_accession_set.add(accession)
#print(accession)
-
+
info_for_yaml_dict['sample']['sample_id'] = accession
- SRAFiles = RUN.find('SRAFiles')
- if SRAFiles is not None:
- url = SRAFiles.find('SRAFile').attrib['url']
- if 'sra-download.ncbi.nlm.nih.gov' in url:
- run_accession_to_downloadble_file_url_dict[accession] = url
+ #SRAFiles = RUN.find('SRAFiles')
+ #if SRAFiles is not None:
+ # url = SRAFiles.find('SRAFile').attrib['url']
+ # if 'sra-download.ncbi.nlm.nih.gov' in url:
+ # run_accession_to_downloadble_file_url_dict[accession] = url
SAMPLE = EXPERIMENT_PACKAGE.find('SAMPLE')
@@ -90,6 +92,9 @@ for i, EXPERIMENT_PACKAGE in enumerate(EXPERIMENT_PACKAGE_SET):
VALUE_text = VALUE.text
if TAG_text in ['host', 'host scientific name']:
+ if VALUE_text.lower() in ['homo sapien', 'homosapiens']:
+ VALUE_text = 'Homo sapiens'
+
if VALUE_text in term_to_uri_dict:
info_for_yaml_dict['host']['host_species'] = term_to_uri_dict[VALUE_text]
else:
@@ -100,11 +105,19 @@ for i, EXPERIMENT_PACKAGE in enumerate(EXPERIMENT_PACKAGE_SET):
elif VALUE_text.strip("'") not in ['missing', 'not collected', 'not provided']:
missing_value_list.append('\t'.join([accession, 'host_health_status', VALUE_text]))
elif TAG_text in ['strain', 'isolate']:
- if VALUE_text.lower() not in ['not applicable', 'missing', 'na', 'unknown']:
- if 'virus_strain' not in info_for_yaml_dict:
- info_for_yaml_dict['virus']['virus_strain'] = VALUE_text
+ if VALUE_text.lower() not in ['not applicable', 'missing', 'na', 'unknown', 'not provided']:
+ value_to_insert = VALUE_text
+
+ if value_to_insert.lower() in ['homo sapien', 'homosapiens']:
+ value_to_insert = 'Homo sapiens'
+
+ if value_to_insert in term_to_uri_dict:
+ value_to_insert = term_to_uri_dict[value_to_insert]
+
+ if 'virus_strain' not in info_for_yaml_dict:
+ info_for_yaml_dict['virus']['virus_strain'] = value_to_insert
else:
- info_for_yaml_dict['virus']['virus_strain'] += '; ' + VALUE_text
+ info_for_yaml_dict['virus']['virus_strain'] += '; ' + value_to_insert
elif TAG_text in ['isolation_source', 'isolation source host-associated']:
if VALUE_text in term_to_uri_dict:
info_for_yaml_dict['sample']['specimen_source'] = [term_to_uri_dict[VALUE_text]]
@@ -179,17 +192,18 @@ for i, EXPERIMENT_PACKAGE in enumerate(EXPERIMENT_PACKAGE_SET):
EXPERIMENT = EXPERIMENT_PACKAGE.find('EXPERIMENT')
INSTRUMENT_MODEL = [x.text for x in EXPERIMENT.find('PLATFORM').iter('INSTRUMENT_MODEL')][0]
+
if INSTRUMENT_MODEL.lower() != 'unspecified':
if INSTRUMENT_MODEL in term_to_uri_dict:
info_for_yaml_dict['technology']['sample_sequencing_technology'] = [term_to_uri_dict[INSTRUMENT_MODEL]]
else:
missing_value_list.append('\t'.join([accession, 'sample_sequencing_technology', INSTRUMENT_MODEL]))
-
+ #else:
+ # print(accession, 'Missing INSTRUMENT_MODEL', info_for_yaml_dict)
LIBRARY_DESCRIPTOR = EXPERIMENT.find('DESIGN').find('LIBRARY_DESCRIPTOR')
if LIBRARY_DESCRIPTOR.text not in ['OTHER']:
info_for_yaml_dict['technology']['additional_technology_information'] = 'LIBRARY_STRATEGY: {};'.format(LIBRARY_DESCRIPTOR.find('LIBRARY_STRATEGY').text)
-
-
+
SUBMISSION = EXPERIMENT_PACKAGE.find('SUBMISSION')
info_for_yaml_dict['submitter']['submitter_sample_id'] = SUBMISSION.attrib['accession']
@@ -197,7 +211,7 @@ for i, EXPERIMENT_PACKAGE in enumerate(EXPERIMENT_PACKAGE_SET):
info_for_yaml_dict['submitter']['originating_lab'] = SUBMISSION.attrib['lab_name']
STUDY = EXPERIMENT_PACKAGE.find('STUDY')
- info_for_yaml_dict['submitter']['publication'] = SUBMISSION.attrib['lab_name']
+ info_for_yaml_dict['submitter']['publication'] = STUDY.attrib['alias']
Organization = EXPERIMENT_PACKAGE.find('Organization')
@@ -222,6 +236,10 @@ for i, EXPERIMENT_PACKAGE in enumerate(EXPERIMENT_PACKAGE_SET):
info_for_yaml_dict['sample']['collection_date'] = '1970-01-01'
info_for_yaml_dict['sample']['additional_collection_information'] = "The real 'collection_date' is missing"
+ if 'sample_sequencing_technology' not in info_for_yaml_dict['technology']:
+ print(accession, ' - technology not found')
+ continue
+
with open(os.path.join(dir_yaml, '{}.yaml'.format(accession)), 'w') as fw:
json.dump(info_for_yaml_dict, fw, indent=2)
@@ -229,4 +247,4 @@ if len(missing_value_list) > 0:
path_missing_terms_tsv = 'missing_terms.tsv'
print('Written missing terms in {}'.format(path_missing_terms_tsv))
with open(path_missing_terms_tsv, 'w') as fw:
- fw.write('\n'.join(missing_value_list)) \ No newline at end of file
+ fw.write('\n'.join(missing_value_list))
diff --git a/scripts/dict_ontology_standardization/ncbi_countries.csv b/scripts/dict_ontology_standardization/ncbi_countries.csv
index 204f7f2..4bea3ec 100644
--- a/scripts/dict_ontology_standardization/ncbi_countries.csv
+++ b/scripts/dict_ontology_standardization/ncbi_countries.csv
@@ -284,6 +284,7 @@ USA:CA,http://www.wikidata.org/entity/Q99
USA: California,http://www.wikidata.org/entity/Q99
USA:California,http://www.wikidata.org/entity/Q99
"USA: CA, San Diego County",http://www.wikidata.org/entity/Q108143
+"USA: California, Monterey County",http://www.wikidata.org/entity/Q108072
USA: CO,http://www.wikidata.org/entity/Q1261
USA: CT,http://www.wikidata.org/entity/Q779
USA: Connecticut,http://www.wikidata.org/entity/Q779
@@ -301,8 +302,9 @@ USA: IN,http://www.wikidata.org/entity/Q1415
USA: KS,http://www.wikidata.org/entity/Q1558
USA: KY,http://www.wikidata.org/entity/Q1603
USA: LA,http://www.wikidata.org/entity/Q1588
-USA:Los Angeles,http://www.wikidata.org/entity/Q65
-"USA: New Orleans, LA",http://www.wikidata.org/entity/Q34404
+"USA: SLIDELL, LA, LA",https://www.wikidata.org/wiki/Q988156
+"USA: Slidell, LA, LA",https://www.wikidata.org/wiki/Q988156
+"USA: New Orleans, LA",https://www.wikidata.org/wiki/Q34404
USA: MA,http://www.wikidata.org/entity/Q771
USA: Massachusetts,http://www.wikidata.org/entity/Q771
USA: MD,http://www.wikidata.org/entity/Q1391
@@ -336,6 +338,33 @@ USA: SC,http://www.wikidata.org/entity/Q1456
USA: South Carolina,http://www.wikidata.org/entity/Q1456
USA: SD,http://www.wikidata.org/entity/Q1211
"USA: Snohomish County, WA",http://www.wikidata.org/entity/Q110403
+"USA: Washington,Snohomish County",http://www.wikidata.org/entity/Q110403
+"USA: Washington, Snohomish County",http://www.wikidata.org/entity/Q110403
+"USA: Washington,Skagit County",http://www.wikidata.org/entity/Q113892
+"USA: Washington, Skagit County",http://www.wikidata.org/entity/Q113892
+"USA: Washington,Pierce County",http://www.wikidata.org/entity/Q156459
+"USA: Washington, Pierce County",http://www.wikidata.org/entity/Q156459
+"USA: Washington,Mason County",http://www.wikidata.org/entity/Q111904
+"USA: Washington, Mason County",http://www.wikidata.org/entity/Q111904
+"USA: Washington,Kittitas County",http://www.wikidata.org/entity/Q111540
+"USA: Washington,King County",http://www.wikidata.org/entity/Q108861
+"USA: Washington, King County",http://www.wikidata.org/entity/Q108861
+"USA: King County,WA",http://www.wikidata.org/entity/Q108861
+"USA: Washington,Jefferson County",http://www.wikidata.org/entity/Q384737
+"USA: Washington,Grant County",http://www.wikidata.org/entity/Q281681
+"USA: Washington, Grant County",http://www.wikidata.org/entity/Q281681
+"USA: Washington,Franklin County",http://www.wikidata.org/entity/Q118716
+"USA: Washington, Franklin County",http://www.wikidata.org/entity/Q118716
+"USA: Washington,Clark County",http://www.wikidata.org/entity/Q156287
+"USA: Washington,Benton County",http://www.wikidata.org/entity/Q156216
+"USA: Washington, Benton County",http://www.wikidata.org/entity/Q156216
+"USA: Washington,Asotin County",http://www.wikidata.org/entity/Q156295
+"USA: Washington, Asotin County",http://www.wikidata.org/entity/Q156295
+"USA: Washington,Adams County",http://www.wikidata.org/entity/Q156273
+"USA: Washington, Adams County",http://www.wikidata.org/entity/Q156273
+"USA: Washington, Spokane County",http://www.wikidata.org/entity/Q485276
+"USA: Washington, Douglas County",http://www.wikidata.org/entity/Q156220
+"USA: Washington, Cowlitz County",http://www.wikidata.org/entity/Q156276
USA: TN,http://www.wikidata.org/entity/Q1509
USA: TX,http://www.wikidata.org/entity/Q1439
USA: UT,http://www.wikidata.org/entity/Q829
@@ -347,6 +376,10 @@ USA: WA,http://www.wikidata.org/entity/Q1223
USA: Washington,http://www.wikidata.org/entity/Q1223
USA: WI,http://www.wikidata.org/entity/Q1537
USA: Wisconsin,http://www.wikidata.org/entity/Q1537
+"USA: Washington,Yakima County",http://www.wikidata.org/entity/Q156629
+"USA: Washington, Yakima County",http://www.wikidata.org/entity/Q156629
+"USA: Washington,Whatcom County",http://www.wikidata.org/entity/Q156623
+"USA: Dane County, Wisconsin",http://www.wikidata.org/entity/Q502200
USA: WV,http://www.wikidata.org/entity/Q1371
USA: WY,http://www.wikidata.org/entity/Q1214
Uzbekistan,http://www.wikidata.org/entity/Q265
diff --git a/scripts/dict_ontology_standardization/ncbi_host_species.csv b/scripts/dict_ontology_standardization/ncbi_host_species.csv
index bc6ac04..40572a3 100644
--- a/scripts/dict_ontology_standardization/ncbi_host_species.csv
+++ b/scripts/dict_ontology_standardization/ncbi_host_species.csv
@@ -5,5 +5,6 @@ sapiens,http://purl.obolibrary.org/obo/NCBITaxon_9606
Mustela lutreola,http://purl.obolibrary.org/obo/NCBITaxon_9666
Manis javanica,http://purl.obolibrary.org/obo/NCBITaxon_9974
Felis catus,http://purl.obolibrary.org/obo/NCBITaxon_9685
+Felis catus; Domestic Shorthair,http://purl.obolibrary.org/obo/NCBITaxon_9685
Panthera tigris jacksoni,http://purl.obolibrary.org/obo/NCBITaxon_419130
Canis lupus familiaris,http://purl.obolibrary.org/obo/NCBITaxon_9615
diff --git a/scripts/dict_ontology_standardization/ncbi_sequencing_technology.csv b/scripts/dict_ontology_standardization/ncbi_sequencing_technology.csv
index 964cbf3..59c4800 100644
--- a/scripts/dict_ontology_standardization/ncbi_sequencing_technology.csv
+++ b/scripts/dict_ontology_standardization/ncbi_sequencing_technology.csv
@@ -13,12 +13,14 @@ Illumina NextSeq 550,http://www.ebi.ac.uk/efo/EFO_0008566
NextSeq550,http://www.ebi.ac.uk/efo/EFO_0008566
NextSeq 550,http://www.ebi.ac.uk/efo/EFO_0008566
Illumina MiniSeq,http://www.ebi.ac.uk/efo/EFO_0008636
+Illumina NovaSeq,http://www.ebi.ac.uk/efo/EFO_0008637
Illumina NovaSeq 6000,http://www.ebi.ac.uk/efo/EFO_0008637
Nanopore MinION,http://www.ebi.ac.uk/efo/EFO_0008632
Oxford Nanopore MinION,http://www.ebi.ac.uk/efo/EFO_0008632
ONT (Oxford Nanopore Technologies),http://purl.obolibrary.org/obo/NCIT_C146818
Oxford Nanopore Technology,http://purl.obolibrary.org/obo/NCIT_C146818
Oxford Nanopore technologies MinION,http://www.ebi.ac.uk/efo/EFO_0008632
+Oxford Nanopore Sequencing,http://purl.obolibrary.org/obo/NCIT_C146818
MinION Oxford Nanopore,http://www.ebi.ac.uk/efo/EFO_0008632
MinION,http://www.ebi.ac.uk/efo/EFO_0008632
Nanopore,http://purl.obolibrary.org/obo/NCIT_C146818
@@ -33,3 +35,24 @@ ThermoFisher S5Plus,http://purl.obolibrary.org/obo/NCIT_C125894
Sanger dideoxy sequencing,http://purl.obolibrary.org/obo/NCIT_C19641
MGISEQ 2000,http://virtual-bh/MGISEQ2000
MGISEQ2000,http://virtual-bh/MGISEQ2000
+Illumina HiSeq X,http://www.ebi.ac.uk/efo/EFO_0008567
+ONT GridION X5,http://www.ebi.ac.uk/efo/EFO_0008633
+ONT PremethION,http://www.ebi.ac.uk/efo/EFO_0008634
+PacBio RS II,http://www.ebi.ac.uk/efo/EFO_0008631
+PacBio Sequel System,http://www.ebi.ac.uk/efo/EFO_0008630
+Illumina Genome Analyzer,http://www.ebi.ac.uk/efo/EFO_0004200
+Illumina Genome Analyzer II,http://www.ebi.ac.uk/efo/EFO_0004201
+Illumina Genome Analyzer IIx,http://www.ebi.ac.uk/efo/EFO_0004202
+454 GS 20 sequencer,http://www.ebi.ac.uk/efo/EFO_0004206
+454 GS FLX Titanium sequencer,http://www.ebi.ac.uk/efo/EFO_0004433
+454 GS FLX sequencer,http://www.ebi.ac.uk/efo/EFO_0004432
+454 GS Junior sequencer,http://www.ebi.ac.uk/efo/EFO_0004434
+454 GS sequencer,http://www.ebi.ac.uk/efo/EFO_0004431
+AB SOLiD 4 System,http://www.ebi.ac.uk/efo/EFO_0004438
+AB SOLiD 4hq System,http://www.ebi.ac.uk/efo/EFO_0004441
+AB SOLiD 5500,http://www.ebi.ac.uk/efo/EFO_0004440
+AB SOLiD 5500xl,http://www.ebi.ac.uk/efo/EFO_0004436
+AB SOLiD PI System,http://www.ebi.ac.uk/efo/EFO_0004437
+AB SOLiD System,http://www.ebi.ac.uk/efo/EFO_0004435
+AB SOLiD System 2.0,http://www.ebi.ac.uk/efo/EFO_0004442
+AB SOLiD System 3.0,http://www.ebi.ac.uk/efo/EFO_0004439
diff --git a/scripts/docker/Dockerfile b/scripts/docker/Dockerfile
index 9fb33d5..02829d4 100644
--- a/scripts/docker/Dockerfile
+++ b/scripts/docker/Dockerfile
@@ -3,8 +3,8 @@ FROM debian:10
RUN apt-get update && \
apt-get -yq --no-install-recommends -o Acquire::Retries=6 install \
python3 python3-pip python3-setuptools python3-dev python-pycurl \
- clustalw python3-biopython libcurl4-openssl-dev build-essential \
+ minimap2 python3-biopython libcurl4-openssl-dev build-essential \
libssl-dev libmagic-dev python3-magic && \
apt-get clean
-RUN pip3 install bh20-seq-uploader
+RUN pip3 install bh20-seq-uploader py-dateutil
diff --git a/scripts/download_genbank_data/from_genbank_to_fasta_and_yaml.py b/scripts/download_genbank_data/from_genbank_to_fasta_and_yaml.py
index d76f56b..cb94787 100755
--- a/scripts/download_genbank_data/from_genbank_to_fasta_and_yaml.py
+++ b/scripts/download_genbank_data/from_genbank_to_fasta_and_yaml.py
@@ -4,6 +4,8 @@ import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--skip-request', action='store_true', help='skip metadata and sequence request', required=False)
parser.add_argument('--only-missing-id', action='store_true', help='download only missing id', required=False)
+parser.add_argument('--dict-ontology', type=str, help='where is the ontology',
+ default='../dict_ontology_standardization/',required=False)
args = parser.parse_args()
from Bio import Entrez
@@ -22,7 +24,7 @@ num_ids_for_request = 100
dir_metadata = 'metadata_from_nuccore'
dir_fasta_and_yaml = 'fasta_and_yaml'
-dir_dict_ontology_standardization = '../dict_ontology_standardization/'
+dir_dict_ontology_standardization = args.dict_ontology
today_date = date.today().strftime("%Y.%m.%d")
path_ncbi_virus_accession = 'sequences.{}.acc'.format(today_date)
@@ -126,7 +128,7 @@ for path_dict_xxx_csv in [os.path.join(dir_dict_ontology_standardization, name_x
if term in term_to_uri_dict:
print('Warning: in the dictionaries there are more entries for the same term ({}).'.format(term))
continue
-
+
term_to_uri_dict[term] = uri
if not os.path.exists(dir_fasta_and_yaml):
@@ -171,7 +173,9 @@ for path_metadata_xxx_xml in [os.path.join(dir_metadata, name_metadata_xxx_xml)
# submitter info
GBSeq_references = GBSeq.find('GBSeq_references')
if GBSeq_references is not None:
- info_for_yaml_dict['submitter']['authors'] = ["{}".format(x.text) for x in GBSeq_references.iter('GBAuthor')]
+ author_list = ["{}".format(x.text) for x in GBSeq_references.iter('GBAuthor')]
+ if len(author_list) > 0:
+ info_for_yaml_dict['submitter']['authors'] = author_list
GBReference = GBSeq_references.find('GBReference')
if GBReference is not None:
@@ -220,7 +224,8 @@ for path_metadata_xxx_xml in [os.path.join(dir_metadata, name_metadata_xxx_xml)
new_seq_tec_list.append(seq_tec)
- info_for_yaml_dict['technology']['sample_sequencing_technology'] = [x for x in new_seq_tec_list]
+ if len(new_seq_tec_list) > 0:
+ info_for_yaml_dict['technology']['sample_sequencing_technology'] = [x for x in new_seq_tec_list]
else:
info_for_yaml_dict['technology'][field_in_yaml] = tech_info_to_parse
@@ -238,58 +243,62 @@ for path_metadata_xxx_xml in [os.path.join(dir_metadata, name_metadata_xxx_xml)
GBQualifier_name_text = GBQualifier.find('GBQualifier_name').text
if GBQualifier_name_text == 'host':
- GBQualifier_value_text_list = GBQualifier_value_text.split('; ')
-
- if GBQualifier_value_text_list[0] in term_to_uri_dict:
- info_for_yaml_dict['host']['host_species'] = term_to_uri_dict[GBQualifier_value_text_list[0]]
- elif GBQualifier_value_text_list[0] and ('MT215193' in accession_version or 'MT270814' in accession_version):
- # Information checked manually from NCBI Virus
- info_for_yaml_dict['host']['host_species'] = term_to_uri_dict['Canis lupus familiaris']
+ if GBQualifier_value_text in term_to_uri_dict:
+ # Cases like 'Felis catus; Domestic Shorthair'
+ info_for_yaml_dict['host']['host_species'] = term_to_uri_dict[GBQualifier_value_text]
else:
- missing_value_list.append('\t'.join([accession_version, 'host_species', GBQualifier_value_text_list[0]]))
-
- # Possible cases:
- # - Homo sapiens --> ['Homo sapiens']
- # - Homo sapiens; female --> ['Homo sapiens', 'female']
- # - Homo sapiens; female 63 --> ['Homo sapiens', 'female 63']
- # - Homo sapiens; female; age 40 --> ['Homo sapiens', 'female', 'age 40']
- # - Homo sapiens; gender: F; age: 61 --> ['Homo sapiens', 'gender: F', 'age: 61']
- # - Homo sapiens; gender: M; age: 68 --> ['Homo sapiens', 'gender: M', 'age: 68']
- # - Homo sapiens; hospitalized patient --> ['Homo sapiens', 'hospitalized patient']
- # - Homo sapiens; male --> ['Homo sapiens', 'male']
- # - Homo sapiens; male; 63 --> ['Homo sapiens', 'male', '63']
- # - Homo sapiens; male; age 29 --> ['Homo sapiens', 'male', 'age 29']
- # - Homo sapiens; symptomatic --> ['Homo sapiens', 'symptomatic']
- if len(GBQualifier_value_text_list) > 1:
- host_sex = ''
- if 'female' in GBQualifier_value_text_list[1]:
- host_sex = 'female'
- elif 'male' in GBQualifier_value_text_list[1]:
- host_sex = 'male'
- elif 'gender' in GBQualifier_value_text_list[1]:
- host_sex_one_lecter = GBQualifier_value_text_list[1].split(':')[-1].strip()
- if host_sex_one_lecter in ['F', 'M']:
- host_sex = 'female' if host_sex_one_lecter == 'F' else 'male'
-
- if host_sex in ['male', 'female']:
- info_for_yaml_dict['host']['host_sex'] = "http://purl.obolibrary.org/obo/PATO_0000384" if host_sex == 'male' else "http://purl.obolibrary.org/obo/PATO_0000383"
- elif GBQualifier_value_text_list[1] in term_to_uri_dict:
- info_for_yaml_dict['host']['host_health_status'] = term_to_uri_dict[GBQualifier_value_text_list[1]]
+ GBQualifier_value_text_list = GBQualifier_value_text.split('; ')
+
+ if GBQualifier_value_text_list[0] in term_to_uri_dict:
+ info_for_yaml_dict['host']['host_species'] = term_to_uri_dict[GBQualifier_value_text_list[0]]
+ elif GBQualifier_value_text_list[0] and ('MT215193' in accession_version or 'MT270814' in accession_version):
+ # Information checked manually from NCBI Virus
+ info_for_yaml_dict['host']['host_species'] = term_to_uri_dict['Canis lupus familiaris']
else:
- missing_value_list.append('\t'.join([accession_version, 'host_sex or host_health_status', GBQualifier_value_text_list[1]]))
-
- # Host age
- host_age = -1
- if len(GBQualifier_value_text_list[1].split(' ')) > 1 and is_integer(GBQualifier_value_text_list[1].split(' ')[-1]):
- host_age = int(GBQualifier_value_text_list[1].split(' ')[-1])
- elif len(GBQualifier_value_text_list) > 2 and is_integer(GBQualifier_value_text_list[2].split(' ')[-1]):
- host_age = int(GBQualifier_value_text_list[2].split(' ')[-1])
-
- if host_age > -1:
- info_for_yaml_dict['host']['host_age'] = host_age
- info_for_yaml_dict['host']['host_age_unit'] = 'http://purl.obolibrary.org/obo/UO_0000036'
- elif len(GBQualifier_value_text_list) > 2:
- missing_value_list.append('\t'.join([accession_version, 'host_age', GBQualifier_value_text_list[2]]))
+ missing_value_list.append('\t'.join([accession_version, 'host_species', GBQualifier_value_text_list[0]]))
+
+ # Possible cases:
+ # - Homo sapiens --> ['Homo sapiens']
+ # - Homo sapiens; female --> ['Homo sapiens', 'female']
+ # - Homo sapiens; female 63 --> ['Homo sapiens', 'female 63']
+ # - Homo sapiens; female; age 40 --> ['Homo sapiens', 'female', 'age 40']
+ # - Homo sapiens; gender: F; age: 61 --> ['Homo sapiens', 'gender: F', 'age: 61']
+ # - Homo sapiens; gender: M; age: 68 --> ['Homo sapiens', 'gender: M', 'age: 68']
+ # - Homo sapiens; hospitalized patient --> ['Homo sapiens', 'hospitalized patient']
+ # - Homo sapiens; male --> ['Homo sapiens', 'male']
+ # - Homo sapiens; male; 63 --> ['Homo sapiens', 'male', '63']
+ # - Homo sapiens; male; age 29 --> ['Homo sapiens', 'male', 'age 29']
+ # - Homo sapiens; symptomatic --> ['Homo sapiens', 'symptomatic']
+ if len(GBQualifier_value_text_list) > 1:
+ host_sex = ''
+ if 'female' in GBQualifier_value_text_list[1]:
+ host_sex = 'female'
+ elif 'male' in GBQualifier_value_text_list[1]:
+ host_sex = 'male'
+ elif 'gender' in GBQualifier_value_text_list[1]:
+ host_sex_one_lecter = GBQualifier_value_text_list[1].split(':')[-1].strip()
+ if host_sex_one_lecter in ['F', 'M']:
+ host_sex = 'female' if host_sex_one_lecter == 'F' else 'male'
+
+ if host_sex in ['male', 'female']:
+ info_for_yaml_dict['host']['host_sex'] = "http://purl.obolibrary.org/obo/PATO_0000384" if host_sex == 'male' else "http://purl.obolibrary.org/obo/PATO_0000383"
+ elif GBQualifier_value_text_list[1] in term_to_uri_dict:
+ info_for_yaml_dict['host']['host_health_status'] = term_to_uri_dict[GBQualifier_value_text_list[1]]
+ else:
+ missing_value_list.append('\t'.join([accession_version, 'host_sex or host_health_status', GBQualifier_value_text_list[1]]))
+
+ # Host age
+ host_age = -1
+ if len(GBQualifier_value_text_list[1].split(' ')) > 1 and is_integer(GBQualifier_value_text_list[1].split(' ')[-1]):
+ host_age = int(GBQualifier_value_text_list[1].split(' ')[-1])
+ elif len(GBQualifier_value_text_list) > 2 and is_integer(GBQualifier_value_text_list[2].split(' ')[-1]):
+ host_age = int(GBQualifier_value_text_list[2].split(' ')[-1])
+
+ if host_age > -1:
+ info_for_yaml_dict['host']['host_age'] = host_age
+ info_for_yaml_dict['host']['host_age_unit'] = 'http://purl.obolibrary.org/obo/UO_0000036'
+ elif len(GBQualifier_value_text_list) > 2:
+ missing_value_list.append('\t'.join([accession_version, 'host_age', GBQualifier_value_text_list[2]]))
elif GBQualifier_name_text == 'collected_by':
if any([x in GBQualifier_value_text.lower() for x in ['institute', 'hospital', 'city', 'center']]):
info_for_yaml_dict['sample']['collecting_institution'] = GBQualifier_value_text
@@ -362,9 +371,9 @@ for path_metadata_xxx_xml in [os.path.join(dir_metadata, name_metadata_xxx_xml)
info_for_yaml_dict['virus']['virus_species'] = "http://purl.obolibrary.org/obo/NCBITaxon_"+GBQualifier_value_text.split('taxon:')[1]
- # Remove technology key if empty!
- if (info_for_yaml_dict['technology']=={}):
- del info_for_yaml_dict['technology']
+ if 'sample_sequencing_technology' not in info_for_yaml_dict['technology']:
+ print(accession_version, ' - technology not found')
+ continue
with open(os.path.join(dir_fasta_and_yaml, '{}.fasta'.format(accession_version)), 'w') as fw:
fw.write('>{}\n{}'.format(accession_version, GBSeq_sequence.text.upper()))
@@ -391,5 +400,5 @@ if len(accession_with_errors_list) > 0:
print('Written the accession with errors in {}'.format(path_accession_with_errors_tsv))
with open(path_accession_with_errors_tsv, 'w') as fw:
fw.write('\n'.join(accession_with_errors_list))
-
+
print('Num. new sequences with length >= {} bp: {}'.format(min_len_to_count, num_seq_with_len_ge_X_bp))
diff --git a/scripts/download_sra_data/SraExperimentPackage.2020.06.08.xml.gz b/scripts/download_sra_data/SraExperimentPackage.2020.06.08.xml.gz
deleted file mode 100644
index f9cd995..0000000
--- a/scripts/download_sra_data/SraExperimentPackage.2020.06.08.xml.gz
+++ /dev/null
Binary files differ
diff --git a/scripts/fetch_from_genbank.cwl b/scripts/fetch_from_genbank.cwl
new file mode 100644
index 0000000..45c8eec
--- /dev/null
+++ b/scripts/fetch_from_genbank.cwl
@@ -0,0 +1,49 @@
+cwlVersion: v1.1
+class: CommandLineTool
+inputs:
+ importScript:
+ type: File
+ default:
+ class: File
+ location: download_genbank_data/from_genbank_to_fasta_and_yaml.py
+ inputBinding: {position: 1}
+ dict:
+ type: Directory
+ inputBinding:
+ prefix: --dict-ontology
+ position: 2
+ default:
+ class: Directory
+ location: dict_ontology_standardization
+ existing_metadata_from_nuccore:
+ type: Directory?
+ inputBinding:
+ valueFrom: "--skip-request"
+ position: 3
+outputs:
+ fasta_and_yaml:
+ type: Directory
+ outputBinding:
+ glob: fasta_and_yaml
+ metadata_from_nuccore:
+ type: Directory
+ outputBinding:
+ glob: metadata_from_nuccore
+ accessions:
+ type: File?
+ outputBinding:
+ glob: "*.acc"
+ missing_terms:
+ type: File
+ outputBinding:
+ glob: missing_terms.tsv
+requirements:
+ InitialWorkDirRequirement:
+ listing:
+ - entry: $(inputs.existing_metadata_from_nuccore)
+ entryname: metadata_from_nuccore
+ DockerRequirement:
+ dockerPull: bh20-seq-uploader/import
+ NetworkAccess:
+ networkAccess: true
+baseCommand: python3
diff --git a/scripts/import.cwl b/scripts/import.cwl
index d84516b..4b4b8ca 100644
--- a/scripts/import.cwl
+++ b/scripts/import.cwl
@@ -12,7 +12,7 @@ inputs:
type: File
default:
class: File
- location: from_genbank_to_fasta_and_yaml.py
+ location: download_genbank_data/from_genbank_to_fasta_and_yaml.py
inputBinding: {position: 2}
dict:
type: Directory
diff --git a/scripts/import_from_genbank.cwl b/scripts/import_from_genbank.cwl
new file mode 100644
index 0000000..dcf9acb
--- /dev/null
+++ b/scripts/import_from_genbank.cwl
@@ -0,0 +1,27 @@
+cwlVersion: v1.1
+class: Workflow
+inputs:
+ existing_metadata_from_nuccore:
+ type: Directory?
+outputs: []
+requirements:
+ ScatterFeatureRequirement: {}
+steps:
+ fetch_from_genbank:
+ in:
+ existing_metadata_from_nuccore: existing_metadata_from_nuccore
+ out: [fasta_and_yaml, metadata_from_nuccore, accessions]
+ run: fetch_from_genbank.cwl
+ split_into_arrays:
+ in:
+ dir: fetch_from_genbank/fasta_and_yaml
+ out: [fasta, metadata]
+ run: split_into_arrays.cwl
+ upload:
+ in:
+ fasta: split_into_arrays/fasta
+ metadata: split_into_arrays/metadata
+ out: []
+ scatter: [fasta, metadata]
+ scatterMethod: dotproduct
+ run: upload.cwl
diff --git a/scripts/import_to_arvados.py b/scripts/import_to_arvados.py
index 78cd13d..aca72d6 100644
--- a/scripts/import_to_arvados.py
+++ b/scripts/import_to_arvados.py
@@ -11,4 +11,4 @@ os.chdir("fasta_and_yaml")
fasta_files = glob.glob("*.fasta")
for f in fasta_files:
- subprocess.run(["bh20-seq-uploader", f, "%s.yaml" %f[:-6]])
+ subprocess.run(["bh20-seq-uploader", "%s.yaml" %f[:-6], f])
diff --git a/scripts/split_into_arrays.cwl b/scripts/split_into_arrays.cwl
new file mode 100644
index 0000000..102fe7d
--- /dev/null
+++ b/scripts/split_into_arrays.cwl
@@ -0,0 +1,30 @@
+cwlVersion: v1.1
+class: ExpressionTool
+requirements:
+ InlineJavascriptRequirement: {}
+inputs:
+ dir:
+ type: Directory
+ loadListing: shallow_listing
+outputs:
+ fasta: File[]
+ metadata: File[]
+expression: |
+ ${
+ var dir = inputs.dir;
+ var fasta = [];
+ var metadata = [];
+ dir.listing.sort(function(a, b) { return a.basename < b.basename; });
+ for (var i = 0; i < dir.listing.length; i++) {
+ if (dir.listing[i].basename.substr(-6) == ".fasta") {
+ fasta.push(dir.listing[i]);
+ }
+ if (dir.listing[i].basename.substr(-5) == ".yaml") {
+ metadata.push(dir.listing[i]);
+ }
+ }
+ if (fasta.length != metadata.length) {
+ throw "They dont match";
+ }
+ return {"fasta": fasta, "metadata": metadata};
+ }
diff --git a/scripts/upload.cwl b/scripts/upload.cwl
new file mode 100644
index 0000000..0fed09a
--- /dev/null
+++ b/scripts/upload.cwl
@@ -0,0 +1,13 @@
+cwlVersion: v1.1
+class: CommandLineTool
+inputs:
+ fasta: File
+ metadata: File
+outputs: []
+requirements:
+ DockerRequirement:
+ dockerPull: bh20-seq-uploader/import
+ NetworkAccess:
+ networkAccess: true
+baseCommand: bh20-seq-uploader
+arguments: [--skip-qc, $(inputs.metadata), $(inputs.fasta)]