Skip to content

Commit

Permalink
Merge pull request #4 from haniffalab/hist
Browse files Browse the repository at this point in the history
Added history command
  • Loading branch information
vjbaskar authored Sep 6, 2024
2 parents 631aabf + 1617c46 commit 246a110
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 22 deletions.
2 changes: 1 addition & 1 deletion bin/cmdbase/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from . import alignment, irods, rna
from . import alignment, irods, rna, basic
from .helpers import *
1 change: 1 addition & 0 deletions bin/cmdbase/basic/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .history import *
32 changes: 32 additions & 0 deletions bin/cmdbase/basic/history.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env python3

import click
import os
from tabulate import tabulate
import pandas as pd

@click.command("history")

@click.option("--last", required=False, help="Retrieve last n commands",
default=10, type = int)

@click.option(
"--all",
default=False,
is_flag=True,
required=False,
help="Retrieve all history",
)

def history(last, all):
CWD = os.environ['CWD']
hist_file = os.path.join(CWD, ".pap/") + "hist"
if not os.path.exists(hist_file):
click.echo("No history file present")
return 0
hist = pd.read_csv(hist_file, index_col = 0)
if all:
print(tabulate(hist, headers='keys', tablefmt='plain'))
else:
print(tabulate(hist.tail(last), headers='keys', tablefmt='plain'))
return 0
9 changes: 9 additions & 0 deletions bin/cmdbase/basic/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env python3

import click


@click.command("test_import")
def test_import1():
print("Hello World")
return 0
8 changes: 6 additions & 2 deletions bin/hl..piperv100
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ os.environ["GLOBAL_HIST"] = GLOBAL_HIST
os.environ["LOCAL_HIST"] = LOCAL_HIST
os.environ["VERSION"] = VERSION
os.environ["RUN_TOKEN"] = RUN_TOKEN
os.environ["CWD"] = CWD
#### Create options that can common to all ####


Expand Down Expand Up @@ -115,15 +116,18 @@ def argtest(user_params, **kwargs):

####

################# basic commands ###########
cli.add_command(cmdbase.basic.history)


################ irods commands ################
irods.add_command(cmdbase.irods.pull_processed)
irods.add_command(cmdbase.irods.pull_fastqs)

################### scrna seq analysis commands ###################
################# scrna seq analysis commands ##
rna.add_command(cmdbase.rna.cellbender)

################# alignment commands ###################
################# alignment commands ###########
alignment.add_command(cmdbase.alignment.cellranger)
alignment.add_command(cmdbase.alignment.starsolo)

Expand Down
19 changes: 0 additions & 19 deletions bin/test1.py

This file was deleted.

0 comments on commit 246a110

Please sign in to comment.