-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In this commit, I created the `macta-tools` CLI. Additionally, I added another field to the `CTAToolInterface` class called `_required_kwargs` - a list of strings that represent the names of the kwargs that the tool must be passed, simplifying the syntax to do so. Consequently, the `NotNoneRequirement` and its related files are no longer needed, so I deleted them. I also added improved the logging suppression in the SCANVI interface file. I added some small tweaks to the project configuration to re-add line length checks and to configure where pyright searches for issues.
- Loading branch information
1 parent
9fe04e5
commit f51340b
Showing
15 changed files
with
151 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
exclude: ["./build/**", "**/__pycache__", "**/.*"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
from macta_tools import tools, utils | ||
from macta_tools._annotate import annotate | ||
from macta_tools._cli import run_from_cli | ||
from macta_tools._cli import main as cli_main | ||
|
||
__all__ = ['annotate', 'tools', 'utils', 'run_from_cli'] | ||
__all__ = ['annotate', 'tools', 'utils', 'cli_main'] | ||
__version__ = '0.0.4' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
from argparse import ArgumentParser, FileType, Namespace | ||
from pathlib import Path | ||
|
||
import scanpy as sc | ||
from pandas.compat.pickle_compat import pkl | ||
|
||
from macta_tools import annotate | ||
|
||
|
||
def parse_args() -> Namespace: | ||
|
||
parser = ArgumentParser('MACTA-tools', description='Tools for cell-type annotation in Python') | ||
|
||
parser.add_argument( | ||
'expr', | ||
# dest='expr_data', | ||
type=FileType(), | ||
) | ||
|
||
parser.add_argument( | ||
'ref', | ||
# dest='ref_data', | ||
type=FileType(), | ||
) | ||
|
||
parser.add_argument( | ||
'annot_type', | ||
choices=['marker', 'ref'] | ||
) | ||
|
||
parser.add_argument( | ||
'convert_to', | ||
choices=['labels', 'scores'], | ||
) | ||
|
||
parser.add_argument( | ||
'output', | ||
# dest='output_path', | ||
type=FileType(), | ||
) | ||
|
||
parser.add_argument( | ||
'-t', '--tools', | ||
nargs='+', | ||
) | ||
|
||
# Tool kwargs | ||
|
||
parser.add_argument( | ||
'--force_update', | ||
type=bool, | ||
) | ||
|
||
parser.add_argument( | ||
'--update_models', | ||
type=bool, | ||
) | ||
|
||
parser.add_argument('--batch_col') | ||
parser.add_argument('--cell_type_col') | ||
|
||
return parser.parse_args() | ||
|
||
|
||
# def read_file(path_name: bytes) -> Union[AnnData, pd.DataFrame, None]: | ||
# | ||
# path = Path(str(path_name)) | ||
# ext = path.suffix | ||
# | ||
# if ext == 'csv': | ||
# return pd.read_csv(path) | ||
# | ||
# if ext == 'tsv': | ||
# return pd.read_csv(path, delimiter='\t') | ||
# | ||
# if ext == 'pkl': | ||
# with path.open('rb') as file: | ||
# return pkl.load(file) | ||
# | ||
# if ext == 'h5ad': | ||
# return sc.read_h5ad(path) | ||
# | ||
# return None | ||
|
||
|
||
def main(): | ||
args = parse_args() | ||
|
||
# print('\nARGUMENTS') | ||
# from pprint import pprint | ||
# pprint(vars(args)) | ||
# print() | ||
|
||
expr_data = sc.read_h5ad(args.expr) | ||
ref_data = sc.read_h5ad(args.ref) | ||
|
||
results = annotate(expr_data, ref_data, **vars(args)) | ||
|
||
with Path(args.output).open('wb') as file: | ||
pkl.dump(results, file) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
from macta_tools.utils.requirements._contains_requirement import ContainsRequirement | ||
from macta_tools.utils.requirements._equality_requirement import EqualityRequirement | ||
from macta_tools.utils.requirements._is_instance_requirement import IsInstanceRequirement | ||
from macta_tools.utils.requirements._not_none_requirement import NotNoneRequirement | ||
from macta_tools.utils.requirements._requirement import Requirement | ||
from macta_tools.utils.requirements._requirement_list import RequirementList | ||
|
||
__all__ = ['Requirement', 'ContainsRequirement', 'IsInstanceRequirement', 'EqualityRequirement', 'RequirementList', 'NotNoneRequirement'] | ||
__all__ = ['Requirement', 'ContainsRequirement', 'IsInstanceRequirement', 'EqualityRequirement', 'RequirementList'] |
13 changes: 0 additions & 13 deletions
13
src/macta_tools/utils/requirements/_not_none_requirement.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.