Beispiel #1
0
  public boolean printBestIncludePreRealignment() {
    if (facetScore > preRealignmentFacetScore) {
      if (in.verbosity > -1) {
        System.err.printf("\nbest facet value --  %.6f (%s)", facetScore, conf);
      }

      return am.printOutput(alignmentInstance, in.bestOutputFileIncludePreRealignment);
    } else {
      if (in.verbosity > 0 && facetScore > -1) {
        System.err.printf("\npre-realignment facet score: %.6f", preRealignmentFacetScore);
      }

      return am.printOutput(
          preRealignmentAlignmentInstance, in.bestOutputFileIncludePreRealignment, false);
    }
  }
Beispiel #2
0
  public boolean printBest() {
    if (facetScore != -1 && in.verbosity > -1) {
      System.err.printf("\nbest facet value --  %.6f (%s)", facetScore, conf);
    }

    return am.printOutput(alignmentInstance, in.bestOutputFile);
  }
Beispiel #3
0
  public boolean printBestPreRealignment() {
    if (in.verbosity > -1) {
      System.err.printf(
          "\nbest pre-realignment facet value --  %.6f (%s)", preRealignmentFacetScore, conf);
    }

    return am.printOutput(preRealignmentAlignmentInstance, in.bestPreRealignmentOutputFile, false);
  }
Beispiel #4
0
 public boolean printPreRealignment() {
   if (in.verbosity > 0 && facetScore > -1) {
     System.err.printf("\npre-realignment facet score: %.6f", preRealignmentFacetScore);
   }
   if (in.preRealignmentOutputFile != null) {
     String fname = in.preRealignmentOutputFile.replace("__CONFIG__", conf.toString());
     if (conf.repetition >= 0)
       fname = fname.replace("__ITTERATION__", Integer.toString(conf.repetition));
     if (facetScore >= 0)
       fname =
           fname.replace(
               "__FACETSCORE__", "facetScore" + Double.toString(preRealignmentFacetScore));
     return am.printOutput(preRealignmentAlignmentInstance, fname, false);
   } else {
     return am.printOutput(preRealignmentAlignmentInstance, null, false);
   }
 }
Beispiel #5
0
  public boolean print() {
    // if(facetScore==-1){
    //	am = null;
    // }
    if (in.verbosity > 0 && facetScore > -1) {
      System.err.printf("\nfacet score: %.6f", facetScore);
    }

    if (in.configOutputFile != null) {
      String fname = in.configOutputFile.replace("__CONFIG__", conf.toString());
      if (conf.repetition >= 0)
        fname = fname.replace("__ITTERATION__", Integer.toString(conf.repetition));
      if (facetScore >= 0)
        fname = fname.replace("__FACETSCORE__", "facetScore" + Double.toString(facetScore));
      return am.printOutput(alignmentInstance, fname);

    } else return am.printOutput(alignmentInstance, null);
  }
