| 1 |
package pp2.prediction.knn; |
| 2 |
|
| 3 |
import java.io.BufferedReader; |
| 4 |
import java.io.IOException; |
| 5 |
import java.util.LinkedList; |
| 6 |
|
| 7 |
import pp2.tools.Tools; |
| 8 |
|
| 9 |
/** |
| 10 |
* stores a list of BLAST results and allows to rerank hits by E-Value etc., sequence identity etc. |
| 11 |
* @author Thomas Hopf |
| 12 |
* |
| 13 |
*/ |
| 14 |
public class BlastResultList { |
| 15 |
|
| 16 |
private LinkedList<BlastHit> hits; |
| 17 |
|
| 18 |
/** |
| 19 |
* stores all hits from blastOutputFile into a list of blast hits |
| 20 |
* @param blastOutputFile |
| 21 |
*/ |
| 22 |
public BlastResultList(String blastOutputFile) |
| 23 |
{ |
| 24 |
hits = new LinkedList<BlastHit>(); |
| 25 |
|
| 26 |
try { |
| 27 |
BufferedReader in = Tools.openFile(blastOutputFile); |
| 28 |
|
| 29 |
String line; |
| 30 |
while((line = in.readLine()) != null) |
| 31 |
{ |
| 32 |
String goTerms = line.split("\t")[0]; |
| 33 |
String eValue = line.split("\t")[1]; |
| 34 |
|
| 35 |
// in some cases, the eValue looks like "e-133" which gives a parsing error, so fix that |
| 36 |
if(eValue.startsWith("e")) |
| 37 |
eValue = "1" + eValue; |
| 38 |
|
| 39 |
hits.add(new BlastHit(goTerms, Double.parseDouble(eValue))); |
| 40 |
} |
| 41 |
in.close(); |
| 42 |
} catch (IOException e) { |
| 43 |
e.printStackTrace(); |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
public LinkedList<BlastHit> getHits() |
| 48 |
{ |
| 49 |
return hits; |
| 50 |
} |
| 51 |
|
| 52 |
|
| 53 |
} |