Skip to content

Commit

Permalink
updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
mattheww95 committed Oct 21, 2024
1 parent 4d2c3f7 commit ae41f4d
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 27 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

-----

# Note

## This repo is underdevelopment and not ready for routine usage

**Table of Contents**

- [Installation](#installation)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "mikrokondo-tools"
dynamic = ["version"]
description = ''
readme = "README.md"
requires-python = ">=3.7"
requires-python = ">=3.8"
license = "MIT"
keywords = []
authors = [
Expand Down
2 changes: 1 addition & 1 deletion src/mikrokondo_tools/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import click

from mikrokondo_tools.__about__ import __version__
from mikrokondo_tools.cli.format import fmt
from mikrokondo_tools.cli.download import download
from mikrokondo_tools.cli.format import fmt


@click.group(context_settings={"help_option_names": ["-h", "--help"]}, invoke_without_command=True, no_args_is_help=True)
Expand Down
8 changes: 4 additions & 4 deletions src/mikrokondo_tools/cli/download/__init__.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import os

import click
from mikrokondo_tools.download import download as dwnld

from mikrokondo_tools.download import download as dwnld

options = {"gtdb-sketch": dwnld.Constants.sketch_url,
options = {"gtdb-sketch": dwnld.Constants.sketch_url,
"dehost": dwnld.Constants.dehost_idx,
"kraken-std": dwnld.Constants.kraken2_std,
"bakta-light": dwnld.Constants.bakta_light,
"bakta-full": dwnld.Constants.bakta_full}

@click.command(short_help="Download a database for mikrokondo", no_args_is_help=True)
@click.option("-f", "--file", "file", type=click.Choice(options.keys()), required = True,
@click.option("-f", "--file", "file", type=click.Choice(options.keys()), required = True,
help="Pick an option from the list to download")
@click.option("-o", "--output", "output", default=os.getcwd(), type=click.Path(), help="An existing directory to download files too.")
def download(file, output):
"""Download a external file for use in mikrokondo. This script only downloads the file and will not untar or unzip them.
"""
option = options[file]
dwnld.download_file(output_dir=output, url=option)
dwnld.download_file(output_dir=output, url=option)
9 changes: 4 additions & 5 deletions src/mikrokondo_tools/download/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
Matthew Wells: 2024-04-18
"""
import requests

import logging
import itertools
import sys
import logging
import os
import sys
from dataclasses import dataclass

import requests

logging.basicConfig(stream=sys.stderr, level=logging.INFO) # TODO this should probably go somewhere else
logger = logging.getLogger(__name__)
Expand All @@ -34,7 +33,7 @@ def get_file_name(input_uri: str) -> str:

def download_file(url: str, output_dir: str = None) -> str:
"""Download a file from zenodo and put it in the correct output director
output_dir str|os.Path: Output location different then local directory
"""
output_file = get_file_name(url)
Expand Down
16 changes: 8 additions & 8 deletions src/mikrokondo_tools/format/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def denested_information(keys: list[str], last_value: dict) -> dict:

temp[Constants.type_field] = Constants.properties_type
temp[Constants.extraction_field] = {keys[-1]: last_value}

return new_chain


Expand Down Expand Up @@ -93,25 +93,25 @@ def nest_schema(properties: dict) -> dict:
if Constants.delimiter not in key:
continue
split_key = key.split(Constants.delimiter)

if new_dict.get(split_key[0]) is None:
new_dict[split_key[0]] = {}
new_dict[split_key[0]][Constants.type_field] = Constants.properties_type
new_dict[split_key[0]][Constants.extraction_field] = {}

denested_data = denested_information(split_key[1:], values)
if denested_data != values:
# multiple fields to be set, update the properties instead of overwriting it

temp = denested_data

nd_temp = new_dict[split_key[0]][Constants.extraction_field]
for i in split_key[1:-1]:
if nd_temp.get(i) is None:
nd_temp[i] = {}
nd_temp[i][Constants.type_field] = temp[i][Constants.type_field]
nd_temp[i][Constants.extraction_field] = {}

nd_temp = nd_temp[i][Constants.extraction_field]
temp = temp[i][Constants.extraction_field]

Expand Down Expand Up @@ -160,7 +160,7 @@ def nest_properties(schema: dict) -> dict:
new_properties = nest_schema(properties=props[Constants.extraction_field])
del schema[Constants.nesting_field][k][Constants.extraction_field]
schema[Constants.nesting_field][k][Constants.extraction_field] = new_properties


new_properties = nest_schema(properties=properties)
del schema[Constants.extraction_field]
Expand All @@ -187,7 +187,7 @@ def reorganize_schema(schema) -> set:
definitions dict: Updated definitions field in a json schema
return drop_keys set: Additional fields to delete from the schema after processing
"""


definitions = schema[Constants.nesting_field]
top_lvl_keys = frozenset(definitions.keys())
Expand Down
5 changes: 3 additions & 2 deletions tests/download/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

import pytest
import requests

from mikrokondo_tools.download import download


@pytest.mark.parametrize("uri",
[
[
(download.Constants.sketch_url),
(download.Constants.dehost_idx),
(download.Constants.kraken2_std),
Expand All @@ -29,7 +30,7 @@ def test_constants_connection(uri):
"PhiPacHum_m2.idx"),
("https://genome-idx.s3.amazonaws.com/kraken/k2_standard_20240112.tar.gz",
"k2_standard_20240112.tar.gz"),
("https://zenodo.org/records/10522951/files/db-light.tar.gz",
("https://zenodo.org/records/10522951/files/db-light.tar.gz",
"db-light.tar.gz"),
("https://zenodo.org/records/10522951/files/db.tar.gz", "db.tar.gz"),
("db.tar.gz", "db.tar.gz")
Expand Down
12 changes: 6 additions & 6 deletions tests/format/test_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,19 @@
"seqkit.args.single_end": {"type": "string"},
},
{
"seqkit":
"seqkit":
{
"type": "object",
"properties":
"properties":
{
"singularity":
{"type": "string"},
"docker":
{"type": "string"},
"args":
"args":
{
"type": "object",
"properties":
"properties":
{
"illumina": {"type": "string"},
"single_end": {"type": "string"},
Expand All @@ -93,8 +93,8 @@ def test_nest_schema(test_val, output):
def test_read_json(real_schema):
assert real_schema == format.read_json(conftest.SCHEMA_PATH)

@pytest.mark.parametrize("input_,output",
@pytest.mark.parametrize("input_,output",
[("singularity", "#/definitions/singularity")
])
def test_create_all_of_ref(input_, output):
assert format.create_all_of_ref(input_) == output
assert format.create_all_of_ref(input_) == output

0 comments on commit ae41f4d

Please sign in to comment.