public class IDMapperStack extends Object implements IDMapper, AttributeMapper
IDMapper's in a stack.
The behavior of the IDMapper interface implementations
differs per method:
if the method returns a single result, usually it is
from the first child database that has a sensible result.
This also means that the child databases have a definitive
ordering: the first one shadows the second one for some results.
If the method returns a list, IDMapperStack joins the result from all connected child databases together.
Transitive maps are deduced from the IDMappers, added to this IDMapperStack. Transitive maps are enabled as soon as the transitivity is set to be true.
In order to calculate the deduced transitive mappings, we build a graph that represents the possible mappings supported by the IDMappers in this IDMapperStack. The nodes of this graph are DataSources, the Edges are IDMappers. Possible mappings are loop free paths in this graph. We consider a path p to be loop free if no data source in p is reached twice by the same IDMapper.
The mapping graph for transitive maps is retained and re-calculated whenever an IDMapper is added or removed from this IDMapperStack.
MATCH_ID| Constructor and Description |
|---|
IDMapperStack() |
| Modifier and Type | Method and Description |
|---|---|
void |
addIDMapper(IDMapper idMapper)
Add an existing IDMapper to the stack.
|
IDMapper |
addIDMapper(String connectionString)
Create a fresh IDMapper from a connectionString and add it to the stack.
|
void |
close()
closes all child databases.
|
Map<Xref,String> |
freeAttributeSearch(String query,
String attrType,
int limit)
free text search for matching attributes.
|
Map<Xref,Set<String>> |
freeAttributeSearchEx(String query,
String attrType,
int limit)
Improved version of free text search for matching attributes.
|
Set<Xref> |
freeSearch(String text,
int limit)
free text search for matching symbols or identifiers.
|
Map<String,Set<String>> |
getAttributes(Xref ref)
Get all attributes for an entity.
|
Set<String> |
getAttributes(Xref ref,
String attrname)
Get attributes for an entity, such as gene Symbol.
|
Set<String> |
getAttributeSet()
Set of attributes provided by this AttributeMapper.
|
Map<String,Set<String>> |
getAttributesForAllMappings(Xref ref,
DataSource... dataSources) |
Set<String> |
getAttributesForAllMappings(Xref ref,
String attrname,
DataSource... dataSources) |
IDMapperCapabilities |
getCapabilities() |
IDMapper |
getIDMapperAt(int index) |
List<IDMapper> |
getMappers()
get all mappers
|
int |
getSize() |
boolean |
getTransitive() |
boolean |
isConnected()
Use this method to check if the IDMapper is still valid.
|
boolean |
isFreeAttributeSearchSupported() |
Map<Xref,Set<Xref>> |
mapID(Collection<Xref> srcXrefs,
DataSource... tgtDataSources)
Get all cross-references for a set of entities, restricting the
result to contain only references from the given set of data sources.
|
Set<Xref> |
mapID(Xref ref,
DataSource... resultDs)
Get all cross-references for the given entity, restricting the
result to contain only references from the given set of data sources.
|
void |
removeIDMapper(IDMapper idMapper)
Remove an idMapper from the stack.
|
void |
setTransitive(boolean value)
Set Transitivity mode, where all mappings are combined to infer
second degree mappings.
|
String |
toString() |
boolean |
xrefExists(Xref xref)
Check whether an Xref is known by the given mapping source.
|
public IDMapper addIDMapper(String connectionString) throws IDMapperException
connectionString - connectionString for configuring the new IDMapperIDMapperException - when the connection failed.public void addIDMapper(IDMapper idMapper)
idMapper - IDMapper to be added.public void setTransitive(boolean value)
value - true or falsepublic boolean getTransitive()
public void removeIDMapper(IDMapper idMapper)
idMapper - IDMapper to be removed.public void close()
throws IDMapperException
close in interface IDMapperIDMapperException - when closing failed for one of the databases. It will still try to
close all child databases even if one throws an exception. However, only the last exception will be thrown.public boolean xrefExists(Xref xref) throws IDMapperException
xrefExists in interface IDMapperxref - reference to checkIDMapperException - if failed, UnsupportedOperationException if it's not supported by the Driver.public boolean isConnected()
IDMapperisConnected in interface IDMapperpublic IDMapperCapabilities getCapabilities()
getCapabilities in interface IDMapperpublic Set<Xref> freeSearch(String text, int limit) throws IDMapperException
freeSearch in interface IDMappertext - text to searchlimit - up limit of number of hitsIDMapperException - if failedpublic Map<Xref,Set<Xref>> mapID(Collection<Xref> srcXrefs, DataSource... tgtDataSources) throws IDMapperException
mapID in interface IDMappersrcXrefs - source Xref, containing ID and ID type/data sourcetgtDataSources - target ID types/data sources. Set this to null
if you want to retrieve all results.IDMapperException - if the mapping service is (temporarily) unavailablepublic Set<String> getAttributes(Xref ref, String attrname) throws IDMapperException
getAttributes in interface AttributeMapperref - the entity to get the attribute forattrname - the attribute to look for, e.g. 'Symbol' or 'Description'.IDMapperException - if the mapping service is (temporarily) unavailablepublic Set<String> getAttributesForAllMappings(Xref ref, String attrname, DataSource... dataSources) throws IDMapperException
IDMapperExceptionpublic boolean isFreeAttributeSearchSupported()
isFreeAttributeSearchSupported in interface AttributeMapperpublic Map<Xref,String> freeAttributeSearch(String query, String attrType, int limit) throws IDMapperException
freeAttributeSearch in interface AttributeMapperquery - The text to search forattrType - the attribute to look for, e.g. 'Symbol' or 'Description'.
If you use the special MATCH_ID constant, it will query the identifier instead.limit - The number of results to limit the search toIDMapperException - if the mapping service is (temporarily) unavailablepublic Map<Xref,Set<String>> freeAttributeSearchEx(String query, String attrType, int limit) throws IDMapperException
AttributeMapperfreeAttributeSearchEx in interface AttributeMapperquery - The text to search forattrType - the attribute to look for, e.g. 'Symbol' or 'Description'.
If you use the special MATCH_ID constant, it will query the identifier instead.limit - The number of results to limit the search toIDMapperException - if the mapping service is (temporarily) unavailablepublic String toString()
public int getSize()
public IDMapper getIDMapperAt(int index)
index - in the range 0 <= index < getSize()public Set<Xref> mapID(Xref ref, DataSource... resultDs) throws IDMapperException
mapID in interface IDMapperref - the entity to get cross-references for.resultDs - target ID types/data sources. Set this to null if you
want to retrieve all results.IDMapperException - if the mapping service is (temporarily) unavailablepublic Set<String> getAttributeSet() throws IDMapperException
getAttributeSet in interface AttributeMapperIDMapperException - if the mapping service is (temporarily) unavailablepublic Map<String,Set<String>> getAttributes(Xref ref) throws IDMapperException
getAttributes in interface AttributeMapperref - the entity to get the attributes forIDMapperException - if the mapping service is (temporarily) unavailablepublic Map<String,Set<String>> getAttributesForAllMappings(Xref ref, DataSource... dataSources) throws IDMapperException
IDMapperExceptionCopyright © 2006–2021 BridgeDb project. All rights reserved.