Ejemplo n.º 1
0
 public void writeHapMap(ReadsByTaxa rbt, String outfileS, float coverRate) {
   String[] hapMap;
   ArrayList<String> al = new ArrayList();
   for (int i = 0; i < cls.length; i++) {
     String temp;
     if (cls[i].ifSnp) {
       temp = getHapMapRecord(rbt, i + 1, cls[i].queryIndex, cls[i].hitIndex, coverRate);
       if (temp != null) {
         al.add(temp);
       }
     }
   }
   hapMap = al.toArray(new String[al.size()]);
   try {
     BufferedWriter bw = new BufferedWriter(new FileWriter(outfileS), 65536);
     bw.write("rs	alleles	chrom	pos	strand	assembly	center	protLSID	assayLSID	panelLSID	QCcode	");
     for (int i = 0; i < rbt.getTaxaCount() - 1; i++) {
       bw.write(rbt.getTaxaNames()[i] + "\t");
     }
     bw.write(rbt.getTaxaNames()[rbt.getTaxaCount() - 1]);
     bw.newLine();
     for (int i = 0; i < hapMap.length; i++) {
       bw.write(hapMap[i]);
       bw.newLine();
     }
     bw.flush();
     bw.close();
   } catch (Exception e) {
     System.out.println(e.toString());
   }
 }
 @Override
 public DataSet performFunction(DataSet input) {
   createMergeOutfile(infiles, outfilename);
   fillMergeOutfile(infiles, outfilename);
   if (hapmapFile != null) {
     myLogger.info("Calling SNPs in good reads.");
     ReadsByTaxa rbt = new ReadsByTaxa();
     rbt.readTBTFile(new File(outfilename));
     Clusters cls = new Clusters(rbt);
     cls
         .networkFilter(); // Really powerful, which generates 85% single locus SNPs in 282 maize
                           // lines
     cls.alleleFrequencyFileter(
         rbt,
         (double) 0.20,
         (double) 0.30); // Only for linkage pop which has allele frequency peaks
     cls.heteozygoteFilter(rbt); // Seems not useful, need to be refined or removed
     cls.writeHapMap(rbt, hapmapFile.getAbsolutePath(), (float) 0.9);
   }
   return null;
 }