예제 #1
0
  public static Map<String, SnpFrequencyData> getSnpFrequencies(
      String filename, Collection<String> snpIDs) {
    Map<String, SnpFrequencyData> freqs = new LinkedHashMap<String, SnpFrequencyData>();
    for (String snpID : snpIDs) {
      SnpFrequencyData freq = new SnpFrequencyData();
      freqs.put(snpID, freq);
    }

    Scanner scanner = CFileHelper.createScanner(filename, "\n");
    scanner.nextLine(); // skip the header line
    while (scanner.hasNext()) {
      String line = scanner.nextLine();
      String[] tabs = line.split("\\s+");
      String snpID = tabs[2];
      if (!freqs.containsKey(snpID)) continue;
      SnpFrequencyData snp = (SnpFrequencyData) freqs.get(snpID);
      snp.setData(tabs);
    }
    CFileHelper.closeScanner(scanner);
    return freqs;
  }
예제 #2
0
 public static void writeDataFile(String filename, CDataFrame dataframe) {
   String output = dataframe.toString();
   output = PlinkHelper.stripMissingValueToken(output);
   CFileHelper.writeFile(filename, output);
 }