protected static void replaceXrefsWithRelatedER ( Collection < BioPAXElement > elements ) { Set < EntityReference > ers = new HashSet < EntityReference > ( ) ; Set < Xref > xrefs = new HashSet < Xref > ( ) ; for ( BioPAXElement element : elements ) { if ( element instanceof Xref ) { xrefs . add ( ( Xref ) element ) ; for ( XReferrable able : ( ( Xref ) element ) . getXrefOf ( ) ) { if ( able instanceof EntityReference ) { ers . add ( ( EntityReference ) able ) ; } } } } elements . removeAll ( xrefs ) ; for ( EntityReference er : ers ) { if ( ! elements . contains ( er ) ) elements . add ( er ) ; } }
Replaces Xref objects with the related EntityReference objects . This is required for the use case when user provides multiple xrefs that point to the same ER .