Skip to content

Commit

Permalink
begin work on looper link #72
Browse files Browse the repository at this point in the history
  • Loading branch information
donaldcampbelljr committed Oct 12, 2023
1 parent f8a93fc commit 2935a23
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 0 deletions.
59 changes: 59 additions & 0 deletions looper/cli_looper.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def add_subparser(cmd):
inspect_subparser = add_subparser("inspect")
init_subparser = add_subparser("init")
init_piface = add_subparser("init-piface")
#link_subparser = add_subparser("link")

# Flag arguments
####################################################################
Expand Down Expand Up @@ -314,6 +315,58 @@ def add_subparser(cmd):
action="store_true",
default=False,
)
#
# link_subparser.add_argument(
# "-o",
# "--output-dir",
# dest="output_dir",
# metavar="DIR",
# default=None,
# type=str,
# )
#
# link_subparser.add_argument(
# "--looper-config",
# required=False,
# default=None,
# type=str,
# help="Looper configuration file (YAML)",
#
# )
#
# link_subparser.add_argument(
# "config_file",
# nargs="?",
# default=None,
# help="Project configuration file (YAML) or pephub registry path.",
#
# )
# link_subparser.add_argument(
# "-a",
# "--amend",
# nargs = "+",
# metavar = "A",
# help = "List of amendments to activate",
# )
# link_subparser.add_argument(
# f"--{SAMPLE_SELECTION_ATTRIBUTE_OPTNAME}",
# default="toggle",
# metavar="ATTR",
# help="Attribute for sample exclusion OR inclusion",
# )
# #protocols = fetch_samples_group.add_mutually_exclusive_group()
# link_subparser.add_argument(
# f"--{SAMPLE_EXCLUSION_OPTNAME}",
# nargs="*",
# metavar="E",
# help="Exclude samples with these values",
# )
# link_subparser.add_argument(
# f"--{SAMPLE_INCLUSION_OPTNAME}",
# nargs="*",
# metavar="I",
# help="Include only samples with these values",
# )

# Common arguments
for subparser in [
Expand Down Expand Up @@ -724,6 +777,12 @@ def main(test_args=None):
else:
raise PipestatConfigurationException("report")

if args.command == "link":
if use_pipestat:
Linker(prj)(args)
else:
raise PipestatConfigurationException("link")

if args.command == "check":
if use_pipestat:
return Checker(prj)(args)
Expand Down
1 change: 1 addition & 0 deletions looper/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,4 +258,5 @@ def _get_apperance_dict(type, templ=APPEARANCE_BY_FLAG):
"inspect": "Print information about a project.",
"init": "Initialize looper config file.",
"init-piface": "Initialize generic pipeline interface.",
"link": "Create directory of symlinks for reported results."
}
26 changes: 26 additions & 0 deletions looper/looper.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,32 @@ def __call__(self, args):
psm.summarize()


class Linker(Executor):
"""Create symlinks for reported results. Requires pipestat to be configured."""

def __call__(self, args):
# initialize the report builder
p = self.prj
project_level = args.project
link_dir = args.output_dir

if project_level:
psms = self.prj.get_pipestat_managers(project_level=True)
for name, psm in psms.items():
psm.link(link_dir=link_dir)
else:
for piface_source_samples in self.prj._samples_by_piface(
self.prj.piface_key
).values():
# For each piface_key, we have a list of samples, but we only need one sample from the list to
# call the related pipestat manager object which will pull ALL samples when using psm.summarize
first_sample_name = list(piface_source_samples)[0]
psms = self.prj.get_pipestat_managers(
sample_name=first_sample_name, project_level=False
)
for name, psm in psms.items():
psm.link(link_dir=link_dir)

class Tabulator(Executor):
"""Project/Sample statistics and table output generator
Expand Down

0 comments on commit 2935a23

Please sign in to comment.