public void writeEmptyResults(FastaSequence fasta) throws IOException { FileWriter writer = new FileWriter(ouptutFile); writer.write(fasta.getIdentifier()); writer.write(NEW_COLUMN); writer.write(EMPTY); writer.write(NEW_COLUMN); writer.write(EMPTY); writer.write(NEW_COLUMN); writer.write(EMPTY); writer.write(NEW_COLUMN); writer.write(EMPTY); writer.write(NEW_COLUMN); writer.write(EMPTY); writer.write(NEW_COLUMN); writer.write(EMPTY); writer.write(NEW_COLUMN); writer.write(EMPTY); writer.write(NEW_COLUMN); writer.write(EMPTY); writer.write(NEW_COLUMN); writer.write(fasta.getSequence()); writer.write(NEW_COLUMN); writer.write(EMPTY); writer.write(NEW_COLUMN); writer.write(EMPTY); writer.write(NEW_LINE); writer.flush(); writer.close(); }
public void writeResults( FastaSequence fastaSequence, IdentificationResults<? extends MappingReport> identificationResults) throws IOException { if (identificationResults == null) { throw new IllegalArgumentException("Identification results are expected"); } if (fastaSequence == null) { throw new IllegalArgumentException("A fast sequence is expected"); } BufferedWriter writer = new BufferedWriter(new FileWriter(ouptutFile, true)); // PICR/swissprot remapping could identify one single uniprot id. We want to give the blast // results of swissprot remapping if necessary if (identificationResults.hasUniqueUniprotId()) { // fast identifier writer.write(fastaSequence.getIdentifier()); // we retrieved the uniprot id from PICR writer.write(NEW_COLUMN); writer.write(identificationResults.getFinalUniprotId()); // no other possible uniprot ids from PICR writer.write(NEW_COLUMN); writer.write(EMPTY); // check if last report is not blast remapping to be reviewed MappingReport report = identificationResults.getLastAction(); if (report != null && report.getStatusLabel().equals(StatusLabel.TO_BE_REVIEWED) && report.getName().equals(ActionName.BLAST_Swissprot_Remapping)) { BlastReport<BlastResults> blastReport = (BlastReport<BlastResults>) report; // we have one result that can match Set<BlastResults> blastResults = blastReport.getBlastMatchingProteins(); if (blastResults.size() == 1) { BlastResults blastResult = blastResults.iterator().next(); writeBlastResults(writer, blastResult, fastaSequence); } // we don't write the other results else { writeEmpytBlastResults(writer, fastaSequence); } } // no swissprot remapping to review else { writeEmpytBlastResults(writer, fastaSequence); } } else { // PICR sequence to be reviewed ? if yes, no blast to report MappingReport report = identificationResults.getLastAction(); if (report != null && report.getStatusLabel().equals(StatusLabel.TO_BE_REVIEWED) && (report.getName().equals(ActionName.PICR_sequence_Swissprot) || report.getName().equals(ActionName.PICR_sequence_Trembl))) { // fasta identifier writer.write(fastaSequence.getIdentifier()); // no unique uniprot id writer.write(NEW_COLUMN); writer.write(EMPTY); // possible uniprot from PICR writer.write(NEW_COLUMN); writer.write(StringUtils.join(report.getPossibleAccessions(), ", ")); writeEmpytBlastResults(writer, fastaSequence); } // for each blast to be reviewed, we need to write a line with blast results else if (report != null && report.getStatusLabel().equals(StatusLabel.TO_BE_REVIEWED) && report instanceof BlastReport) { BlastReport<BlastResults> blastReport = (BlastReport<BlastResults>) report; if (blastReport.getBlastMatchingProteins().isEmpty()) { writeEmptyResults(fastaSequence); } else { for (BlastResults blastResult : blastReport.getBlastMatchingProteins()) { // fasta identifier writer.write(fastaSequence.getIdentifier()); // no unique uniprot id writer.write(NEW_COLUMN); writer.write(EMPTY); // no other possible uniprot ids from PICR writer.write(NEW_COLUMN); writer.write(EMPTY); writeBlastResults(writer, blastResult, fastaSequence); } } } // no blast results else { writeEmptyResults(fastaSequence); } } writer.flush(); writer.close(); }