private void setMatches(Set<Match> matches) { for (Match m : matches) { addMatch(m); } }
public Protein build() { Protein protein = new Protein(sequence); if (!matches.isEmpty()) { for (Match m : matches) { protein.addMatch(m); } } if (!crossReferences.isEmpty()) { for (ProteinXref x : crossReferences) { protein.addCrossReference(x); } } return protein; }
@Override @Transactional public void persist(Collection<RawProtein<T>> filteredProteins, final Map<String, SignatureModelHolder> modelAccessionToSignatureMap, final Map<String, Protein> proteinIdToProteinMap) { // Add matches to protein for (RawProtein<T> rp : filteredProteins) { Protein protein = proteinIdToProteinMap.get(rp.getProteinIdentifier()); if (protein == null) { throw new IllegalStateException("Cannot store match to a protein that is not in database " + "[protein ID= " + rp.getProteinIdentifier() + "]"); } // Convert raw matches to filtered matches Collection<Hmmer2Match> filteredMatches = Hmmer2RawMatch.getMatches(rp.getMatches(), modelAccessionToSignatureMap); // Add matches to protein for (Hmmer2Match m : filteredMatches) { protein.addMatch(m); // Adds protein to match (yes, I know it doesn't look that way!) entityManager.persist(m); } } } }
/** * This is the method that should be implemented by specific FilteredMatchDAOImpl's to * persist filtered matches. * * @param filteredProteins being the Collection of filtered RawProtein objects to persist * @param modelAccessionToSignatureMap a Map of model accessions to Signature objects. * @param proteinIdToProteinMap a Map of Protein IDs to Protein objects */ @Override @Transactional public void persist(Collection<RawProtein<T>> filteredProteins, Map<String, SignatureModelHolder> modelAccessionToSignatureMap, Map<String, Protein> proteinIdToProteinMap) { for (RawProtein<T> rawProtein : filteredProteins) { final Protein protein = proteinIdToProteinMap.get(rawProtein.getProteinIdentifier()); for (T rawMatch : rawProtein.getMatches()) { SignatureModelHolder holder = modelAccessionToSignatureMap.get(rawMatch.getModelId()); Signature signature = holder.getSignature(); ProfileScanMatch match = buildMatch(signature, rawMatch); protein.addMatch(match); entityManager.persist(match); } } }
protein.addMatch(match); // Adds protein to match (yes, I know it doesn't look that way!) entityManager.persist(match); matchLocationCount += match.getLocations().size();
/** * This is the method that should be implemented by specific FilteredMatchDAOImpl's to * persist filtered matches. * * @param filteredProteins being the Collection of filtered RawProtein objects to persist * @param modelAccessionToSignatureMap a Map of model accessions to Signature objects. * @param proteinIdToProteinMap a Map of Protein IDs to Protein objects */ @Override public void persist(Collection<RawProtein<ProSitePatternRawMatch>> filteredProteins, Map<String, SignatureModelHolder> modelAccessionToSignatureMap, Map<String, Protein> proteinIdToProteinMap) { for (RawProtein<ProSitePatternRawMatch> rawProtein : filteredProteins) { final Protein protein = proteinIdToProteinMap.get(rawProtein.getProteinIdentifier()); for (ProSitePatternRawMatch rawMatch : rawProtein.getMatches()) { SignatureModelHolder holder = modelAccessionToSignatureMap.get(rawMatch.getModelId()); Signature signature = holder.getSignature(); PatternScanMatch match = buildMatch(signature, rawMatch); protein.addMatch(match); entityManager.persist(match); } } }
/** * This is the method that should be implemented by specific FilteredMatchDAOImpl's to * persist filtered matches. * * @param filteredProteins being the Collection of filtered RawProtein objects to persist * @param modelAccessionToSignatureMap a Map of model accessions to Signature objects. * @param proteinIdToProteinMap a Map of Protein IDs to Protein objects */ @Override @Transactional public void persist(Collection<RawProtein<MobiDBRawMatch>> filteredProteins) { // public void persist(Collection<RawProtein<MobiDBRawMatch>> filteredProteins, Map<String, SignatureModelHolder> modelAccessionToSignatureMap, Map<String, Protein> proteinIdToProteinMap) { Map<String, Protein> proteinIdToProteinMap = getProteinIdToProteinMap(filteredProteins); for (RawProtein<MobiDBRawMatch> rawProtein : filteredProteins) { final Protein protein = proteinIdToProteinMap.get(rawProtein.getProteinIdentifier()); for (MobiDBRawMatch rawMatch : rawProtein.getMatches()) { Signature signature = loadPersistedSignature(); // Utilities.verboseLog(rawMatch.toString()); MobiDBMatch match = buildMatch(signature, rawMatch); // Utilities.verboseLog("MobiDb match:" + match.toString()); protein.addMatch(match); entityManager.persist(match); } } }
/** * Persists a set of ParseCoilsMatch objects as filtered matches: * there is no filtering step with Coils. * * @param coilsMatches being a Set of ParseCoilsMatch objects to be persisted. */ @Transactional public void persist(Set<ParseCoilsMatch> coilsMatches) { Signature coilsSignature = loadPersistedSignature(); Map<String, Protein> proteinIdToProteinMap = getProteinIdToProteinMap(coilsMatches); for (ParseCoilsMatch parseCoilsMatch : coilsMatches) { final Protein persistentProtein = proteinIdToProteinMap.get(parseCoilsMatch.getProteinDatabaseIdentifier()); if (persistentProtein == null) { throw new IllegalArgumentException("Attempting to store a Coils match for a protein with id " + parseCoilsMatch.getProteinDatabaseIdentifier() + ", however this does not exist in the database."); } Set<CoilsMatch.CoilsLocation> locations = Collections.singleton( new CoilsMatch.CoilsLocation(parseCoilsMatch.getStartCoordinate(), parseCoilsMatch.getEndCoordinate()) ); CoilsMatch match = new CoilsMatch(coilsSignature, coilsSignature.getAccession(), locations); persistentProtein.addMatch(match); entityManager.persist(match); } }
@Transactional public void persist(Set<TMHMMProtein> proteins) { //load TMHMM signatures from database and map them by accession Map<String, Signature> sigAccToDbSignatureMap = loadPersistedSignatures(); //load proteins from database and map them by protein identifier Map<String, Protein> proteinIdToProteinMap = getProteinIdToProteinMap(proteins); for (TMHMMProtein protein : proteins) { final Protein persistentProtein = proteinIdToProteinMap.get(protein.getProteinIdentifier()); if (persistentProtein == null) { throw new IllegalArgumentException("Attempting to store a TMHMM match for a protein with id " + protein.getProteinIdentifier() + ", however this does not exist in the database."); } for (TMHMMMatch match : protein.getMatches()) { final Signature signature = sigAccToDbSignatureMap.get(match.getSignature().getAccession()); TMHMMMatch newMatch = new TMHMMMatch(signature, signature.getAccession(), match.getLocations()); persistentProtein.addMatch(newMatch); entityManager.persist(newMatch); } } }
protein.addMatch(match); entityManager.persist(match);
); PhobiusMatch match = new PhobiusMatch(signature, signature.getAccession(), locations); persistentProtein.addMatch(match); entityManager.persist(match);
protein.addMatch(match); // Adds protein to match (yes, I know it doesn't look that way!) entityManager.persist(match); matchLocationCount += match.getLocations().size();
LOGGER.debug("rpsBlast match: " + match); protein.addMatch(match);
protein.addMatch(match); entityManager.persist(match);