this should solve the filename problem
This commit is contained in:
@@ -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
|
||||
|
||||
14
src/main.py
14
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")
|
||||
|
||||
Reference in New Issue
Block a user