Skip to content

Commit

Permalink
Merge pull request #28 from MannLabs/gui
Browse files Browse the repository at this point in the history
Gui
  • Loading branch information
GeorgWa authored Jul 17, 2023
2 parents 4d90563 + 9e3a00b commit 2effbb7
Show file tree
Hide file tree
Showing 113 changed files with 57,034 additions and 6,607 deletions.
37 changes: 27 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
# User defined:
AlphaDIA/logs

*.DS_Store
*sandbox*
.neptune
nbs/mono_crash*
.coverage

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# neptune ai
.neptune

# C extensions
*.so

Expand Down Expand Up @@ -131,10 +137,21 @@ dmypy.json
# Pyre type checker
.pyre/

# User defined:
AlphaDIA/logs
*.DS_Store
*sandbox*
.neptune
nbs/mono_crash*
.coverage
######################
# OS generated files #
######################
.DS_Store
.AppleDouble
.LSOverride

##################
# JavaScript GUI #
##################
node_modules
jspm_packages

gui/dist/
gui/out/



91 changes: 62 additions & 29 deletions alphadia/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import logging
import time
import sys
import yaml

# external
import click
Expand All @@ -25,14 +26,7 @@
@click.pass_context
@click.version_option(alphadia.__version__, "-v", "--version")
def run(ctx, **kwargs):
click.echo(' _ _ _ ___ ___ _ ')
click.echo(' /_\ | |_ __| |_ __ _| \_ _| /_\ ')
click.echo(' / _ \| | \'_ \\ \' \/ _` | |) | | / _ \ ')
click.echo(' /_/ \_\_| .__/_||_\__,_|___/___/_/ \_\\')
click.echo(f' |_| version: {alphadia.__version__}')
click.echo('')



if ctx.invoked_subcommand is None:
click.echo(run.get_help(ctx))

Expand All @@ -48,7 +42,7 @@ def gui():
@click.argument(
"output-location",
type=click.Path(exists=True, file_okay=False, dir_okay=True),
required=True,
required=False,
)
@click.option(
'--file',
Expand Down Expand Up @@ -78,13 +72,13 @@ def gui():
show_default=True,
)
@click.option(
"--config-path",
help='DO NOT TOUCH - Default config yaml. If not specified, the default config will be used.',
"--config",
help='Config yaml which will be used to update the default config.',
type=click.Path(exists=True, file_okay=True, dir_okay=False),
)
@click.option(
"--config-update-path",
help='Config yaml which will be used to update the default config.',
"--config-base",
help='DO NOT TOUCH - Default config yaml. If not specified, the default config will be used.',
type=click.Path(exists=True, file_okay=True, dir_okay=False),
)
@click.option(
Expand All @@ -110,23 +104,62 @@ def gui():
help="If specified, directory will be used to store calibration figures.",
type=click.Path(exists=True, file_okay=False, dir_okay=True)
)
def extract(**kwargs):
def extract(**kwargs):

kwargs['neptune_tag'] = list(kwargs['neptune_tag'])

# load config file if specified
config_update = None
if kwargs['config'] is not None:
with open(kwargs['config'], 'r') as f:
config_update = yaml.safe_load(f)

output_location = None
if kwargs['output_location'] is not None:
output_location = kwargs['output_location']

if "output" in config_update:
output_location = config_update['output']

if output_location is None:
logging.error("No output location specified.")
return

processlogger.init_logging(kwargs['output_location'])
logger = logging.getLogger()

if kwargs['file'] is None:
logging.error("No input file specified.")
# assert input files have been specified
files = None
if kwargs['file'] is not None:
files = list(kwargs['file'])

if "files" in config_update:
files = config_update['files'] if type(config_update['files']) is list else [config_update['files']]

if (files is None) or (len(files) == 0):
logging.error("No files specified.")
return
else:
kwargs['file'] = list(kwargs['file'])

# assert library has been specified
library = None
if kwargs['library'] is not None:
library = kwargs['library']

if "library" in config_update:
library = config_update['library']

if kwargs['library'] is None:
if library is None:
logging.error("No library specified.")
return

kwargs['neptune_tag'] = list(kwargs['neptune_tag'])

logger.progress(f"Extracting from {len(files)} files:")
for f in files:
logger.progress(f" {f}")
logger.progress(f"Using library {library}.")
logger.progress(f"Saving output to {output_location}.")

try:
print (kwargs)

import matplotlib
# important to supress matplotlib output
matplotlib.use('Agg')
Expand All @@ -135,21 +168,21 @@ def extract(**kwargs):
from alphadia.extraction.planning import Plan

lib = SpecLibBase()
lib.load_hdf(kwargs['library'], load_mod_seq=True)
lib.load_hdf(library, load_mod_seq=True)
#lib._precursor_df['elution_group_idx'] = lib._precursor_df['precursor_idx']

config_update = eval(kwargs['config_update']) if kwargs['config_update'] else None
#config_update = eval(kwargs['config_update']) if kwargs['config_update'] else None

plan = Plan(
kwargs['file'],
kwargs['config_path'],
kwargs['config_update_path'],
files,
None,
None,
config_update
)
plan.from_spec_lib_base(lib)

plan.run(
kwargs['output_location'],
output_location,
keep_decoys = kwargs['keep_decoys'],
fdr = kwargs['fdr'],
figure_path = kwargs['figure_path'],
Expand Down
Loading

0 comments on commit 2effbb7

Please sign in to comment.