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