Пример #1
0
 private void print(XReferrable xr, Model m) {
   System.out.println();
   System.out.println(
       "model="
           + m.contains(xr)
           + ":\t"
           + xr.getUri()
           + " is "
           + xr.getModelInterface().getSimpleName()
           + " and has xrefs: ");
   for (Xref x : xr.getXref()) {
     System.out.println(
         "model="
             + m.contains(x)
             + ":\t"
             + "  "
             + x
             + " is "
             + x.getModelInterface().getSimpleName()
             + " - "
             + x.getUri()
             + ", db="
             + x.getDb()
             + ", id="
             + x.getId()
             + ", idVer="
             + x.getIdVersion());
     for (XReferrable rx : x.getXrefOf()) {
       System.out.println("model=" + m.contains(rx) + ":\t" + "    xrefOf: " + rx);
     }
   }
 }
Пример #2
0
  @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);
  }