moved scanpy parser to scanpy class

This commit is contained in:
Charlotte Weaver
2018-08-07 16:37:02 -07:00
parent 0969854e9e
commit 499b9551f1
2 changed files with 13 additions and 3 deletions
+6 -3
View File
@@ -63,8 +63,11 @@ def main():
"of the directory from the data_directory arg")
parser.add_argument("--port", help="Port to run server on.", type=int, default=5005)
subparsers = parser.add_subparsers(dest="cellxgene_command")
scanpy_subparser = subparsers.add_parser("scanpy", help="run cellxgene using the scanpy engine")
scanpy_subparser.add_argument("data_directory", metavar="dir", help="Directory containing data and schema file")
scanpy_subparser.set_defaults(func=run_scanpy)
try:
from .scanpy_engine.scanpy_engine import ScanpyEngine
ScanpyEngine.add_to_parser(subparsers, run_scanpy)
except ImportError:
print("Scanpy engine not available")
args = parser.parse_args()
args.func(args)
@@ -23,6 +23,13 @@ class ScanpyEngine(CXGDriver):
def _set_cell_names(self):
self.data.obs["cell_name"] = list(self.data.obs.index)
@classmethod
def add_to_parser(cls, subparsers, invocation_function):
scanpy_group = subparsers.add_parser("scanpy", help="run cellxgene using the scanpy engine")
scanpy_group.add_argument("data_directory", metavar="dir", help="Directory containing data and schema file")
scanpy_group.set_defaults(func=invocation_function)
return scanpy_group
@staticmethod
def _load_data(data):
return sc.read(os.path.join(data, "data.h5ad"))