def run_scrape( name: str, input_specification: Path, jobs: int, minscans: int, scanwindow: int, mztol: float, minintensity: int, minrt: float, configfile: Optional[Path] = None, ): """Collects relevant scan data for all members of the ground truth feature list""" click.echo(f"Running scrape for {name} using {input_specification}") spec = InputSpec.from_csv(input_specification) config = get_config(configfile, mztol=mztol) source_dir = Path(name.replace(" ", "_")) core.isotope_scraper( input_spec=spec, source_dir=source_dir, exp_name=name, n_jobs=jobs, min_scans=minscans, scanwindow=scanwindow, min_intensity=minintensity, min_rt=minrt, config=config, )
def test_get_filepath_info(): inp = InputSpec.from_csv(TESTFILE) data = inp.get_filepath_info( Path("tests/test_files/full_scan_labelled_rep3.mzml")) assert data["organism"] == "ORG1" assert data["type"] == "s" assert data["isotope"] == 13 assert data["element"] == "C" assert data["condition"] == "COND1"
def test_get_feature_filepaths_blanks(): inp = InputSpec.from_csv(TESTFILE) expected = list( map( Path, [ "tests/test_files/blanks_rep1.csv", "tests/test_files/blanks_rep2.csv" ], )) assert expected == inp.get_feature_filepaths("blank")
def test_get_scan_filepaths(): inp = InputSpec.from_csv(TESTFILE) expected = list( map( Path, [ "tests/test_files/full_scan_nat_rep1.mzml", "tests/test_files/full_scan_nat_rep2.mzml", "tests/test_files/full_scan_nat_rep3.mzml", ], )) assert expected == inp.get_scan_filepaths("12cond1")
def test_get_feature_filepaths_condition(): inp = InputSpec.from_csv(TESTFILE) expected = list( map( Path, [ "tests/test_files/feature_list_rep1.csv", "tests/test_files/feature_list_rep2.csv", "tests/test_files/feature_list_rep3.csv", ], )) assert expected == inp.get_feature_filepaths("cond1")
def run_validate( name: str, input_specification: Path, configfile: Optional[Path] = None ): """ Performs some simple checks on your input specification file """ click.echo(f"Running validation for {name} on {input_specification}") spec = InputSpec.from_csv(input_specification) try: core.validate_input(spec) click.echo(click.style("Validation successful! ✅", fg="green")) except AssertionError as e: click.echo(click.style("Validation failed... ❌", fg="red"), err=True) sys.exit(1)
def run_analyze( name: str, input_specification: Path, jobs: int, minscans: int, minconditions: int, configfile: Optional[Path] = None, ): """Performs Stable Isotope Labelling detecting and analysis""" click.echo(f"Running analysis for {name} using {input_specification}") spec = InputSpec.from_csv(input_specification) source_dir = Path(name.replace(" ", "_")) core.isotope_label_detector( input_spec=spec, source_dir=source_dir, exp_name=name, min_scans=minscans, num_cond=minconditions, n_jobs=jobs, )
def run_prep( name: str, input_specification: Path, jobs: int, blank_remove: bool, minreps: int, mztol: int, rttol: int, configfile: Optional[Path] = None, ): """Prepares the ground truth feature list""" click.echo(f"Running prep for {name} using {input_specification}") spec = InputSpec.from_csv(input_specification) config = get_config(configfile, minreps=minreps, mztol=mztol, rttol=rttol) source_dir = Path(name.replace(" ", "_")) core.generate_featurelist( input_spec=spec, source_dir=source_dir, exp_name=name, n_jobs=jobs, config=config, blank_remove=blank_remove, )
def test_csv_factory(): inp = InputSpec.from_csv(TESTFILE) assert isinstance(inp, InputSpec) assert isinstance(inp.df, pd.DataFrame)
def test_validate_success(): inp = InputSpec.from_csv(TESTFILE) print(inp.df.head()) assert inp.validate()
def test_get_filepath_info_missing(): inp = InputSpec.from_csv(TESTFILE) data = inp.get_filepath_info("MISSING") assert len(data) == 0
def test_get_conditions(): inp = InputSpec.from_csv(TESTFILE) expected = ["COND1"] assert expected == inp.get_conditions()