/** *************************************************************************** */ public void sortHits() { // Check for no proteins. if (total <= 1) return; // Compare this protein to all other proteins. AminoWords words = best[0].getWords(); int matches = 0; int words_total = 0; for (int i = 1; i < total; i++) { // Count the number of words common to both sequences. matches = words.countCommonWords(best[i].getWords()); if (words.getTotal() > 0) best[i].setPercentFirst((byte) ((matches * 100) / words.getTotal())); words_total = best[i].getWords().getTotal(); if (words_total < words.getTotal()) best[i].setPercentFirst((byte) ((matches * 100) / words_total)); } // for // Sort the best hits. if (total == 2) { // Find the best matches. for (int i = 0; i < total; i++) findBest(i); return; } // if Best temp = null; for (int i = 1; i < total - 1; i++) { for (int j = i + 1; j < total; j++) { // Compare by percent words. if (best[j].getPercentFirst() > best[i].getPercentFirst()) { temp = best[i]; best[i] = best[j]; best[j] = temp; } // if else // Check for the same percent identity. if (best[j].getPercentFirst() == best[i].getPercentFirst()) { if (best[j].getFastaSequence().getLength() > best[i].getFastaSequence().getLength()) { temp = best[i]; best[i] = best[j]; best[j] = temp; } // if } // if } // for } // for // Find the best matches. for (int i = 0; i < total; i++) findBest(i); } // method sortHits
/** *************************************************************************** */ private void findBest(int index) { // Check for the first protein. if (index <= 0) { families++; // New protein family best[index].setFamily(families); // Set the protein family number super_families++; // New protein super family best[index].setSuperFamily(super_families); // Set the protein super family number return; } // if // Compare this protein to all other proteins. int best_count = 0; int best_match = 0; int best_percent = 0; AminoWords words = best[index].getWords(); int length = best[index].getFastaSequence().getLength(); int length2 = length; for (int i = 0; i < index; i++) { // Count the number of words common to both sequences. int count = words.countCommonWords(best[i].getWords()); // Check for a better match. if (count > best_count) { best_count = count; best_match = i; // best_percent = (count * 100) / best [ i ].getWordsTotal (); length2 = best[i].getFastaSequence().getLength(); if (length < length2) best_percent = (count * 100) / length; else best_percent = (count * 100) / length2; } // if } // for // Record the number of common words with the best match. best[index].setCommonWords(best_count); best[index].setBestMatch(best_match); // Check for a family or super-family match. if (best_count > 9) { // Check for a family match. if ((best_count > 49) && (best_percent >= 26)) { best[index].setFamily(best[best_match].getFamily()); best[index].setSuperFamily(best[best_match].getSuperFamily()); // Check for a better match for the previous sequence. if (best_count > best[best_match].getCommonWords()) { best[best_match].setCommonWords(best_count); best[best_match].setBestMatch(index); } // if } // if else // super family member { families++; // New protein family best[index].setFamily(families); // Set the protein family number // Set the protein super family number if (best_count > 19) { best[index].setSuperFamily(best[best_match].getSuperFamily()); } // if else { super_families++; // New protein super family best[index].setSuperFamily(super_families); // Set the protein super family number } // else } // else } // if else { families++; // New protein family best[index].setFamily(families); // Set the protein family number super_families++; // New protein super family best[index].setSuperFamily(super_families); // Set the protein super family number } // else } // method findBest