Skip to content

Added 1 missing validation rule (layout)#73

Open
UnsharpenedSpear wants to merge 4 commits intosbgn:masterfrom
UnsharpenedSpear:master
Open

Added 1 missing validation rule (layout)#73
UnsharpenedSpear wants to merge 4 commits intosbgn:masterfrom
UnsharpenedSpear:master

Conversation

@UnsharpenedSpear
Copy link

Summary

This PR implements a missing layout validation rule from the SBGN Activity Flow Level 1 Version 1.2 specification in the sbgn_af.sch Schematron rules.

New rule added

af10115: Prohibit overlapping Activity Flow nodes


Detailed Changes

Rule: No Overlapping Activity Nodes (af10115)

Spec Reference: SBGN Activity Flow Level 1 Version 1.2 — Layout constraints

Illegal overlapping nodes are not allowed in SBGN Activity Flow diagrams.


Implementation

The rule checks that Activity Flow node glyphs do not spatially overlap.

The following glyph classes are validated:

  • biological activity
  • phenotype
  • submap
  • and
  • or
  • not
  • delay

For each glyph, the rule:

  1. Retrieves its bounding box (sbgn:bbox)
  2. Compares it with subsequent AF glyph bounding boxes
  3. Uses axis-aligned rectangle intersection logic
  4. Reports an error if any overlap (including edge-touching) is detected

The following:: axis is used to avoid symmetric duplicate checks and improve evaluation efficiency.


Example Violation

<glyph id="glyph1" class="biological activity">
    <bbox x="26" y="30" w="108" h="60"/>
</glyph>

<glyph id="glyph2" class="biological activity">
    <bbox x="26" y="30" w="108" h="60"/> <!-- ERROR -->
</glyph>

This results in:

af10115: Illegal overlapping nodes are not allowed in SBGN AF.

Verification

Validation was performed using the Schematron compilation and validation commands described in the libSBGN repository README.

To streamline testing, these commands were wrapped in a small helper script (validate.py) that automates:

  • Schematron compilation (include expansion, abstract pattern expansion, SVRL stylesheet generation)
  • Batch validation of SBGN test files
  • SVRL report generation

Test Cases

  • Overlapping biological activity glyphs

    • Correctly triggered af10115
    • Diagnostic reported the failing glyph ID
  • Non-overlapping glyphs

    • Passed validation

All existing AF validation tests passed successfully.


Notes

  • The rule relies on sbgn:bbox geometry, consistent with SBGN-ML layout encoding.
  • Diagnostics currently report only the failing glyph ID.
  • If preferred, diagnostics can be extended to report conflicting glyph IDs in a follow-up change.

Impact

This PR improves Activity Flow layout validation by enforcing a specification constraint that was previously not checked, helping detect diagram layout errors early in the validation pipeline.

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.

1 participant