@Test
  public void testDNAtoRNA() {
    BiojavaSequence seq = null;
    try {
      seq = biojava.loadSequence(TestData.getPathToDNAFastaSequence());
    } catch (IOException e1) {
      LogUtils.debugTrace(logger, e1);
      fail(e1.getMessage());
    } catch (Exception e) {
      LogUtils.debugTrace(logger, e);
      fail(e.getMessage());
    }

    assertNotNull(seq);

    assertTrue(seq instanceof BiojavaDNASequence);
    BiojavaDNASequence dnaSeq = (BiojavaDNASequence) seq;

    try {
      assertEquals("GATTACA", seq.getPlainSequence().trim().toUpperCase());
      BiojavaRNASequence rnaSeq;
      rnaSeq = biojava.DNAtoRNA(dnaSeq);
      assertEquals("GAUUACA", rnaSeq.getPlainSequence().trim().toUpperCase());
    } catch (IOException e) {
      LogUtils.debugTrace(logger, e);
      fail(e.getMessage());
    } catch (Exception e) {
      LogUtils.debugTrace(logger, e);
      fail(e.getMessage());
    }
  }
  @Test
  public void testLoadFastaSequences() {
    BiojavaSequence seq = null;
    try {
      // Test read Protein as fasta
      seq = biojava.loadSequence(TestData.getPathToAAFastaSequence());
      assertNotNull(seq);
      assertEquals("SEQUENCE", seq.getPlainSequence().trim().toUpperCase());

      // Test read DNA as fasta
      seq = biojava.loadSequence(TestData.getPathToDNAFastaSequence());
      assertNotNull(seq);
      assertEquals("GATTACA", seq.getPlainSequence().trim().toUpperCase());

      /*
                  //Test read RNA as fasta
                  seq = biojava.loadSequence( TestData.getPathToRNAFastaSequence() );
                  assertNotNull( seq );
                  assertEquals( "GAUUACA", seq.getPlainSequence().trim().toUpperCase() );
      */
    } catch (IOException e) {
      fail(e.getMessage());
    } catch (Exception e) {
      LogUtils.debugTrace(logger, e);
      fail(e.getMessage());
    }
  }
  @Test
  public void testDNAtoProtein() {
    BiojavaSequence seq = null;
    seq = biojava.createSequence("CTCCTCGCGAAACGATACGAT");

    assertNotNull(seq);

    assertTrue(seq instanceof BiojavaDNASequence);
    BiojavaDNASequence dnaSeq = (BiojavaDNASequence) seq;

    try {

      BiojavaAASequence rnaSeq = biojava.DNAToProtein(dnaSeq);
      assertEquals("LLAKRYD", rnaSeq.getPlainSequence().trim().toUpperCase());

    } catch (IOException e) {
      LogUtils.debugTrace(logger, e);
      fail(e.getMessage());
    } catch (Exception e) {
      LogUtils.debugTrace(logger, e);
      fail(e.getMessage());
    }
  }
  @Test
  public void testToFasta() {
    BiojavaSequence seq = null;
    try {
      seq = biojava.loadSequence(TestData.getPathToAAFastaSequence());
      //            seq = biojava.loadSequence( TestData.getPathToFosbFastaSequence() );
    } catch (IOException e) {
      LogUtils.debugTrace(logger, e);
      fail(e.getMessage());
    } catch (Exception e) {
      LogUtils.debugTrace(logger, e);
      fail(e.getMessage());
    }
    assertNotNull(seq);
    //        assertEquals( "Sequence", seq.getName());

    try {
      assertEquals("SEQUENCE", seq.getPlainSequence().trim());
    } catch (IOException e) {
      LogUtils.debugTrace(logger, e);
      fail(e.getMessage());
    }
  }
  /*
      @Test
      public void testRNAtoDNA() {

          BiojavaSequence seq = biojava.createSequence("GAUUACA");

          assertNotNull(seq);

          assertTrue(seq instanceof BiojavaRNASequence);
          BiojavaRNASequence rnaSeq = (BiojavaRNASequence) seq;

          try {
              //Check correctly read
              assertEquals( "GAUUACA", rnaSeq.getPlainSequence().trim().toUpperCase() );

              BiojavaDNASequence dnaSeq = biojava.RNAtoDNA(rnaSeq);

              //Check correctly converted
              assertEquals( "GATTACA", dnaSeq.getPlainSequence().trim().toUpperCase() );
          } catch (IOException e) {
              LogUtils.debugTrace(logger, e);
              fail(e.getMessage());
          } catch (Exception e) {
              LogUtils.debugTrace(logger, e);
              fail(e.getMessage());
          }
      }
  */
  @Test
  public void testLoadFastaSequenceCollection() throws BioclipseException, IOException {
    BiojavaSequenceList sequenceCollection = null;
    sequenceCollection = biojava.loadSequences(TestData.getPathToMultipleSequences());
    assertNotNull(sequenceCollection);
    assertEquals(2, sequenceCollection.size());

    // Check individual sequences
    BiojavaSequence seq1 = sequenceCollection.get(0);
    BiojavaSequence seq2 = sequenceCollection.get(1);

    try {
      assertEquals(341, seq1.getPlainSequence().length());
      assertEquals(342, seq2.getPlainSequence().length());
    } catch (IOException e) {
      LogUtils.debugTrace(logger, e);
      fail(e.getMessage());
    }
  }
