Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

6 implement addpolymerizationreactions class #7

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
from nomad.datamodel.metainfo.annotations import ELNAnnotation, ELNComponentEnum
from nomad.datamodel.metainfo.basesections import (
Activity,
BaseSection,
CompositeSystem,
PubChemPureSubstanceSection,
PublicationReference,
PureSubstanceComponent,
SectionReference,
)
from nomad.metainfo import Quantity, SchemaPackage, SubSection

Expand Down Expand Up @@ -96,11 +98,11 @@ class PolymerizationReaction(Activity, Schema):
description='Reference to the publication containing the data.',
section_def=PublicationReference,
)
extracted_json_data = Quantity(
data_file_name = Quantity(
type=str,
description='Data file containing the extracted data.',
a_eln=ELNAnnotation(
component=ELNComponentEnum.FileEditQuantity,
component=ELNComponentEnum.StringEditQuantity,
),
)

Expand All @@ -117,4 +119,53 @@ def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
super().normalize(archive, logger)


class PolymerizationReactionReference(SectionReference):
reference = SubSection(
section_def=PolymerizationReaction,
description='Reference to the polymerization reaction.',
)


class AddPolymerizationReactions(BaseSection, Schema):
"""
A section to add polymerization reaction entries in the current upload.
Each entry is also referenced in this section.
"""

zip_file = Quantity(
type=str,
description="""
Zip file containing data files in JSON format. Each file contains data for
one polymerization reaction.
""",
a_eln=ELNAnnotation(
component=ELNComponentEnum.FileEditQuantity,
),
)
polymerization_reactions = SubSection(
section_def=PolymerizationReactionReference,
repeats=True,
description='References to polymerization reaction entries.',
)
reprocess = Quantity(
type=bool,
description='Reprocess the zip file to generate entries.',
a_eln=ELNAnnotation(
component=ELNComponentEnum.BoolEditQuantity,
),
default=True,
)

def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
logger.info(
'AddPolymerizationReactions.normalize', parameter=configuration.parameter
)
super().normalize(archive, logger)
if self.zip_file and self.reprocess:
## create entry archives with overwriting
## use generate archive from json
## add the entry to the polymerization_reactions reference list
self.reprocess = False


m_package.__init_metainfo__()
Binary file added tests/data/processed_reactions_small.zip
Binary file not shown.