/** @param args */ public static void main(String[] args) { if (args.length > 0 && (args[0].equals("-h") || args[0].equals("-help"))) { System.out.println( "\n \\**\n" + " * Pair Count \n" + " * True Positives : Correctly Predicted BP\n" + " * False Positives : Incorrectly Predicted BP \n" + " * False Negatives : Base pair exists in native structure\n" + " *\n" + " * Specificity = FN / (TP + FP)\n" + " * Sensitivity/Recall = TP / (TP + FN)\n" + " * Precision = TP / (TP + FP)\n" + " * True Negative Rate = TN / (TN + FP)\n" + " * Accuracy = (TP + TN) / (TP + TN + FP + FN)\n" + " * F-Measure = 2 * Precision * Recall / (Precision + Recall)\n" + " * Matthews Correlation\n" + " * Coefficient = (TP * TN - FP * FN) / ((TP + FP)(TP + FN)(FP + TN)(FP + FN))\n" + " */\n\n"); } if (args.length > 1) try { bf = new BufferedWriter(new FileWriter(args[1])); } catch (IOException e) { e.printStackTrace(); } if (args.length > 0) { processFile_RNA(new File(args[0])); } else display("Please enter a valid \".rna\" file."); if (bf != null) try { bf.close(); } catch (IOException e) { e.printStackTrace(); } }
public static void processFile_RNA(File f) { if (f == null || !f.exists()) return; if (f.isDirectory()) { processDir(f); return; } display("[Processing: " + f.getAbsolutePath() + "\n\n"); try { Scanner scan = new Scanner(f); String[] arr = new String[4]; int count = 0; while (scan.hasNextLine() && count < 4) { arr[count++] = scan.nextLine(); } scan.close(); if (arr[1] != null && arr[2] != null) { Map<String, StringBuilder> ht = parseNative(arr[1]); double[] vals = parsePredicted(arr[2], ht); String header = "Native Structure vs. MFE Predicted Structure\n" + "--------------------------------------------\n"; printCalculations(vals, header); if (arr[3] != null) { vals = parsePredicted(arr[3], ht); header = "Native Structure vs. Custom Predicted Structure\n" + "-----------------------------------------------\n"; printCalculations(vals, header); } } } catch (Exception e) { e.printStackTrace(); } }
public static void processDir(File base) { if (base == null || !base.exists()) return; display("Opening " + base.getAbsolutePath() + "\n\n"); File[] files = base.listFiles(); for (File f : files) { if (f.isDirectory()) processDir(f); else processFile_RNA(f); } }
public static void printCalculations(double[] arr, String header) { StringBuilder sb = new StringBuilder(header); sb.append("-Specificity\t= ").append(specificity(arr)).append("\n"); sb.append("-Sensitivity\t= ").append(sensitivity(arr)).append("\n"); sb.append("-Precision\t= ").append(precision(arr)).append("\n"); sb.append("-F-Measure\t= ").append(fMeasure(arr)).append("\n\n"); sb.append("See \"-help\" for equations.\n\n"); display(sb.toString()); }