예제 #1
0
  private static void writeStrs(
      String outFileName, List<ShortTandemRepeat> strs, boolean writeAll) {
    BufferedWriter bw = null;
    File outFile = new File(outFileName);
    try {
      if (outFile.exists()) {
        outFile.delete();
      }
      bw = new BufferedWriter(new FileWriter(outFile));
      if (writeAll) {
        for (ShortTandemRepeat str : strs) {
          bw.write(str.toString());
          bw.newLine();
        }
      } else {
        for (ShortTandemRepeat str : strs) {
          bw.write(str.toSmallString());
          bw.newLine();
        }
      }

    } catch (IOException e) {
      e.printStackTrace();
    } finally {
      if (bw != null) {
        try {
          bw.close();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
    }
  }
예제 #2
0
  public static void writeCM124Answer(
      String refFileName, String outFileName, HashMap<String, LinkedList<ShortTandemRepeat>> ref) {
    BufferedReader br = null;
    String genomeName = null;
    try {
      br =
          new BufferedReader(
              new InputStreamReader(Utilities.class.getResourceAsStream(refFileName), "UTF-8"));
      genomeName = br.readLine();
      System.out.println("Formatting for genome: " + genomeName);
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      if (br != null) {
        try {
          br.close();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
    }
    if (genomeName == null) {
      throw new Error(refFileName + " does not have a genome name.");
    }
    List<ShortTandemRepeat> strs = refToSortedList(ref);
    BufferedWriter bw = null;
    File outFile = new File(outFileName);
    try {
      if (outFile.exists()) {
        outFile.delete();
      }
      if (!outFile.createNewFile()) {
        throw new RuntimeException(outFileName + " already exists.");
      }
      bw = new BufferedWriter(new FileWriter(outFile));
      bw.write(genomeName);
      bw.newLine();
      bw.write(">STR");
      for (ShortTandemRepeat str : strs) {
        bw.newLine();
        bw.write(str.toString());
      }

    } catch (IOException e) {
      e.printStackTrace();
    } finally {
      if (bw != null) {
        try {
          bw.close();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
    }
  }
예제 #3
0
 public static void printRef(
     HashMap<String, LinkedList<ShortTandemRepeat>> ref, boolean printAll) {
   List<ShortTandemRepeat> strs = refToSortedList(ref);
   System.out.println("\n####Reference Results####");
   if (printAll) {
     for (ShortTandemRepeat str : strs) {
       System.out.println(str.toString());
     }
   } else {
     for (ShortTandemRepeat str : strs) {
       System.out.println(str.toSmallString());
     }
   }
 }
예제 #4
0
 public static void printPriv(
     HashMap<ShortTandemRepeat, ShortTandemRepeat> priv, boolean printAll) {
   List<ShortTandemRepeat> strs = privToSortedList(priv);
   System.out.println("\n####Private results####");
   if (printAll) {
     for (ShortTandemRepeat str : strs) {
       System.out.println(str.toString());
     }
   } else {
     for (ShortTandemRepeat str : strs) {
       if (str.isLost()) {
         break;
       }
       System.out.println(str.toSmallString());
     }
   }
 }