Skip to content

Fix #480: Allow CIF labels to differ from the java field name - #482

Merged
josemduarte merged 2 commits into
biojava:masterfrom
sbliven:fix480
May 20, 2016
Merged

josemduarte merged 2 commits into
biojava:masterfrom
sbliven:fix480

Conversation

@sbliven

@sbliven sbliven commented May 13, 2016

Copy link
Copy Markdown
Member

This provides a general solution to the problem in #480, which is that some CIF labels contain characters not permitted in java identifiers (like hyphens). Thus, a mechanism is needed for mapping java fields to the correct identifier for cases like _symmetry.space_group_name_H-M when writing to mmCIF.

This is implemented by adding two annotations. @CIFLabel(label="str") causes the cif property to be _category.str. @IgnoreField causes the field to be ignored entirely.

This pull also changes the MMCIFFileTools.toMMCIF method to be generic,
so that we enforce at compile time that all loop rows must be of the same type. The old method is deprecated (and should be backwards compatible if I understand type erasure correctly).

sbliven added 2 commits May 13, 2016 13:11
…n CIF output

CIF categories are represented as a simple bean, typically extending AbstractBean.
By default, all fields from the bean are taken as the CIF labels. Fields may be omitted
by annotating them as @IgnoreField. The CIF label for a field may be changed
by defining a function, `static Map<String,String> getCIFLabelMap();`,
mapping from the field's name to the correct label.

This commit also changes the MMCIFFileTools.toMMCIF method to be generic,
so that we enforce at compile time that all loop rows must be of the same type.
This replaces the short-lived getCIFLabelMap static function.
It lets you associate the label directly with the applicable field
@josemduarte

Copy link
Copy Markdown
Contributor

This is awesome! Couldn't we use these annotations also while parsing the files? (not only when writing them).

For instance there's a few fields that contain square brackets, e.g. _pdbx_struct_oper_list.matrix[1][1]. Those are handled in SimpleMMcifParser in special ways (instead of with the generic buildObject method), but it should be possible to handle them like the others via using these annotations, shouldn't it?

@josemduarte

Copy link
Copy Markdown
Contributor

I'm working in using the annotations also from the cif parser. I'll pull request some commits to your branch when I'm ready.

@josemduarte

Copy link
Copy Markdown
Contributor

I'll merge this in. I'll then add a new pull request to deal with reading mmcif files using the new tags.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants