Exemple #1
0
    def info(self, lims_json_path):
        ''' return a string that a bash script can use
        to find the working directory, etc. to clean up.
        '''
        ocr = OptimizeConfigReader()
        ocr.read_lims_file(lims_json_path)

        print(self.app_config.data['runs'][0]['specimen_id'])
        print(self.manifest.get_path('BASEDIR'))
Exemple #2
0
def one_param_config():
    ocr = OptimizeConfigReader()

    lims_json_path = 'lims_message.json'
    
    with patch(builtins.__name__ + ".open",
               mock_open(read_data=LIMS_MESSAGE_ONE_PARAM_FILE)):
        ocr.read_lims_file(lims_json_path)
    
    return ocr
Exemple #3
0
def no_param_config():
    json_data = json.loads(LIMS_MESSAGE_ONE_PARAM_FILE)
    json_data['well_known_files'] = []
    lims_message_no_param_file = json.dumps(json_data)
    ocr = OptimizeConfigReader()

    lims_json_path = 'lims_message.json'
    
    with patch(builtins.__name__ + ".open",
               mock_open(read_data=lims_message_no_param_file)):
        ocr.read_lims_file(lims_json_path)
    
    return ocr
Exemple #4
0
    def make_fit(self):
        self.load_manifest()

        fit_types = ["f9", "f13"]

        best_fit_values = {fit_type: None for fit_type in fit_types}

        specimen_id = self.app_config.data['runs'][0]['specimen_id']

        for fit_type in fit_types:
            fit_type_dir = self.manifest.get_path('fit_type_path', fit_type)

            if os.path.exists(fit_type_dir):
                report = Report(self.app_config, fit_type)
                report.generate_fit_file()
                if fit_type in best_fit_values.keys():
                    best_fit_values[fit_type] = report.best_fit_value()

        best_fit_type, min_fit_value = reduce(
            lambda a, b: a if (a[1] < b[1]) else b,
            (i for i in best_fit_values.items() if i[1] is not None))
        best_fit_file = self.manifest.get_path('output_fit_file', specimen_id,
                                               best_fit_type)

        lims_upload_config = OptimizeConfigReader()
        lims_upload_config.read_json(
            self.manifest.get_path('neuronal_model_data'))

        lims_upload_config.update_well_known_file(
            best_fit_file,
            well_known_file_type_id=OptimizeConfigReader.
            NEURONAL_MODEL_PARAMETERS)
        lims_upload_config.write_file(output_json)
Exemple #5
0
    def generate_manifest_lims(self, lims_json_path, manifest_path):
        '''
        Note
        ----
        Other necessary files are also written.
        '''
        ocr = OptimizeConfigReader()
        ocr.read_lims_file(lims_json_path)

        ocr.to_manifest(manifest_path)
Exemple #6
0
    def generate_manifest_rma(self,
                              neuronal_model_id,
                              manifest_path,
                              api_url=None):
        '''
        Note
        ----
        Other necessary files are also written.
        '''
        import json
        from allensdk.api.api import Api

        bma = BiophysicalModuleApi(api_url)
        data = bma.get_neuronal_models(neuronal_model_id)

        ocr = OptimizeConfigReader()
        ocr.read_lims_message(data, 'lims_message.json')

        with open('lims_message.json', 'w') as f:
            f.write(json.dumps(data[0], sort_keys=True, indent=2))

        ocr.to_manifest(manifest_path)