예제 #1
0
    def prepare_reference(reference_params: dict, location: str, paired: bool):
        ParameterValidator.assert_keys(list(reference_params.keys()), ["format", "params"], location,
                                       "reference")

        seq_import_params = reference_params["params"] if "params" in reference_params else {}

        assert os.path.isfile(seq_import_params["path"]), f"{location}: the file {seq_import_params['path']} does not exist. " \
                                                  f"Specify the correct path under reference."

        if "is_repertoire" in seq_import_params:
            assert seq_import_params["is_repertoire"] == False, f"{location}: is_repertoire must be False for SequenceImport"
        else:
            seq_import_params["is_repertoire"] = False

        if "paired" in seq_import_params:
            assert seq_import_params["paired"] == paired, f"{location}: paired must be {paired} for SequenceImport"
        else:
            seq_import_params["paired"] = paired

        format_str = reference_params["format"]

        import_class = ReflectionHandler.get_class_by_name("{}Import".format(format_str))
        default_params = DefaultParamsLoader.load(EnvironmentSettings.default_params_path / "datasets",
                                          DefaultParamsLoader.convert_to_snake_case(format_str))

        params = {**default_params, **seq_import_params}

        processed_params = DatasetImportParams.build_object(**params)

        receptors = ImportHelper.import_items(import_class, reference_params["params"]["path"], processed_params)

        return receptors
예제 #2
0
    def make_reports_docs(path: Path):
        filename = "reports.rst"
        file_path = path / filename

        with file_path.open("w") as file:
            pass

        for report_type_class in [
                DataReport, EncodingReport, MLReport, TrainMLModelReport,
                MultiDatasetReport
        ]:
            with file_path.open("a") as file:
                doc_format = DocumentationFormat(
                    cls=report_type_class,
                    cls_name=f"**{report_type_class.get_title()}**",
                    level_heading=DocumentationFormat.LEVELS[1])
                write_class_docs(doc_format, file)

            subdir = DefaultParamsLoader.convert_to_snake_case(
                report_type_class.__name__) + "s"

            classes = ReflectionHandler.all_nonabstract_subclasses(
                report_type_class, "", f"reports/{subdir}/")
            make_docs(path, classes, filename, "", "a")