Esempio n. 1
0
  /** Use miRbase fastas source */
  public static void miRdupExecutionFastas() {
    String filename = matures.substring(0, matures.lastIndexOf("."));
    // Normal execution. We get sequences on mirbase using keyword ("all" if empty),
    // then we train the model on it, and if the test dataset is present we submit it to the model
    if (!classifier.isEmpty()) {
      if (predictionsFile.isEmpty()) {
        System.out.println("You must submit a file with data you want to validate");
      } else {
        System.out.println("Validation of " + predictionsFile + " with classifier " + classifier);
        // test model
        File arff = null;
        if (arffFileForValidate.isEmpty()) {
          arff = new File(predictionsFile + ".arff");
          AdaptDataForWeka.createPredictionDataset(predictionsFile, false);
        } else {
          System.out.println("Using arff file " + arffFileForValidate + " to validate");
          arff = new File(arffFileForValidate);
        }
        WekaModule.testModel(arff, predictionsFile, classifier, predictMirnaPosition);
      }
    } else if (trainFromOnlineMiRbase == true) {
      // search sequences from mirbase based on a keyword
      Mirbase m = new Mirbase();
      ArrayList altrain = m.getSequencesFromMirbase(keyword);
      // train model
      File arff = new File(keyword + ".arff");
      AdaptDataForWeka.createFileFromList(altrain, arff, false);
      WekaModule.trainModel(arff, keyword);

      // submit a file with predicted mirnas and their hairpins to the model
      if (!predictionsFile.isEmpty()) {
        // test model
        arff = null;
        if (arffFileForValidate.isEmpty()) {
          arff = new File(predictionsFile + ".arff");
          AdaptDataForWeka.createPredictionDataset(predictionsFile, false);
        } else {
          arff = new File(arffFileForValidate);
        }
        WekaModule.testModel(arff, predictionsFile, keyword + modelExtension, predictMirnaPosition);
      }
      // Case offline mirbase, and local sequences are submitted
    } else {
      // search sequences from mirbase based on a keyword
      File arff = null;
      if (arffFileForTrain.isEmpty()) {
        Mirbase m = new Mirbase();
        ArrayList altrain =
            m.getSequencesFromFiles(matures, hairpins, organisms, structures, keyword, filename);
        arff = new File(keyword + "" + filename + ".arff");
        AdaptDataForWeka.createFileFromList(altrain, arff, false);
      } else {
        arff = new File(arffFileForTrain);
      }
      // train model
      WekaModule.trainModel(arff, keyword + "" + filename);
      // submit a file with predicted mirnas and their hairpins to the model
      if (!predictionsFile.isEmpty()) {
        // test model
        arff = null;
        if (arffFileForValidate.isEmpty()) {
          arff = new File(predictionsFile + ".arff");
          AdaptDataForWeka.createPredictionDataset(predictionsFile, false);
        } else {
          arff = new File(arffFileForValidate);
        }
        WekaModule.testModel(
            arff, predictionsFile, keyword + filename + modelExtension, predictMirnaPosition);
      }
    }
  }