diff --git a/output/sample-Na-26-015-nexus.nx b/output/sample-Na-26-015-nexus.nx deleted file mode 100644 index 533a243..0000000 Binary files a/output/sample-Na-26-015-nexus.nx and /dev/null differ diff --git a/src/classes.py b/src/classes.py index 98a4883..813a7fa 100644 --- a/src/classes.py +++ b/src/classes.py @@ -224,6 +224,7 @@ class Entrypoint: self.extra = sample_data["metadata_decoded"]["extra_fields"] self.linked_items = sample_data["items_links"] # dict self.batch_elabid = self.extra["Substrate batch"]["value"] # elabid + self.proposal = self.extra["Proposal"].get("value") or None # proposal self.linked_experiments = sample_data["related_experiments_links"] # dict self.linked_experiments_elabid = [ i["entityid"] for i in self.linked_experiments diff --git a/src/main.py b/src/main.py index 8e1c868..0cbc2a3 100755 --- a/src/main.py +++ b/src/main.py @@ -877,12 +877,22 @@ if __name__ == "__main__": data = handler.get_entry_from_elabid(elabid) sample = Entrypoint(data) sample_name = sample.name.strip().replace(" ", "_") + if sample.proposal: + sample_proposal = sample.proposal.strip().replace(" ", "_") + else: + sample_proposal = None substrate_object = chain_entrypoint_to_batch(sample) # Substrate-class object layers = chain_entrypoint_to_layers(sample) # list of Layer-class objects n_layers = len(layers) # total number of layers on the sample result = make_nexus_schema_dictionary(substrate_object, layers) # print(make_nexus_schema_dictionary(substrate_object, layers)) # debug - with open(f"output/sample-{sample_name}.json", "w") as f: + fn_base = ( + "nffa-di_" + + (f"{sample_proposal}_" if sample_proposal else "") + + "Napoli_" + + sample_name + ) + with open(f"output/{fn_base}.json", "w") as f: json.dump(result, f, indent=3) # TO-DO: remove the hard-coded path of the RWA file # ideally the script should download a TXT/CSV file from each layer @@ -895,4 +905,4 @@ if __name__ == "__main__": # In this test I will only consider one image. # TO-DO: make it format-agnostic. If not possible, make it PNG-only. # mx = mx.astype(np.float32) / 255.0 # consider deleting??? - build_nexus_file(result, output_path=f"output/sample-{sample_name}-nexus.nx") + build_nexus_file(result, output_path=f"output/{fn_base}.h5")