Skip to content

Commit

Permalink
change to pathosonar (#31)
Browse files Browse the repository at this point in the history
* change mpoxsonar to pathosonar
  • Loading branch information
silenus092 authored Dec 2, 2023
1 parent f19d9f5 commit 99a3306
Show file tree
Hide file tree
Showing 108 changed files with 37,053 additions and 6,911 deletions.
4 changes: 2 additions & 2 deletions data/location_coordinates.csv
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ location_ID,country_ID,ISO_Code,name,lon,lat
49,CC,CCK,Cocos [Keeling] Islands,96.870956,-12.164165
50,CO,COL,Colombia,-74.297333,4.570868
51,KM,COM,Comoros,43.872219,-11.875001
52,CD,COG,Congo [DRC],21.758664,-4.038333
53,CG,COD,Congo [Republic],15.827659,-0.228021
52,CD,COG,Congo [Republic],21.758664,-4.038333
53,CG,COD,Congo [DRC],15.827659,-0.228021
54,CK,COK,Cook Islands,-159.777671,-21.236736
55,CR,CRI,Costa Rica,-83.753428,9.748917
56,CI,CIV,Côte d'Ivoire,-5.54708,7.539989
Expand Down
58 changes: 26 additions & 32 deletions pages/app_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import sys
from textwrap import fill
import time
from typing import List

import pandas as pd

Expand All @@ -14,12 +15,12 @@
from pages.config import redis_manager
from pages.DBManager import DBManager
from pages.utils import generate_96_mutation_types
from .libs.mpxsonar.src.mpxsonar.basics import sonarBasics
from .libs.mpxsonar.src.mpxsonar.dbm import sonarDBManager
from .libs.pathosonar.src.pathosonar.dbm import sonarDBManager
from .libs.pathosonar.src.pathosonar.utils import sonarUtils


# CLASS
class sonarBasicsChild(sonarBasics):
class sonarBasicsChild(sonarUtils):
"""
this class inherit from sonarBasics to provides sonarBasics functionalities and intelligence
"""
Expand All @@ -28,8 +29,8 @@ class sonarBasicsChild(sonarBasics):
@staticmethod
def match(
db,
profiles=[],
reserved_props_dict={},
profiles: List[str] = [],
samples: List[str] = [],
propdict={},
reference=None,
outfile=None,
Expand All @@ -43,20 +44,22 @@ def match(
output = """The current MpoxSonar in the MpoxRadar is
not supporting the save-output-to-file command (-o). """
return output

with sonarDBManager(db, debug=debug) as dbm:
if format == "vcf" and reference is None:
if reference is None:
reference = dbm.get_default_reference_accession()

cursor = dbm.match(
*profiles,
reserved_props=reserved_props_dict,
properties=propdict,
reference_accession=reference,
format=format,
output_column=output_column,
showNX=showNX,
)
try:
cursor = dbm.match(
profiles=profiles,
samples=samples,
properties=propdict,
reference_accession=reference,
format=format,
output_columns=output_column,
filter_n=not showNX,
filter_x=not showNX,
)
except Exception as e:
print(e)
if format == "csv" or format == "tsv":
# cursor => list of dict
df = pd.DataFrame(cursor)
Expand Down Expand Up @@ -138,12 +141,12 @@ def get_freq_mutation(args):
with sonarDBManager(args.db, readonly=False) as dbm:
cursor = dbm.our_match()
df = pd.DataFrame(cursor)
print(df)
# print(df)
return df


def match_controller(args): # noqa: C901
props = {}
reserved_props = {}

with sonarDBManager(args.db, readonly=False, debug=args.debug) as dbm:
if args.reference:
Expand All @@ -170,23 +173,14 @@ def match_controller(args): # noqa: C901
)
else:
valid_output_column = "all"
# for reserved keywords
reserved_key = ["sample"]
for pname in reserved_key:
if hasattr(args, pname):
if pname == "sample" and len(getattr(args, pname)) > 0:
# reserved_props[pname] = set([x.strip() for x in args.sample])
reserved_props = sonarBasics.set_key(
reserved_props, pname, getattr(args, pname)
)
# reserved_props[pname] = getattr(args, pname)
format = "count" if args.count else args.format
# print(props)

output = sonarBasicsChild.match(
args.db,
args.profile,
reserved_props,
props,
profiles=args.profile,
samples=args.sample,
propdict=props,
outfile=args.out,
output_column=valid_output_column,
debug=args.debug,
Expand Down
1 change: 0 additions & 1 deletion pages/explore_callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ def update_world_map_explorer(
color_dict,
location_coordinates,
)

fig = world_map_instance.get_world_map(method)
# layout: {'geo.projection.rotation.lon': -99.26450411962647,
# 'geo.center.lon': -99.26450411962647,
Expand Down
2 changes: 1 addition & 1 deletion pages/html_compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def html_date_picker(d_id):
dbc.Label("Date interval:"),
dcc.DatePickerRange(
id=f"date_picker_range_{d_id}",
start_date="2022-01-01",
start_date="1960-01-01",
end_date=today,
min_date_allowed=date(1960, 1, 1),
max_date_allowed=today,
Expand Down
Binary file added pages/libs/mpxsonar.backup.zip
Binary file not shown.
Loading

0 comments on commit 99a3306

Please sign in to comment.