protected void processAddedAliasEvent(Alias added) { // the added alias is gene name and it is not the current gene name if (geneName == null && AliasUtils.doesAliasHaveType(added, Alias.GENE_NAME_MI, Alias.GENE_NAME)){ geneName = added; } }
protected void processRemovedAliasEvent(Alias removed) { if (geneName != null && geneName.equals(removed)){ geneName = AliasUtils.collectFirstAliasWithType(getAliases(), Alias.GENE_NAME_MI, Alias.GENE_NAME); } }
public void buildOntology(Map<String, T> id2Terms, Map<String, T> name2Terms) { // 1. convert and index all terms (note: at this stage we don't handle the hierarchy) for ( Iterator iterator = ontBean.getTerms().iterator(); iterator.hasNext(); ) { Term term = ( Term ) iterator.next(); // convert term into a OboTerm T ontologyTerm = createNewTerm(term); final Collection<TermSynonym> synonyms = term.getSynonyms(); if( synonyms != null ) { for ( TermSynonym synonym : synonyms ) { ontologyTerm.getSynonyms().add(AliasUtils.createAlias(Alias.SYNONYM, Alias.SYNONYM_MI, synonym.getSynonym())); } } id2Terms.put(term.getIdentifier(), ontologyTerm); name2Terms.put(term.getName(), ontologyTerm); } }
for(Gene g : entry.getGenes()){ if(g.hasGeneName()) p.getAliases().add(AliasUtils.createGeneName(g.getGeneName().getValue())); p.getAliases().add( AliasUtils.createGeneNameSynonym(gns.getValue())); p.getAliases().add( AliasUtils.createOrfName(orf.getValue())); p.getAliases().add( AliasUtils.createLocusName(oln.getValue())); p.getAliases().add( AliasUtils.createIsoformSynonym( syn.getValue() ));
jamiGene.getAliases().add(AliasUtils.createGeneName(entityGene.getGeneName().getValue())); for(GeneNameSynonym synonym : entityGene.getGeneNameSynonyms()){ jamiGene.getAliases().add(AliasUtils.createGeneNameSynonym(synonym.getValue()));
protected void processSynonyms(Term term, OntologyTerm ontologyTerm) { Collection<TermSynonym> synonyms = term.getSynonyms(); if (synonyms != null){ for (TermSynonym synonym : synonyms){ Term synonymType = synonym.getSynonymType(); //PSI-MOD-label for MOD if (synonymType != null){ if (SHORTLABEL_IDENTIFIER.equalsIgnoreCase(synonymType.getName()) || MOD_SHORTLABEL_IDENTIFIER.equalsIgnoreCase(synonymType.getName())){ ontologyTerm.setShortName(synonym.getSynonym()); } else if (ALIAS_IDENTIFIER.equalsIgnoreCase(synonymType.getName()) || MOD_ALIAS_IDENTIFIER.equalsIgnoreCase(synonymType.getName()) || RESID_IDENTIFIER.equalsIgnoreCase(synonymType.getName()) || RESID_MISNOMER_IDENTIFIER.equalsIgnoreCase(synonymType.getName()) || RESID_NAME_IDENTIFIER.equalsIgnoreCase(synonymType.getName()) || RESID_SYSTEMATIC_IDENTIFIER.equalsIgnoreCase(synonymType.getName()) || UNIPROT_FEATURE_IDENTIFIER.equalsIgnoreCase(synonymType.getName()) || EXACT_KEY.equalsIgnoreCase(synonymType.getName())){ ontologyTerm.getSynonyms().add(AliasUtils.createAlias(Alias.SYNONYM, Alias.SYNONYM_MI, synonym.getSynonym())); } } } } }
for(Gene g : entry.getGenes()){ if(g.hasGeneName()) p.getAliases().add(AliasUtils.createGeneName(g.getGeneName().getValue())); p.getAliases().add( AliasUtils.createGeneNameSynonym(gns.getValue())); p.getAliases().add( AliasUtils.createOrfName(orf.getValue())); p.getAliases().add( AliasUtils.createLocusName(oln.getValue()));
protected void processSynonyms(Term term, T ontologyTerm) { Collection<TermSynonym> synonyms = term.getSynonyms(); if (synonyms != null){ for (TermSynonym synonym : synonyms){ Term synonymType = synonym.getSynonymType(); //PSI-MOD-label for MOD if (synonymType != null){ if (SHORTLABEL_IDENTIFIER.equalsIgnoreCase(synonymType.getName()) || MOD_SHORTLABEL_IDENTIFIER.equalsIgnoreCase(synonymType.getName())){ ontologyTerm.setShortName(synonym.getSynonym()); } else if (ALIAS_IDENTIFIER.equalsIgnoreCase(synonymType.getName()) || MOD_ALIAS_IDENTIFIER.equalsIgnoreCase(synonymType.getName()) || RESID_IDENTIFIER.equalsIgnoreCase(synonymType.getName()) || RESID_MISNOMER_IDENTIFIER.equalsIgnoreCase(synonymType.getName()) || RESID_NAME_IDENTIFIER.equalsIgnoreCase(synonymType.getName()) || RESID_SYSTEMATIC_IDENTIFIER.equalsIgnoreCase(synonymType.getName()) || UNIPROT_FEATURE_IDENTIFIER.equalsIgnoreCase(synonymType.getName()) || EXACT_KEY.equalsIgnoreCase(synonymType.getName())){ ontologyTerm.getSynonyms().add(AliasUtils.createAlias(Alias.SYNONYM, Alias.SYNONYM_MI, synonym.getSynonym())); } } } } }
protected void processAddedAliasEvent(Alias added) { if (recommendedName == null && AliasUtils.doesAliasHaveType(added, Alias.COMPLEX_RECOMMENDED_NAME_MI, Alias.COMPLEX_RECOMMENDED_NAME)){ recommendedName = added; } else if (systematicName == null && AliasUtils.doesAliasHaveType(added, Alias.COMPLEX_SYSTEMATIC_NAME_MI, Alias.COMPLEX_SYSTEMATIC_NAME)){ systematicName = added; } }
p.getAliases().add(AliasUtils.createGeneName(g.getGeneName().getValue())); && !g.getGeneNameSynonyms().isEmpty()){ for(GeneNameSynonym gns : g.getGeneNameSynonyms()){ p.getAliases().add(AliasUtils.createGeneNameSynonym(gns.getValue())); && !g.getORFNames().isEmpty()){ for(ORFName orf : g.getORFNames()){ p.getAliases().add(AliasUtils.createOrfName(orf.getValue())); && !g.getOrderedLocusNames().isEmpty()){ for(OrderedLocusName oln : g.getOrderedLocusNames()){ p.getAliases().add(AliasUtils.createLocusName(oln.getValue()));
protected void processRemovedAliasEvent(Alias removed) { if (recommendedName != null && recommendedName.equals(removed)){ recommendedName = AliasUtils.collectFirstAliasWithType(getAliases(), Alias.COMPLEX_RECOMMENDED_NAME_MI, Alias.COMPLEX_RECOMMENDED_NAME); } else if (systematicName != null && systematicName.equals(removed)){ systematicName = AliasUtils.collectFirstAliasWithType(getAliases(), Alias.COMPLEX_SYSTEMATIC_NAME_MI, Alias.COMPLEX_SYSTEMATIC_NAME); } }
currentOrganism.getAliases().add(AliasUtils.createAlias(Alias.SYNONYM, Alias.SYNONYM_MI, currentOrganism.getCommonName())); currentOrganism.getAliases().add(AliasUtils.createAlias(Alias.SYNONYM, Alias.SYNONYM_MI, currentOrganism.getScientificName())); currentOrganism.setScientificName(organism.getCommonName()); fullNameLength = organism.getCommonName().length(); currentOrganism.getAliases().add(AliasUtils.createAlias(Alias.SYNONYM, Alias.SYNONYM_MI, organism.getCommonName()));
/** * The source of the Alias is uniprotkb if the alias type is gene name, gene name synonym, isoform synonym, * locus name or orf name. It is unknown otherwise. * @param alias * @return the default dbsource for this alias */ public static String findDbSourceForAlias(Alias alias){ // these aliases should come from uniprotkb if (AliasUtils.doesAliasHaveType(alias, Alias.GENE_NAME_MI, Alias.GENE_NAME) || AliasUtils.doesAliasHaveType(alias, Alias.GENE_NAME_SYNONYM_MI, Alias.GENE_NAME_SYNONYM) || AliasUtils.doesAliasHaveType(alias, Alias.ISOFORM_SYNONYM_MI, Alias.ISOFORM_SYNONYM) || AliasUtils.doesAliasHaveType(alias, Alias.LOCUS_NAME_MI, Alias.LOCUS_NAME) || AliasUtils.doesAliasHaveType(alias, Alias.ORF_NAME_MI, Alias.ORF_NAME)){ return Xref.UNIPROTKB; } return UNKNOWN_DATABASE; }
currentOrganism.getAliases().add(AliasUtils.createAlias(Alias.SYNONYM, Alias.SYNONYM_MI, currentOrganism.getCommonName())); currentOrganism.getAliases().add(AliasUtils.createAlias(Alias.SYNONYM, Alias.SYNONYM_MI, currentOrganism.getScientificName())); currentOrganism.setScientificName(organism.getCommonName()); fullNameLength = organism.getCommonName().length(); currentOrganism.getAliases().add(AliasUtils.createAlias(Alias.SYNONYM, Alias.SYNONYM_MI, organism.getCommonName()));
/** * This method will return the first Alias having this typeId/type name * It will return null if there are no Alias with this type id/name * @param aliases : the collection of Alias * @param typeId : the type id to look for * @param typeName : the type name to look for * @return the first alias having this type name/id, null if no Alias with this type name/id */ public static Alias collectFirstAliasWithType(Collection<? extends Alias> aliases, String typeId, String typeName){ if (aliases == null || aliases.isEmpty()){ return null; } for (Alias alias : aliases){ if (doesAliasHaveType(alias, typeId, typeName)){ return alias; } } return null; }
private BioactiveEntity createNewBioactiveEntity(Entity entity) { CvTerm entityType = retrieveMoleculeTypeFrom(entity); BioactiveEntity bioactiveEntity = new DefaultBioactiveEntity(entity.getChebiAsciiName(), entity.getChebiAsciiName(), entityType); // == Chebi ID bioactiveEntity.setChebi( entity.getChebiId() ); // == Secondary CHEBI IDs for(String secondaryId : entity.getSecondaryChEBIIds()){ bioactiveEntity.getIdentifiers().add(XrefUtils.createChebiSecondary(secondaryId)); } // == Smile bioactiveEntity.setSmile( entity.getSmiles() ); // == Inchi / Inchi Key bioactiveEntity.setStandardInchi( entity.getInchi() ); bioactiveEntity.setStandardInchiKey( entity.getInchiKey() ); // == SYNONYMS for(DataItem syn : entity.getSynonyms()){ bioactiveEntity.getAliases().add(AliasUtils.createAlias( Alias.SYNONYM, Alias.SYNONYM_MI, syn.getData())); } // == IUPAC names for(DataItem syn : entity.getIupacNames()){ bioactiveEntity.getAliases().add(AliasUtils.createAlias( Alias.IUPAC , Alias.IUPAC_MI , syn.getData())); } return bioactiveEntity; }
/** * Remove all Alias having this method name/method id from the collection of aliases * @param aliases : the collection of Checksum * @param typeId : the method id to look for * @param typeName : the method name to look for */ public static void removeAllAliasesWithType(Collection<Alias> aliases, String typeId, String typeName){ if (aliases != null){ Iterator<Alias> aliasIterator = aliases.iterator(); while (aliasIterator.hasNext()){ if (doesAliasHaveType(aliasIterator.next(), typeId, typeName)){ aliasIterator.remove(); } } } }
public static psidev.psi.mi.jami.model.Organism createOrganismFromEntry(UniProtEntry entity){ if(entity.getNcbiTaxonomyIds() == null || entity.getNcbiTaxonomyIds().isEmpty()){ return OrganismUtils.createUnknownOrganism(); } else if(entity.getNcbiTaxonomyIds().size() > 1){ throw new IllegalArgumentException( "Uniprot entry ["+entity.getPrimaryUniProtAccession().getValue()+"] " +"has multiple organisms."); } else { String id = entity.getNcbiTaxonomyIds().get(0).getValue(); try{ psidev.psi.mi.jami.model.Organism o = new DefaultOrganism( Integer.parseInt( id ) ); if(entity.getOrganism().hasCommonName()) o.setCommonName(entity.getOrganism().getCommonName().getValue()); if(entity.getOrganism().getScientificName() != null) o.setScientificName(entity.getOrganism().getScientificName().getValue()); if(entity.getOrganism().hasSynonym()) o.getAliases().add(AliasUtils.createAlias(Alias.SYNONYM, Alias.SYNONYM_MI, entity.getOrganism().getSynonym().getValue())); return o; }catch(NumberFormatException n){ throw new IllegalArgumentException("Uniprot entry ["+entity.getPrimaryUniProtAccession().getValue()+"] " + "has a TaxonomyID which could not be cast to an integer: ("+id+").",n); } } } }
/** * Extract all the aliases having a specific type. * @param aliases : the aliases to analyse * @param typeId : the alias type MI identifier * @param typeName : the alias type name * @return the selection of aliases having the specified type (typeId or typeName if no ids) */ public static Collection<Alias> collectAllAliasesHavingType(Collection<? extends Alias> aliases, String typeId, String typeName){ if (aliases == null || aliases.isEmpty()){ return Collections.EMPTY_LIST; } Collection<Alias> selectedAliases = new ArrayList<Alias>(aliases.size()); for (Alias alias : aliases){ if (doesAliasHaveType(alias, typeId, typeName)){ selectedAliases.add(alias); } } return selectedAliases; }
if (AliasUtils.doesAliasHaveType(alias, Checksum.SMILE_MI, Checksum.SMILE) || AliasUtils.doesAliasHaveType(alias, Checksum.SMILE_MI, Checksum.SMILE_SHORT)){ createChecksumFromAlias(interactor, alias); else if (AliasUtils.doesAliasHaveType(alias, Checksum.INCHI_KEY_MI, Checksum.INCHI_KEY)){ createChecksumFromAlias(interactor, alias); else if (AliasUtils.doesAliasHaveType(alias, Checksum.STANDARD_INCHI_KEY_MI, Checksum.STANDARD_INCHI_KEY)){ createChecksumFromAlias(interactor, alias); else if (AliasUtils.doesAliasHaveType(alias, Checksum.INCHI_MI, Checksum.INCHI) || AliasUtils.doesAliasHaveType(alias, Checksum.INCHI_MI, Checksum.INCHI_SHORT)){ createChecksumFromAlias(interactor, alias); else if (AliasUtils.doesAliasHaveType(alias, Checksum.ROGID_MI, Checksum.ROGID) || AliasUtils.doesAliasHaveType(alias, null, Checksum.IROGID)){ createChecksumFromAlias(interactor, alias);