Ejemplo n.º 6
0
  public void runTest(
      String testID,
      IMolecule mol,
      IReturner<List<? extends ITestResult>> returner,
      IProgressMonitor monitor)
      throws BioclipseException {

    ICDKManager cdk = net.bioclipse.cdk.business.Activator.getDefault().getJavaCDKManager();

    IDSTest test = getTest(testID);
    List<? extends ITestResult> ret = null;
    try {

      // Preprocess the molecule
      ICDKMolecule cdkmol = cdk.asCDKMolecule(mol);

      // Clone the mol
      IAtomContainer clonedAC = null;
      try {
        clonedAC = (IAtomContainer) cdkmol.getAtomContainer().clone();
      } catch (CloneNotSupportedException e) {
        logger.error("Could not clone mol: " + cdkmol);
        return;
      }

      ICDKMolecule clonedMol = new CDKMolecule(clonedAC);
      ret = test.runWarningTest(clonedMol, monitor);

    } catch (Exception e) {
      // in case of error...
      LogUtils.debugTrace(logger, e);
      ITestResult er = new SimpleResult("Error: " + e.getMessage(), ITestResult.ERROR);
      er.setDetailedMessage(e.getMessage());
      List<ITestResult> trlist = new ArrayList<ITestResult>();
      trlist.add(er);
      monitor.done();
      returner.completeReturn(trlist);
      return;
    }

    monitor.done();
    returner.completeReturn(ret);
  }
  public static ChoiceGenerator getGeneratorsFromExtensionPoint() {
    ChoiceGenerator choiseGenerator = new ChoiceGenerator();
    IExtensionRegistry registry = Platform.getExtensionRegistry();
    IExtensionPoint generatorExtensionPoint = registry.getExtensionPoint(EP_GENERATOR);
    if (generatorExtensionPoint != null) {
      IExtension[] generatorExtensions = generatorExtensionPoint.getExtensions();

      for (IExtension extension : generatorExtensions) {

        for (IConfigurationElement element : extension.getConfigurationElements()) {
          try {
            final IGenerator generator = (IGenerator) element.createExecutableExtension("class");
            choiseGenerator.add(generator);
          } catch (CoreException e) {
            LogUtils.debugTrace(Logger.getLogger(ChoiceGenerator.class), e);
          }
        }
      }
    }
    return choiseGenerator;
  }