@Test public final void testNormalize2() { Model model = BioPAXLevel.L3.getDefaultFactory().createModel(); Xref ref = model.addNew(UnificationXref.class, "Xref1"); ref.setDb("uniprotkb"); // will be converted to 'uniprot' ref.setId("Q0VCL1"); Xref uniprotX = ref; ProteinReference pr = model.addNew(ProteinReference.class, "ProteinReference"); pr.setDisplayName("ProteinReference"); pr.addXref(uniprotX); ref = model.addNew(RelationshipXref.class, "Xref2"); ref.setDb("refseq"); ref.setId("NP_001734"); pr.addXref(ref); // normalizer won't merge diff. types of xref with the same db:id ref = model.addNew(PublicationXref.class, "Xref3"); ref.setDb("pubmed"); ref.setId("2549346"); // the same id pr.addXref(ref); ref = model.addNew(RelationshipXref.class, "Xref4"); ref.setDb("pubmed"); ref.setId("2549346"); // the same id pr.addXref(ref); Normalizer normalizer = new Normalizer(); normalizer.normalize(model); ProteinReference e = (ProteinReference) model.getByID("http://identifiers.org/uniprot/Q0VCL1"); assertNotNull(e); assertEquals(4, e.getXref().size()); // print(e, model); }
@Test public final void testNormalize3() { Model model = BioPAXLevel.L3.getDefaultFactory().createModel(); Xref ref = model.addNew(UnificationXref.class, "Xref1"); ref.setDb("uniprotkb"); // will be converted to 'uniprot' ref.setId("Q0VCL1"); ProteinReference pr = model.addNew(ProteinReference.class, "ProteinReference1"); pr.setDisplayName("A ProteinReference"); pr.addXref(ref); assertEquals(1, ref.getXrefOf().size()); // System.out.println("Before the model is normalized - "); // print(pr, model); // go normalize! Normalizer normalizer = new Normalizer(); normalizer.normalize(model); // System.out.println("After the model is normalized - "); // print(pr, model); assertFalse(model.contains(pr)); // replaced by new norm. PR in the model assertFalse(model.contains(ref)); // replaced by new norm. xref in the model // now xrefOf is consistent with xref for all objects inn the model (since after some paxtools // 4.1.3 snapshot) assertEquals(0, pr.getXref().size()); // old PR has xref removed! assertEquals( 0, ref.getXrefOf().size()); // because the old xref was replaced in all parent elements! ProteinReference e = (ProteinReference) model.getByID("http://identifiers.org/uniprot/Q0VCL1"); assertNotNull(e); assertEquals(1, e.getXref().size()); String normUri = Normalizer.uri(model.getXmlBase(), "UNIPROT", "Q0VCL1", UnificationXref.class); ref = (UnificationXref) model.getByID(normUri); assertNotNull(ref); assertEquals(1, ref.getXrefOf().size()); // print(e, model); }