| 1 |
package pp2.prediction.knn; |
| 2 |
|
| 3 |
|
| 4 |
/** |
| 5 |
* command-line wrapper to apply kNN predictions to a file containing several targets |
| 6 |
* @author Thomas Hopf |
| 7 |
* |
| 8 |
*/ |
| 9 |
public class KNNPredictor { |
| 10 |
|
| 11 |
|
| 12 |
public static void main(String[] args) |
| 13 |
{ |
| 14 |
// example run: java KNNPredictor -i examples/blast_results_all.blast -o examples/prediction_out1 -k 11 -c data/deductiveClosureGO.txt -t data/goterm.txt |
| 15 |
|
| 16 |
String usage = "java KNNPredictor -i <blast input> -o <output path> -d <distribution> [-k <#neighbors> |-e <eValue threshold>] [-nofilter] [-cc] " + |
| 17 |
"-c <GO closure file> -t <GO term file>"; |
| 18 |
|
| 19 |
if(args.length < 8) |
| 20 |
{ |
| 21 |
System.out.println(usage); |
| 22 |
System.exit(-1); |
| 23 |
} |
| 24 |
|
| 25 |
String hitFile = null; //"examples/blast_results_example_subset2"; |
| 26 |
String outFile = null; // "examples/prediction_out1"; |
| 27 |
String distributionFile = null; |
| 28 |
boolean eliminateDuplicateHits = true; |
| 29 |
boolean useEValueThreshold = false; |
| 30 |
double eValueTreshold = 1E-10; |
| 31 |
int k=1; |
| 32 |
|
| 33 |
String closureFile = null; |
| 34 |
String termFile = null; |
| 35 |
boolean noCellularComponent = false; |
| 36 |
|
| 37 |
//String hitFile = "examples/blast_results_all.blast"; |
| 38 |
//String outFile = "examples/prediction_out1"; |
| 39 |
//boolean eliminateDuplicateHits = true; |
| 40 |
//boolean useEValueThreshold = false; |
| 41 |
//double eValueTreshold=1E-10; |
| 42 |
//int k=2; |
| 43 |
//"data/deductiveClosureGO.txt" |
| 44 |
//"data/goterm.txt" |
| 45 |
|
| 46 |
for(int i=0; i<args.length; i++) { |
| 47 |
|
| 48 |
if(args[i].equals("-i")) |
| 49 |
hitFile = args[++i]; |
| 50 |
else if(args[i].equals("-o")) |
| 51 |
outFile = args[++i]; |
| 52 |
else if(args[i].equals("-c")) |
| 53 |
closureFile = args[++i]; |
| 54 |
else if(args[i].equals("-t")) |
| 55 |
termFile = args[++i]; |
| 56 |
else if(args[i].equals("-o")) |
| 57 |
outFile = args[++i]; |
| 58 |
else if(args[i].equals("-d")) |
| 59 |
distributionFile = args[++i]; |
| 60 |
else if(args[i].equals("-k")) |
| 61 |
{ |
| 62 |
k = Integer.parseInt(args[++i]); |
| 63 |
useEValueThreshold = false; |
| 64 |
} |
| 65 |
else if(args[i].equals("-e")) |
| 66 |
{ |
| 67 |
eValueTreshold = Double.parseDouble(args[++i]); |
| 68 |
useEValueThreshold = true; |
| 69 |
} |
| 70 |
else if(args[i].equals("-nofilter")) |
| 71 |
eliminateDuplicateHits = false; |
| 72 |
// else if(args[i].equals("-cc")) |
| 73 |
// noCellularComponent = false; |
| 74 |
else |
| 75 |
System.out.println(usage); |
| 76 |
} |
| 77 |
|
| 78 |
if(hitFile == null || outFile == null || closureFile == null || termFile == null) |
| 79 |
{ |
| 80 |
System.out.println("invalid file parameters!"); |
| 81 |
System.out.println(usage); |
| 82 |
System.exit(-1); |
| 83 |
} |
| 84 |
|
| 85 |
System.out.println(" input file: " + hitFile); |
| 86 |
System.out.println(" out path: " + outFile); |
| 87 |
System.out.println(" use E-value: " + useEValueThreshold); |
| 88 |
System.out.println(" k: " + k); |
| 89 |
System.out.println(" E-Value threshold: " + eValueTreshold); |
| 90 |
System.out.println(" eliminate duplicate hits: " + eliminateDuplicateHits); |
| 91 |
System.out.println(" closure file: " + closureFile); |
| 92 |
System.out.println(" term file: " + termFile); |
| 93 |
System.out.println(" distribution file: " + distributionFile); |
| 94 |
System.out.println(" no cellular component: " + noCellularComponent); |
| 95 |
System.out.println(); |
| 96 |
|
| 97 |
KNNKernel knn = new KNNKernel(closureFile, termFile, noCellularComponent); |
| 98 |
knn.predictTargetList(hitFile, outFile, eliminateDuplicateHits,useEValueThreshold, eValueTreshold, k, distributionFile); |
| 99 |
|
| 100 |
//-i examples/blast_results_all.blast -o examples/prediction_out1 -k 11 -c data/deductiveClosureGO.txt -t data/goterm.tx |
| 101 |
|
| 102 |
/* |
| 103 |
* TODO: |
| 104 |
* X doppelte Hits filtern (aus den verschiedenen PSI-Blast Iterationen) |
| 105 |
* X BestHit als 1-NN implementieren! |
| 106 |
* X normalisierung per ontologie |
| 107 |
* |
| 108 |
* - warum korrelieren unweighted und weighted so stark? |
| 109 |
* - exception handling für individuelle targets implementieren |
| 110 |
* X scores runden |
| 111 |
*/ |
| 112 |
} |
| 113 |
} |