ExtractBlast implements Callable<Integer> { static HashMap<String, BlastResults> readBlast(final int alleleCutoff, final File inputBlastFile) throws IOException{ BufferedReader reader = null; HashMap<String, BlastResults> blast = new HashMap<String, BlastResults>(); try { reader = new BufferedReader(new FileReader(inputBlastFile)); for (HighScoringPair hsp : HspReader.read(reader)) { List<String> BlastnParts = Splitter.on("\t").splitToList(hsp.toString()); String sequenceId = BlastnParts.get(0); String allele = BlastnParts.get(1); BlastResults blastResults = blast.get(sequenceId); if(blastResults == null){ blastResults = new BlastResults(alleleCutoff); blast.put(sequenceId, blastResults); } blastResults.addTyping(allele); } }finally { try { reader.close(); } catch (Exception e) { e.printStackTrace(); System.exit(1); } } return blast; } ExtractBlast(final File inputBlastFile, 
    		            final File inputFastqFile, 
    		            final File outputFile,
    		            final int alleleCutoff, 
    		            final String imgtDbVersion); @Override Integer call(); static void main(final String[] args);  }
@Test public void testReadBlast() throws Exception { copyResource("blast.txt", inputBlastFile); Map<String, BlastResults> blast = readBlast(10,inputBlastFile); assertNotNull(blast); assertNotNull(blast.get("0|Ref151|32552989|1||1|0")); }
@Test public void testAlleleCutoff() throws Exception { copyResource("blast.txt", inputBlastFile); Map<String, BlastResults> blast = readBlast(10,inputBlastFile); assertNotNull(blast); for (String seqId : blast.keySet()) { List<String> blastString = Splitter.on("/").splitToList(blast.get(seqId).getTypingGlstring()); assertEquals(10,blastString.size()); } }
@Test public void testUniqueAllelesInGlstring() throws Exception { copyResource("blast.txt", inputBlastFile); Map<String, BlastResults> blast = readBlast(10,inputBlastFile); assertNotNull(blast); for (String seqId : blast.keySet()) { List<String> unique = new ArrayList<String>(); List<String> blastGlstring = Splitter.on("/").splitToList(blast.get(seqId).getTypingGlstring()); for(String allele : blastGlstring){ boolean inGl = unique.contains(allele); assertFalse(inGl); unique.add(allele); } } }