示例#1
0
  @Override
  public void performOperation() throws OperationFailedException {
    if (verbose) {
      System.out.println("TestOperator is performing operation");
    }

    inputFile = inputBuffers.get(0).getFile();

    try {
      BufferedReader reader = new BufferedReader(new FileReader(inputFile));
      FileBuffer output = outputBuffers.get(0);

      String line = reader.readLine();

      BufferedWriter writer = new BufferedWriter(new FileWriter(output.getFile()));
      writer.write("Top of the new output buffer!\n");

      int count = 0;
      while (line != null) {
        System.out.println("Read this line from input file : " + line);
        writer.write(count + "\t " + line + "\n");
        count++;
        line = reader.readLine();
      }

      reader.close();
      writer.close();
    } catch (FileNotFoundException e) {
      throw new OperationFailedException(e.getCause() + "\t" + e.getMessage(), this);
    } catch (IOException e) {
      throw new OperationFailedException(e.getCause() + "\t" + e.getMessage(), this);
    }
  }
示例#2
0
  @Override
  protected String[] getCommand(FileBuffer inputBuffer) throws OperationFailedException {
    if (cutAdaptPath == null) {
      cutAdaptPath = this.getPipelineProperty(CUTADAPT_PATH);
      if (cutAdaptPath == null)
        throw new OperationFailedException("No path to cutadapt found", this);
    }

    if (!(inputBuffer instanceof FastQFile)) {
      return null;
    }

    if (adapterString == null) {
      try {
        FileBuffer adapterBuf = this.getInputBufferForClass(TextBuffer.class);
        if (adapterBuf == null)
          throw new OperationFailedException(
              "No adapter file specified, cannot cut adapters", this);
        BufferedReader reader = new BufferedReader(new FileReader(adapterBuf.getFile()));
        StringBuffer adapterStr = new StringBuffer();
        String line = reader.readLine();
        while (line != null) {
          adapterStr.append(" -a " + line.trim());
          line = reader.readLine();
        }
        reader.close();
        adapterString = adapterStr.toString();
      } catch (IOException ex) {
        throw new OperationFailedException(
            "Error reading adapter sequences : " + ex.getMessage(), this);
      }
    }

    String outputFilename = "adaptercut-" + inputBuffer.getFilename();
    FastQFile outputFile = new FastQFile(new File(getProjectHome() + outputFilename));
    super.addOutputFile(outputFile);
    String command =
        cutAdaptPath
            + adapterString
            + " -o "
            + outputFile.getAbsolutePath()
            + " "
            + inputBuffer.getAbsolutePath();

    return new String[] {command};
  }