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; }
protected void addToMoleculeCollection(String sequence, final String currentId, final Set<Protein> parsedMolecules) { sequence = WHITE_SPACE_PATTERN.matcher(sequence).replaceAll(""); Protein thisProtein = new Protein(sequence); // Check if this sequence is already in the Set. If it is, retrieve it. boolean isMoleculeAdded = parsedMolecules.add(thisProtein); if (!isMoleculeAdded) { for (Protein existing : parsedMolecules) { if (existing.getMd5().equals(thisProtein.getMd5())) { thisProtein = existing; break; } } } // Add the Xref to the Protein object. (Being added to a Set, so no risk of duplicates) thisProtein.addCrossReference(XrefParser.getProteinXref(currentId)); } }
/** * This method stores sequences with (optionally) cross references. * The method attempts to store them in batches by calling the addProteinToBatch(Protein protein) * method. This in turn calls persistBatch(), when the batch size has been reached. * <p/> * * @param sequence being the protein sequence to store * @param crossReferences being a set of Cross references. */ public void store(String sequence, Map<String, SignatureLibraryRelease> analysisJobMap, String... crossReferences) { if (sequence != null && sequence.length() > 0) { Protein protein = new Protein(sequence); if (crossReferences != null) { for (String crossReference : crossReferences) { ProteinXref xref = XrefParser.getProteinXref(crossReference); protein.addCrossReference(xref); } } proteinsAwaitingPrecalcLookup.add(protein); if (proteinsAwaitingPrecalcLookup.size() > proteinPrecalcLookupBatchSize) { lookupProteins(analysisJobMap); } } }