@Override
 protected void writeAttributes(ParticipantEvidence object) throws XMLStreamException {
   // write attributes
   Stoichiometry stc = object.getStoichiometry();
   Collection<Annotation> noExportAnnotations =
       AnnotationUtils.collectAllAnnotationsHavingTopic(
           object.getAnnotations(), null, "no-export");
   Collection<Annotation> exportAnnotations = new ArrayList<Annotation>(object.getAnnotations());
   exportAnnotations.removeAll(noExportAnnotations);
   if (!exportAnnotations.isEmpty()) {
     // write start attribute list
     getStreamWriter().writeStartElement("attributeList");
     for (Object ann : exportAnnotations) {
       getAttributeWriter().write((Annotation) ann);
     }
     // write stoichiometry attribute if not null
     writeOtherAttributes(object, false);
     // write end attributeList
     getStreamWriter().writeEndElement();
   }
   // write stoichiometry attribute if not null
   else {
     writeOtherAttributes(object, true);
   }
 }
 @Override
 protected void writeXref(ParticipantEvidence object) throws XMLStreamException {
   if (object instanceof IntactParticipantEvidence) {
     IntactParticipantEvidence intactParticipant = (IntactParticipantEvidence) object;
     if (intactParticipant.getAc() != null) {
       writeIntactAc("primaryRef", intactParticipant.getAc());
       if (!object.getXrefs().isEmpty()) {
         writeXrefFromIntactParticipantXrefs(object);
       }
     } else if (!object.getXrefs().isEmpty()) {
       writeXrefFromParticipantXrefs(object);
     }
   } else {
     super.writeXref(object);
   }
 }
  protected void writeXrefFromIntactParticipantXrefs(ParticipantEvidence object)
      throws XMLStreamException {
    Iterator<Xref> refIterator = object.getXrefs().iterator();
    // default qualifier is null as we are not processing identifiers
    getXrefWriter().setDefaultRefType(null);
    getXrefWriter().setDefaultRefTypeAc(null);
    // write start xref
    getStreamWriter().writeStartElement("xref");

    while (refIterator.hasNext()) {
      Xref ref = refIterator.next();
      // write secondaryref
      getXrefWriter().write(ref, "secondaryRef");
    }

    // write end xref
    getStreamWriter().writeEndElement();
  }
  @Test
  @Ignore
  public void test_write_interaction_inferred()
      throws XMLStreamException, IOException, IllegalRangeException {
    BinaryInteractionEvidence interaction = new DefaultNamedBinaryInteractionEvidence();
    ParticipantEvidence participant =
        new DefaultNamedParticipantEvidence(InteractorUtils.createUnknownBasicInteractor());
    ParticipantEvidence participant2 =
        new DefaultNamedParticipantEvidence(InteractorUtils.createUnknownBasicInteractor());
    ParticipantEvidence participant3 =
        new DefaultNamedParticipantEvidence(InteractorUtils.createUnknownBasicInteractor());
    ParticipantEvidence participant4 =
        new DefaultNamedParticipantEvidence(InteractorUtils.createUnknownBasicInteractor());
    // two inferred interactiosn f1, f2, f3 and f3,f4
    FeatureEvidence f1 = new DefaultFeatureEvidence();
    f1.getRanges().add(RangeUtils.createRangeFromString("1-4"));
    FeatureEvidence f2 = new DefaultFeatureEvidence();
    f2.getRanges().add(RangeUtils.createRangeFromString("1-4"));
    FeatureEvidence f3 = new DefaultFeatureEvidence();
    f1.getLinkedFeatures().add(f2);
    f1.getLinkedFeatures().add(f3);
    f2.getLinkedFeatures().add(f1);
    f2.getLinkedFeatures().add(f3);
    f3.getLinkedFeatures().add(f1);
    f3.getLinkedFeatures().add(f2);
    participant.addFeature(f1);
    participant2.addFeature(f2);
    participant3.addFeature(f3);
    interaction.addParticipant(participant);
    interaction.addParticipant(participant2);
    elementCache.clear();

    XmlNamedBinaryInteractionEvidenceWriter writer =
        new XmlNamedBinaryInteractionEvidenceWriter(createStreamWriter(), this.elementCache);
    writer.write(interaction);
    streamWriter.flush();

    Assert.assertEquals(this.interaction_inferred, output.toString());
  }
예제 #5
0
  @Test
  public void test_copy_participant_evidence_properties_create_new_features() {

    ParticipantEvidence sourceParticipant =
        new DefaultParticipantEvidence(InteractorUtils.createUnknownBasicInteractor());
    sourceParticipant.setStoichiometry(new DefaultStoichiometry(3));
    sourceParticipant
        .getCausalRelationships()
        .add(
            new DefaultCausalRelationship(
                new DefaultCvTerm("decrease"), new DefaultParticipant(new DefaultProtein("p1"))));
    sourceParticipant.setBiologicalRole(new DefaultCvTerm("enzyme"));
    sourceParticipant.getAliases().add(new DefaultAlias("test alias"));
    sourceParticipant.getXrefs().add(new DefaultXref(new DefaultCvTerm("test database"), "xxxx"));
    sourceParticipant
        .getAnnotations()
        .add(new DefaultAnnotation(new DefaultCvTerm("test comment"), "comment"));
    sourceParticipant.addFeature(new DefaultFeatureEvidence("test", "test feature"));
    sourceParticipant.setInteraction(new DefaultInteractionEvidence());
    sourceParticipant.setExperimentalRole(new DefaultCvTerm("bait"));
    sourceParticipant.setExpressedInOrganism(new DefaultOrganism(-1));
    sourceParticipant.getExperimentalPreparations().add(new DefaultCvTerm("test preparation"));
    sourceParticipant
        .getConfidences()
        .add(new DefaultConfidence(new DefaultCvTerm("author-score"), "high"));
    sourceParticipant
        .getParameters()
        .add(new DefaultParameter(new DefaultCvTerm("kd"), new ParameterValue(new BigDecimal(3))));

    ParticipantEvidence targetParticipant =
        new DefaultParticipantEvidence(new DefaultProtein("p2"));

    ParticipantCloner.copyAndOverrideParticipantEvidenceProperties(
        sourceParticipant, targetParticipant, true);

    Assert.assertEquals(1, targetParticipant.getFeatures().size());
    Assert.assertFalse(
        targetParticipant.getFeatures().iterator().next()
            == sourceParticipant.getFeatures().iterator().next());
    Assert.assertTrue(
        DefaultFeatureBaseComparator.areEquals(
            targetParticipant.getFeatures().iterator().next(),
            sourceParticipant.getFeatures().iterator().next()));
    Assert.assertTrue(
        targetParticipant.getFeatures().iterator().next().getParticipant() == targetParticipant);
  }