Skip to content

Preserve extra_fields when add_missing_atoms is set to True #56

Closed

Description

@MrGreyfun

Hello, thank you for developing this useful project.

When using the parse function from atomworks.io.parser, extra fields will be removed if add_missing_atoms is set to True. It would be helpful if these extra_fields could be preserved, as they often contain necessary information (e.g. auth_asym_id is frequently used).

For atoms that are added because they were missing in the original mmCIF or PDB file, the corresponding extra_fields could be filled with nan or another placeholder value if the data is not available in the source file.

Would it be possible to update the behavior so that extra_fields are retained rather than deleted in such cases?

Activity

  1. nscorley commented on Oct 28, 2025

    @nscorley
    Collaborator

    We've talked about this in the past, and certainly run into it in our own work. It's a good point. I think the behavior you suggested is reasonable -- providing a default for the extra annotations (e.g., in parse, we can already specify extra_annotations; we could extend to support pairs of (annotation, default value). We will probably get around to this within the next few months, but would also absolutely welcome a PR if you're interested in contributing! @Croydon-Brixton @RafiBrent other thoughts?

  2. RafiBrent commented on Oct 28, 2025

    @RafiBrent
    Contributor

    Sounds like a good feature, thanks for bringing this up! I'd say that the default should still be to remove extra_fields if no defaults are specified, to avoid unexpected behavior. But when we give the warning that the extra fields will be removed, we could also describe the procedure for specifying defaults so that users are aware of the option.

  3. nscorley commented on Dec 15, 2025

    @nscorley
    Collaborator

    This is addressed in an upcoming release

  4. nscorley commented on Oct 5, 2026

    @nscorley
    Collaborator

    Addressed in #116. Supply defaults through ParseConfig.extra_fields, e.g. {"atom_id": {"default": -1, "dtype": np.int64}}. Existing values survive missing-atom rebuilding; added atoms receive the default. Fields without explicit defaults are still skipped during completion. Regression test and usage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions