Example #1
0
 @Test
 public void testGetParticipants() throws Exception {
   MetabolicReaction mock = mock(MetabolicReaction.class);
   MetabolicReaction rxn = new BiochemRxnImpl(mock);
   rxn.getParticipants();
   verify(mock).getParticipants();
 }
Example #2
0
  public MetabolicReaction parseTwoSidedReaction(
      PreparsedReaction preparsed, String[] equationSides) throws UnparsableReactionError {

    Matcher reactionCompartment = REACTION_COMPARTMENT.matcher(equationSides[0]);

    MetabolicReaction rxn = getReaction(preparsed);

    Compartment defaultCompartment = Organelle.CYTOPLASM;

    if (reactionCompartment.find()) {
      defaultCompartment = resolver.getCompartment(reactionCompartment.group(1));
      equationSides[0] = reactionCompartment.replaceAll("");
    }

    for (MetabolicParticipantImplementation p :
        parseParticipants(equationSides[0], defaultCompartment, preparsed)) {
      rxn.addReactant(p);
    }
    for (MetabolicParticipantImplementation p :
        parseParticipants(equationSides[1], defaultCompartment, preparsed)) {
      rxn.addProduct(p);
    }

    return rxn;
  }
Example #3
0
  @Test
  public void testSetAbbreviation() throws Exception {
    MetabolicReaction mock = mock(MetabolicReaction.class);
    MetabolicReaction rxn = new BiochemRxnImpl(mock);

    rxn.setAbbreviation("b");
    verify(mock).setAbbreviation("b");
  }
Example #4
0
  @Test
  public void testGetAnnotationsExtending() throws Exception {
    MetabolicReaction mock = mock(MetabolicReaction.class);
    MetabolicReaction rxn = new BiochemRxnImpl(mock);

    rxn.getAnnotationsExtending(CrossReference.class);
    verify(mock).getAnnotationsExtending(CrossReference.class);
  }
Example #5
0
  @Test
  public void testUuid() throws Exception {
    MetabolicReaction mock = mock(MetabolicReaction.class);
    MetabolicReaction rxn = new BiochemRxnImpl(mock);

    rxn.uuid();
    verify(mock).uuid();
  }
Example #6
0
  @Test
  public void testGetObservationManager() throws Exception {
    MetabolicReaction mock = mock(MetabolicReaction.class);
    MetabolicReaction rxn = new BiochemRxnImpl(mock);

    rxn.getObservationManager();
    verify(mock).getObservationManager();
  }
Example #7
0
  @Test
  public void testHasAnnotation_Class() throws Exception {
    MetabolicReaction mock = mock(MetabolicReaction.class);
    MetabolicReaction rxn = new BiochemRxnImpl(mock);

    rxn.hasAnnotation(CrossReference.class);
    verify(mock).hasAnnotation(CrossReference.class);
  }
Example #8
0
  @Test
  public void testSetDirection() throws Exception {
    MetabolicReaction mock = mock(MetabolicReaction.class);
    MetabolicReaction rxn = new BiochemRxnImpl(mock);

    rxn.setDirection(Direction.FORWARD);
    verify(mock).setDirection(Direction.FORWARD);
  }
Example #9
0
  @Test
  public void testAddProduct_Metabolite() throws Exception {
    MetabolicReaction mock = mock(MetabolicReaction.class);
    MetabolicReaction rxn = new BiochemRxnImpl(mock);

    Metabolite m = mock(Metabolite.class);
    rxn.addProduct(m);
    verify(mock).addProduct(m);
  }
Example #10
0
  @Test
  public void testRemove() throws Exception {
    MetabolicReaction mock = mock(MetabolicReaction.class);
    MetabolicReaction rxn = new BiochemRxnImpl(mock);

    Metabolite m = mock(Metabolite.class);
    rxn.remove(m);
    verify(mock).remove(m);
  }
Example #11
0
  @Test
  public void testSetIdentifier() throws Exception {
    Identifier id = mock(Identifier.class);
    MetabolicReaction mock = mock(MetabolicReaction.class);
    MetabolicReaction rxn = new BiochemRxnImpl(mock);

    rxn.setIdentifier(id);
    verify(mock).setIdentifier(id);
  }
Example #12
0
  @Test
  public void testAddAnnotation() throws Exception {
    MetabolicReaction mock = mock(MetabolicReaction.class);
    MetabolicReaction rxn = new BiochemRxnImpl(mock);

    Annotation annotation = mock(Annotation.class);
    rxn.addAnnotation(annotation);
    verify(mock).addAnnotation(annotation);
  }
Example #13
0
  @Test
  @SuppressWarnings("unchecked")
  public void testAddAnnotations() throws Exception {
    MetabolicReaction mock = mock(MetabolicReaction.class);
    MetabolicReaction rxn = new BiochemRxnImpl(mock);

    rxn.addAnnotations(mock(Collection.class));
    verify(mock).addAnnotations(anyCollection());
  }
Example #14
0
  @Test
  public void testRemoveObservation() throws Exception {
    MetabolicReaction mock = mock(MetabolicReaction.class);
    MetabolicReaction rxn = new BiochemRxnImpl(mock);

    Observation obs = mock(Observation.class);

    rxn.removeObservation(obs);
    verify(mock).removeObservation(obs);
  }
Example #15
0
  @Test
  public void testRemoveProduct() throws Exception {
    MetabolicReaction mock = mock(MetabolicReaction.class);
    MetabolicReaction rxn = new BiochemRxnImpl(mock);

    MetabolicParticipant p = mock(MetabolicParticipant.class);

    rxn.removeProduct(p);
    verify(mock).removeProduct(p);
  }
Example #16
0
  /** Only have left side (or some weird reaction operator) */
  public MetabolicReaction parseExchangeReaction(PreparsedReaction reaction, String equationSide)
      throws UnparsableReactionError {
    Matcher reactionCompartment = REACTION_COMPARTMENT.matcher(equationSide);

    MetabolicReaction rxn = getReaction(reaction);

    Compartment defaultCompartment = Organelle.CYTOPLASM;

    if (reactionCompartment.find()) {
      defaultCompartment = resolver.getCompartment(reactionCompartment.group(1));
      equationSide = reactionCompartment.replaceAll("");
    }

    for (MetabolicParticipantImplementation p :
        parseParticipants(equationSide, defaultCompartment, reaction)) {
      rxn.addReactant(p);
    }

    return rxn;
  }
Example #17
0
  public MetabolicReaction getReaction(PreparsedReaction preparsed) {

    MetabolicReaction rxn =
        factory.ofClass(
            MetabolicReaction.class,
            BasicReactionIdentifier.nextIdentifier(),
            preparsed.hasValue(DESCRIPTION) ? preparsed.getValue(DESCRIPTION) : "",
            preparsed.hasValue(ABBREVIATION) ? preparsed.getValue(ABBREVIATION) : "");

    if (preparsed.hasValue(DIRECTION)) {
      rxn.setDirection(getReactionArrow(preparsed.getValue(DIRECTION)));
    } else {
      rxn.setDirection(getReactionArrow(preparsed.getEquation()));
    }

    // add subsytem annotation
    if (preparsed.hasValue(SUBSYSTEM)) {
      rxn.addAnnotation(new Subsystem(preparsed.getSubsystem()));
    }

    // add classification
    for (String classification : preparsed.getClassifications()) {
      // load EC code
      if (classification.matches("(?:\\d+\\.){3}\\d+") || classification.contains("EC")) {
        rxn.addAnnotation(new EnzymeClassification(new ECNumber(classification)));
      } else if (classification.contains("TC")) {
        rxn.addAnnotation(new Classification(new TransportClassificationNumber(classification)));
      }
    }

    // add loci
    for (String locus : preparsed.getLoci()) {
      rxn.addAnnotation(new Locus(locus));
    }

    // add delta g and delta g error
    if (preparsed.hasValue(FREE_ENERGY)) {
      try {
        if (preparsed.hasValue(FREE_ENERGY_ERROR)) {
          rxn.addAnnotation(
              new GibbsEnergy(
                  Double.parseDouble(preparsed.getValue(FREE_ENERGY)),
                  Double.parseDouble(preparsed.getValue(FREE_ENERGY_ERROR))));
        } else {
          rxn.addAnnotation(
              new GibbsEnergy(Double.parseDouble(preparsed.getValue(FREE_ENERGY)), 0d));
        }
      } catch (NumberFormatException ex) {
        LOGGER.error("Gibbs energy column(s) contained invalid value (not a double)");
      }
    }

    if (preparsed.hasValue(MIN_FLUX)) {
      try {
        rxn.addAnnotation(new FluxLowerBound(Double.parseDouble(preparsed.getValue(MIN_FLUX))));
      } catch (NumberFormatException ex) {
        LOGGER.error(
            "Min flux column contained invalid value (not a double): "
                + preparsed.getValue(MIN_FLUX));
      }
    }

    if (preparsed.hasValue(MAX_FLUX)) {
      try {
        rxn.addAnnotation(new FluxLowerBound(Double.parseDouble(preparsed.getValue(MAX_FLUX))));
      } catch (NumberFormatException ex) {
        LOGGER.error(
            "Max flux column contained invalid value (not a double): "
                + preparsed.getValue(MAX_FLUX));
      }
    }

    return rxn;
  }