Commit 40b823f2 authored by Lukas Jelonek's avatar Lukas Jelonek
Browse files

Add file metadata for card

parent 2b71cd2d
#!/usr/bin/env python3
import dbman.helper as h
import json
import os
import logging
logging.basicConfig(level=logging.INFO)
......@@ -22,9 +23,23 @@ fn = h.download(url)
# extract archive
h.extract(fn)
os.unlink(fn)
# detect version
version = lookup_card_version()
# lookup tags for fasta files
fastas = [f.name for f in os.scandir('.') if f.is_file() and f.name.endswith('.fasta')]
parts = []
for fasta in fastas:
tags = fasta .replace('_protein_', '_') .replace('.fasta', '') .split('_',2)
parts.append({'files': [fasta], 'tags': tags})
tsvs = [f.name for f in os.scandir('.') if f.is_file() and (f.name.endswith('.tsv') or f.name == 'snps.txt')]
for tsv in tsvs:
parts.append({'files': [tsv], 'tags': ['tsv']})
parts.append({'files': ['card.json'], 'tags':['json', 'model']})
parts.append({'files': ['CARD-Download-README.txt'], 'tags':['text', 'readme']})
# write metadata file
h.create_metadata(dbname, "download", dbdescription, version=version)
h.create_metadata(dbname, "download", dbdescription, version=version, other={'parts': parts})
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment