List of usage examples for java.util TreeSet clear
public void clear()
From source file:reconcile.hbase.ingest.rss.ImportRSS.java
/** * Add feed and entry fields as meta data to put * /* www. j ava2 s .c om*/ * @param put * @param feed * @param entry */ private void meta(Put put, SyndFeed feed, SyndEntry entry) { DocSchema.add(put, DocSchema.srcCF, DocSchema.srcName, source); DocSchema.add(put, DocSchema.srcCF, "tags", tags); // Add Feed Meta data DocSchema.add(put, DocSchema.metaCF, "feed_url", feed.getUri()); DocSchema.add(put, DocSchema.metaCF, "feed_link", feed.getLink()); DocSchema.add(put, DocSchema.metaCF, "feed_author", feed.getAuthor()); DocSchema.add(put, DocSchema.metaCF, "feed_copyright", feed.getCopyright()); DocSchema.add(put, DocSchema.metaCF, "feed_description", feed.getDescription()); DocSchema.add(put, DocSchema.metaCF, "feed_language", feed.getLanguage()); DocSchema.add(put, DocSchema.metaCF, "feed_type", feed.getFeedType()); DocSchema.add(put, DocSchema.metaCF, "feed_title", feed.getTitle()); // Add Entry Meta data DocSchema.add(put, DocSchema.metaCF, "title", entry.getTitle()); DocSchema.add(put, DocSchema.metaCF, "url", entry.getUri()); DocSchema.add(put, DocSchema.metaCF, "updated_date", DocSchema.formatSolrDate(entry.getUpdatedDate())); DocSchema.add(put, DocSchema.metaCF, "published_date", DocSchema.formatSolrDate(entry.getPublishedDate())); // Save authors TreeSet<String> values = new TreeSet<String>(); if (entry.getAuthor() != null) values.add(entry.getAuthor()); if (entry.getAuthors() != null) for (Object obj : entry.getAuthors()) { SyndPerson author = (SyndPerson) obj; values.add(author.getName()); } add(put, "authors", values); // Save links values.clear(); if (entry.getLink() != null) values.add(entry.getLink()); if (entry.getLinks() != null) for (Object obj : entry.getLinks()) { SyndLink link = (SyndLink) obj; values.add(link.getHref()); } add(put, "links", values); // Save categories values.clear(); if (entry.getCategories() != null) for (Object obj : entry.getCategories()) { SyndCategory cat = (SyndCategory) obj; values.add(cat.getName()); } add(put, "categories", values); DocSchema.addIngestDate(put); }
From source file:uk.ac.ebi.intact.util.protein.utils.AliasUpdaterUtils.java
public static AliasUpdateReport updateAliases(UniprotProtein uniprotProtein, Protein protein, AliasDao aliasDao, TreeSet<InteractorAlias> sortedAliases) { sortedAliases.clear(); sortedAliases.addAll(protein.getAliases()); Iterator<InteractorAlias> intactIterator = sortedAliases.iterator(); AliasUpdateReport report = new AliasUpdateReport(protein); // process genes TreeSet<String> geneNames = new TreeSet<String>(uniprotProtein.getGenes()); Iterator<String> geneIterator = geneNames.iterator(); InteractorAlias currentIntact = null; if (geneIterator.hasNext()) { currentIntact = compareAndUpdateAliases(protein, null, intactIterator, geneIterator, CvAliasType.GENE_NAME_MI_REF, report, aliasDao); }/*from www . j a v a2 s .c o m*/ // process synonyms TreeSet<String> geneSynonyms = new TreeSet<String>(uniprotProtein.getSynomyms()); Iterator<String> geneSynonymsIterator = geneSynonyms.iterator(); if (geneSynonymsIterator.hasNext()) { currentIntact = compareAndUpdateAliases(protein, currentIntact, intactIterator, geneSynonymsIterator, CvAliasType.GENE_NAME_SYNONYM_MI_REF, report, aliasDao); } // process orfs TreeSet<String> orfs = new TreeSet<String>(uniprotProtein.getOrfs()); Iterator<String> orfsIterator = orfs.iterator(); if (orfsIterator.hasNext()) { currentIntact = compareAndUpdateAliases(protein, currentIntact, intactIterator, orfsIterator, CvAliasType.ORF_NAME_MI_REF, report, aliasDao); } // process locus TreeSet<String> locuses = new TreeSet<String>(uniprotProtein.getLocuses()); Iterator<String> locusesIterator = locuses.iterator(); if (locusesIterator.hasNext()) { currentIntact = compareAndUpdateAliases(protein, currentIntact, intactIterator, locusesIterator, CvAliasType.LOCUS_NAME_MI_REF, report, aliasDao); } // delete remaining aliases if (currentIntact != null || intactIterator.hasNext()) { if (currentIntact == null) { currentIntact = intactIterator.next(); } do { protein.removeAlias(currentIntact); report.getRemovedAliases().add(currentIntact); aliasDao.delete(currentIntact); if (intactIterator.hasNext()) { currentIntact = intactIterator.next(); } else { currentIntact = null; } } while (currentIntact != null); } sortedAliases.clear(); return report; }
From source file:uk.ac.ebi.intact.util.protein.utils.AliasUpdaterUtils.java
public static AliasUpdateReport updateIsoformAliases(UniprotProtein master, UniprotProteinTranscript uniprotProteinTranscript, Protein protein, AliasDao aliasDao, TreeSet<InteractorAlias> sortedAliases) { sortedAliases.clear(); sortedAliases.addAll(protein.getAliases()); Iterator<InteractorAlias> intactIterator = sortedAliases.iterator(); AliasUpdateReport report = new AliasUpdateReport(protein); // process genes TreeSet<String> geneNames = new TreeSet<String>(master.getGenes()); Iterator<String> geneIterator = geneNames.iterator(); InteractorAlias currentIntact = null; if (geneIterator.hasNext()) { currentIntact = compareAndUpdateAliases(protein, null, intactIterator, geneIterator, CvAliasType.GENE_NAME_MI_REF, report, aliasDao); }//from w w w . jav a 2 s.co m // process synonyms TreeSet<String> geneSynonyms = new TreeSet<String>(master.getSynomyms()); Iterator<String> geneSynonymsIterator = geneSynonyms.iterator(); if (geneSynonymsIterator.hasNext()) { currentIntact = compareAndUpdateAliases(protein, currentIntact, intactIterator, geneSynonymsIterator, CvAliasType.GENE_NAME_SYNONYM_MI_REF, report, aliasDao); } // process orfs TreeSet<String> orfs = new TreeSet<String>(master.getOrfs()); Iterator<String> orfsIterator = orfs.iterator(); if (orfsIterator.hasNext()) { currentIntact = compareAndUpdateAliases(protein, currentIntact, intactIterator, orfsIterator, CvAliasType.ORF_NAME_MI_REF, report, aliasDao); } // process locus TreeSet<String> locuses = new TreeSet<String>(master.getLocuses()); Iterator<String> locusesIterator = locuses.iterator(); if (locusesIterator.hasNext()) { currentIntact = compareAndUpdateAliases(protein, currentIntact, intactIterator, locusesIterator, CvAliasType.LOCUS_NAME_MI_REF, report, aliasDao); } // process isoform synonyms TreeSet<String> isoformSynonyms = new TreeSet<String>(uniprotProteinTranscript.getSynomyms()); Iterator<String> isoformSynonymsIterator = isoformSynonyms.iterator(); if (isoformSynonymsIterator.hasNext()) { currentIntact = compareAndUpdateAliases(protein, currentIntact, intactIterator, isoformSynonymsIterator, CvAliasType.ISOFORM_SYNONYM_MI_REF, report, aliasDao); } // delete remaining aliases if (currentIntact != null || intactIterator.hasNext()) { if (currentIntact == null) { currentIntact = intactIterator.next(); } do { protein.removeAlias(currentIntact); report.getRemovedAliases().add(currentIntact); aliasDao.delete(currentIntact); if (intactIterator.hasNext()) { currentIntact = intactIterator.next(); } else { currentIntact = null; } } while (currentIntact != null); } sortedAliases.clear(); return report; }
From source file:uk.ac.ebi.intact.util.protein.utils.XrefUpdaterUtils.java
public static XrefUpdaterReport updateAllXrefs(Protein protein, UniprotProtein uniprotProtein, Map<String, String> databaseName2mi, DataContext context, ProteinUpdateProcessor processor, TreeSet<InteractorXref> sortedXrefs, TreeSet<UniprotXref> sortedUniprotXrefs) { sortedXrefs.clear(); sortedXrefs.addAll(protein.getXrefs()); Iterator<InteractorXref> intactIterator = sortedXrefs.iterator(); sortedUniprotXrefs.clear();// w w w .j a va2 s . c o m sortedUniprotXrefs.addAll(uniprotProtein.getCrossReferences()); Iterator<UniprotXref> uniprotIterator = sortedUniprotXrefs.iterator(); List<Xref> createdXrefs = new ArrayList<Xref>(uniprotProtein.getCrossReferences().size()); List<Xref> deletedXrefs = new ArrayList<Xref>(protein.getXrefs().size()); DaoFactory daoFactory = context.getDaoFactory(); CvObjectDao<CvDatabase> dbDao = daoFactory.getCvObjectDao(CvDatabase.class); XrefDao<InteractorXref> refDao = daoFactory.getXrefDao(InteractorXref.class); InteractorXref currentIntact = null; UniprotXref currentUniprot = null; String db = null; CvDatabase cvDatabase = null; if (intactIterator.hasNext() && uniprotIterator.hasNext()) { currentIntact = intactIterator.next(); currentUniprot = uniprotIterator.next(); db = databaseName2mi.get(currentUniprot.getDatabase().toLowerCase()); cvDatabase = currentIntact.getCvDatabase(); if (db != null && cvDatabase != null) { do { int dbComparator = cvDatabase.getIdentifier().compareTo(db); if (dbComparator == 0) { int acComparator = currentIntact.getPrimaryId().compareTo(currentUniprot.getAccession()); if (acComparator == 0) { if (intactIterator.hasNext() && uniprotIterator.hasNext()) { currentIntact = intactIterator.next(); currentUniprot = uniprotIterator.next(); db = databaseName2mi.get(currentUniprot.getDatabase().toLowerCase()); cvDatabase = currentIntact.getCvDatabase(); } else { currentIntact = null; currentUniprot = null; db = null; cvDatabase = null; } } else if (acComparator < 0) { //intact has no match in uniprot if (!CvDatabase.UNIPROT_MI_REF.equalsIgnoreCase(cvDatabase.getIdentifier()) && !CvDatabase.INTACT_MI_REF .equalsIgnoreCase(currentIntact.getCvDatabase().getIdentifier()) && !(currentIntact.getCvXrefQualifier() != null && ("intact-secondary" .equalsIgnoreCase(currentIntact.getCvXrefQualifier().getShortLabel()) || CvXrefQualifier.SECONDARY_AC.equalsIgnoreCase( currentIntact.getCvXrefQualifier().getShortLabel())))) { deletedXrefs.add(currentIntact); protein.removeXref(currentIntact); refDao.delete(currentIntact); } if (intactIterator.hasNext()) { currentIntact = intactIterator.next(); cvDatabase = currentIntact.getCvDatabase(); } else { currentIntact = null; cvDatabase = null; } } else { //uniprot has no match in intact CvDatabase cvDb = cvDatabase; InteractorXref newXref = new InteractorXref( IntactContext.getCurrentInstance().getInstitution(), cvDb, currentUniprot.getAccession(), null); protein.addXref(newXref); refDao.persist(newXref); createdXrefs.add(newXref); if (uniprotIterator.hasNext()) { currentUniprot = uniprotIterator.next(); db = databaseName2mi.get(currentUniprot.getDatabase().toLowerCase()); } else { currentUniprot = null; db = null; } } } else if (dbComparator < 0) { //intact has no match in uniprot if (!CvDatabase.UNIPROT_MI_REF .equalsIgnoreCase(currentIntact.getCvDatabase().getIdentifier()) && !CvDatabase.INTACT_MI_REF .equalsIgnoreCase(currentIntact.getCvDatabase().getIdentifier()) && !(currentIntact.getCvXrefQualifier() != null && ("intact-secondary" .equalsIgnoreCase(currentIntact.getCvXrefQualifier().getShortLabel()) || CvXrefQualifier.SECONDARY_AC.equalsIgnoreCase( currentIntact.getCvXrefQualifier().getShortLabel())))) { deletedXrefs.add(currentIntact); protein.removeXref(currentIntact); refDao.delete(currentIntact); } if (intactIterator.hasNext()) { currentIntact = intactIterator.next(); cvDatabase = currentIntact.getCvDatabase(); } else { currentIntact = null; cvDatabase = null; } } else { //uniprot has no match in intact CvDatabase cvDb = dbDao.getByIdentifier(db); if (cvDb != null) { InteractorXref newXref = new InteractorXref( IntactContext.getCurrentInstance().getInstitution(), cvDb, currentUniprot.getAccession(), null); protein.addXref(newXref); refDao.persist(newXref); createdXrefs.add(newXref); } else { log.debug("We are not copying across xref to " + db); } if (uniprotIterator.hasNext()) { currentUniprot = uniprotIterator.next(); db = databaseName2mi.get(currentUniprot.getDatabase().toLowerCase()); } else { currentUniprot = null; db = null; } } } while (currentIntact != null && currentUniprot != null && db != null && cvDatabase != null); } } if (currentIntact != null || intactIterator.hasNext()) { if (currentIntact == null) { currentIntact = intactIterator.next(); cvDatabase = currentIntact.getCvDatabase(); } do { //intact has no match in uniprot if (cvDatabase == null || (cvDatabase != null && !CvDatabase.UNIPROT_MI_REF.equalsIgnoreCase(cvDatabase.getIdentifier()) && !CvDatabase.INTACT_MI_REF.equalsIgnoreCase(cvDatabase.getIdentifier()) && !(currentIntact.getCvXrefQualifier() != null && ("intact-secondary" .equalsIgnoreCase(currentIntact.getCvXrefQualifier().getShortLabel()) || CvXrefQualifier.SECONDARY_AC .equalsIgnoreCase(currentIntact.getCvXrefQualifier().getShortLabel()))))) { deletedXrefs.add(currentIntact); protein.removeXref(currentIntact); refDao.delete(currentIntact); } if (intactIterator.hasNext()) { currentIntact = intactIterator.next(); cvDatabase = currentIntact.getCvDatabase(); } else { currentIntact = null; cvDatabase = null; } } while (currentIntact != null); } if (currentUniprot != null || uniprotIterator.hasNext()) { if (currentUniprot == null) { currentUniprot = uniprotIterator.next(); db = databaseName2mi.get(currentUniprot.getDatabase().toLowerCase()); } if (db != null) { do { //uniprot has no match in intact CvDatabase cvDb = dbDao.getByIdentifier(db); if (cvDb != null) { InteractorXref newXref = new InteractorXref( IntactContext.getCurrentInstance().getInstitution(), cvDb, currentUniprot.getAccession(), null); protein.addXref(newXref); refDao.persist(newXref); createdXrefs.add(newXref); } else { log.debug("We are not copying across xref to " + db); } if (uniprotIterator.hasNext()) { currentUniprot = uniprotIterator.next(); db = databaseName2mi.get(currentUniprot.getDatabase().toLowerCase()); } else { currentUniprot = null; db = null; } } while (currentUniprot != null && db != null); } } // update uniprot xrefs XrefUpdaterReport report = updateUniprotXrefs(protein, uniprotProtein, context, processor); if (report == null && (!createdXrefs.isEmpty() || !deletedXrefs.isEmpty())) { report = new XrefUpdaterReport(protein, createdXrefs, deletedXrefs); } else if (report != null && (!createdXrefs.isEmpty() || !deletedXrefs.isEmpty())) { report.getAddedXrefs().addAll(createdXrefs); report.getRemovedXrefs().addAll(deletedXrefs); } sortedXrefs.clear(); sortedUniprotXrefs.clear(); return report; }