コード例 #1
0
  @Override
  public void actionPerformed(AnActionEvent e) {
    Project project = e.getData(PlatformDataKeys.PROJECT);
    Editor editor = e.getData(PlatformDataKeys.EDITOR);

    if (editor == null) {
      return;
    }

    if (!editor.getDocument().isWritable()) {
      return;
    }

    Document document = editor.getDocument();
    SelectionModel selection = editor.getSelectionModel();
    String selectedText = selection.getSelectedText();

    String autoAlignedText;
    int startOffset;
    int endOffset;

    if (selectedText != null) {
      // just align the selected text
      autoAlignedText = aligner.align(selectedText);
      startOffset = selection.getSelectionStart();
      endOffset = selection.getSelectionEnd();
    } else {
      // auto-align the whole document
      autoAlignedText = aligner.align(document.getText());
      startOffset = 0;
      endOffset = document.getTextLength();
    }

    replaceString(project, document, autoAlignedText, startOffset, endOffset);
  }
コード例 #2
0
  public static void main(String[] args) {
    try {
      String sp1 = "/home/caoc/alterAligner/SCORE_DROP/all_mtx/" + args[0] + ".mtx";
      String sp2 = "/home/caoc/alterAligner/SCORE_DROP/all_mtx/" + args[1] + ".mtx";
      System.out.println(args[0]);
      //                                String sp1 =
      // "/home/caoc/alterAligner/SCORE_DROP/all_fasta/" + args[0] ;
      //                               String sp2 =  "/home/caoc/alterAligner/SCORE_DROP/all_fasta/"
      // + args[1] ;

      Class parserClass = Class.forName("alterAligner.sequenceProfileParsers.PSSMParser");
      Class scoreFunctionClass =
          Class.forName("alterAligner.scoreFunctionStrategies.WeightedSumStrategy");
      SequenceProfileParser aParser = (SequenceProfileParser) parserClass.newInstance();
      ScoreFunctionStrategy aStrategy = (ScoreFunctionStrategy) scoreFunctionClass.newInstance();
      Aligner aligner = new Aligner(aStrategy, (float) 10, (float) 0.5);
      SequenceProfile seqPro1 = aParser.parse(new File(sp1));
      SequenceProfile seqPro2 = aParser.parse(new File(sp2));
      Alignment alignment = aligner.smithWatermanAlign(seqPro1, seqPro2);
      BufferedWriter writer =
          new BufferedWriter(
              new FileWriter(
                  "/home/caoc/alterAligner/SCORE_DROP/all_ws_alignment/"
                      + args[0]
                      + "__"
                      + args[1]
                      + ".ws.fasta"));
      writer.append(
          ">"
              + alignment.getName1()
              + "\t"
              + alignment.getStart1()
              + "\t"
              + alignment.getEnd1()
              + "\n");
      writer.append(alignment.getSequence1AsString() + "\n");
      writer.append(
          ">"
              + alignment.getName2()
              + "\t"
              + alignment.getStart2()
              + "\t"
              + alignment.getEnd2()
              + "\n");
      writer.append(alignment.getSequence2AsString() + "\n");
      writer.close();
    } catch (FileNotFoundException e) {
      System.out.println("Failed to open file! " + e.getMessage());
    } catch (IOException e) {
      System.out.println("Failed to read the file! " + e.getMessage());
    } catch (ClassNotFoundException e) {
      System.out.println("Failed to find the class! " + e.getMessage());
    } catch (Exception e) {
      System.out.println("Failed to due to do alignment! " + e.getMessage());
      e.printStackTrace();
    }
  }