Beispiel #6
0
  public static double TCSValue(
      int[][] alignmentInstance, AlignmentMaker am, Configuration config) {
    String filename =
        config.temporaryFileDirectory
            + "tmp"
            + alignmentInstance.hashCode()
            + "_"
            + am.hashCode()
            + "_"
            + config.hashCode()
            + "_"
            + am.in.hashCode();

    int oldVerbosity = am.in.verbosity;
    am.in.verbosity = -1;
    am.printOutput(alignmentInstance, filename);
    am.in.verbosity = oldVerbosity;

    String command =
        config.tcoffeeDirectory
            + "t_coffee -infile "
            + filename
            + " -evaluate -method proba_pair -output score_ascii -outfile=stdout";
    String result = "-1";
    try {
      result = execCmd(command);
      execCmd("rm " + filename);
    } catch (NumberFormatException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    // System.err.println("Command: \""+command+"\"\nPre Parse Line: \""+result+"\"");
    return Double.parseDouble(result) / 100.0;
  }
Beispiel #7
0
  public void run() {
    if (in.verbosity > 1) System.err.println("Config : " + conf);

    try {

      if (AlignmentMaker_SingleSequences.consistency) {
        int increase = AlignmentMaker_SingleSequences.consistency_subs_increase;
        conf.cost.increaseCosts(
            increase); // arbitrary number ... just trying to make w-w identities non-zero cost, and
                       // high enough to avoid rounding effects
        conf.cost.multiplyCosts(2);

        conf.increaseGapCosts(increase / 2);
        conf.multiplyGapCosts(2);
      }

      if (Tree.treeType == Tree.TreeType.entered) {
        Tree.iterations = 1;
      }

      FacetAlignment fa = null;
      if (in.justDoSubOpt) {
        am = new AlignmentMaker_SuboptimalityTester();
        // am.initialize(in.fileA, in.structFileA);
        am.initialize(conf, in);
        alignmentInstance = am.buildAlignment();
        if (in.structFileA != null) {
          fa =
              new FacetAlignment(
                  conf.sc.convertIntsToSeqs(alignmentInstance), in.structure.structure);
        }
      } else if (in.justDoConvert) {
        am = new AlignmentMaker_Converter();
        // am.initialize(in.fileA, in.structFileA);
        am.initialize(conf, in);
        alignmentInstance = am.buildAlignment();
        if (in.structFileA != null) {
          fa =
              new FacetAlignment(
                  conf.sc.convertIntsToSeqs(alignmentInstance), in.structure.structure);
        }
      } else if (in.fileB != null) { // alignalign call
        am = new AlignmentMaker_TwoAlignments();
        // am.initialize(in.fileA, in.fileB);
        // Aligner.useStructure = false;
        am.initialize(conf, in);
        alignmentInstance = am.buildAlignment();
        if (in.structFileA != null) {
          fa =
              new FacetAlignment(
                  ((AlignmentMaker_TwoAlignments) am).result, in.structure.structure);
        }

      } else if (in.justTree || Tree.justPWDists) { //
        am = new AlignmentMaker_SingleSequences();
        // am.initialize(in.fileA, in.structFileA);
        am.initialize(conf, in);
        ((AlignmentMaker_SingleSequences) am).buildTree(conf, in);
      } else { // multiple alignment call
        am = new AlignmentMaker_SingleSequences();
        // am.initialize(in.fileA, in.structFileA);
        am.initialize(conf, in);
        // final Timer queueRunner = new Timer();
        // ShutdownHandler sh = new ShutdownHandler(queueRunner,
        // (AlignmentMaker_SingleSequences)am);
        // Runtime.getRuntime().addShutdownHook(sh);
        // Thread.setDefaultUncaughtExceptionHandler(sh);  // this should be available for all calls
        // ... but this is the one I use a lot, so it's all I've implemented it for

        alignmentInstance = am.buildAlignment();

        if (in.structFileA != null) {

          if (realignmentConfigList != null) {
            Configuration newRealignmentConfigList[] =
                new Configuration[realignmentConfigList.length];
            for (int rNum = 0; rNum < realignmentConfigList.length; rNum++) {
              newRealignmentConfigList[rNum] = new Configuration(realignmentConfigList[rNum]);
            }
            preRealignmentAlignmentInstance = alignmentInstance.clone();
            preRealignmentFacetScore =
                Facet.defaultValue(
                    new FacetAlignment(
                        conf.sc.convertIntsToSeqs(preRealignmentAlignmentInstance),
                        in.structure.structure),
                    conf.useLegacyFacetFunction);
            if (conf.useTCSforAdvising)
              preRealignmentFacetScore = TCS.TCSValue(preRealignmentAlignmentInstance, am, conf);
            realignmentDriver realigner =
                new realignmentDriver(
                    conf.sc.convertIntsToSeqs(preRealignmentAlignmentInstance),
                    in.structure.structure,
                    newRealignmentConfigList,
                    conf,
                    (float) preRealignmentFacetScore,
                    am);
            if (conf.realignment_window_type == Configuration.WINDOW_SIZE.VALUE)
              realigner.simpleRealignment((int) conf.realignment_window_value);
            else if (conf.realignment_window_type == Configuration.WINDOW_SIZE.PERCENTAGE) {
              int window_size =
                  (int)
                      (conf.realignment_window_value
                          * (float) preRealignmentAlignmentInstance[0].length);
              if (window_size > conf.maximum_realignment_window_value)
                window_size = (int) conf.maximum_realignment_window_value;
              if (window_size < conf.minimum_realignment_window_value)
                window_size = (int) conf.minimum_realignment_window_value;
              realigner.simpleRealignment(window_size);
            }
            alignmentInstance = realigner.newAlignment();
            newRealignmentConfigList = null;
          }
          fa =
              new FacetAlignment(
                  conf.sc.convertIntsToSeqs(alignmentInstance), in.structure.structure);
        }
      }

      if (fa != null) {
        if (in.featureOutputFile != null) {
          String fname = in.featureOutputFile.replace("__CONFIG__", conf.toString());
          if (conf.repetition >= 0)
            fname = fname.replace("__ITTERATION__", Integer.toString(conf.repetition));
          Facet.outputDefaultFeatures(fname, fa);
        }
        facetScore = Facet.defaultValue(fa, conf.useLegacyFacetFunction);
        if (conf.useTCSforAdvising) facetScore = TCS.TCSValue(alignmentInstance, am, conf);
      }
      // in.structFileA = "";
      // System.err.println("File: " + in.structFileA);

      // System.err.printf("facet value --  %.6f\n\n",facetScore);
    } catch (GenericOpalException e) {
      System.exit(1);
    } /*catch (FileNotFoundException e){
      	System.err.println("File Error:" + e.toString());
      	System.exit(15);
      }*/
  }