public final class InternalUtils extends Object
Warning! This class is not part of the public API of BridgeDb. Methods in this class may disappear or change in backwards-incompatible ways. This class should not be used by applications!
| Modifier and Type | Method and Description |
|---|---|
static InputStream |
getInputStream(String source) |
static InputStream |
getInputStream(URL source)
Start downloading a file from the web and open an InputStream to it.
|
static Map<DataSource,Set<Xref>> |
groupByDataSource(Collection<Xref> srcXrefs)
Split a heterogeneous
Xref set into multiple homogeneous Xref sets. |
static String |
joinIds(Collection<Xref> refs,
String sep)
Join the ID part of a collection of Xrefs with a custom separator.
|
static Map<Xref,Set<Xref>> |
mapMultiFromSingle(IDMapper mapper,
Collection<Xref> srcXrefs,
DataSource... tgt)
call the "single" mapID (Xref, ...) multiple times
to perform mapping of a Set.
|
static Set<Xref> |
mapSingleFromMulti(IDMapper mapper,
Xref src,
DataSource... tgt)
call the "multi" mapID (Set, ...) using a Set with one item
to perform mapping of a single ID.
|
static <T,U> void |
multiMapAdd(Map<T,List<U>> map,
T key,
U val)
Generic method for multimaps, a map that can contain multiple values per key.
|
static <T,U> void |
multiMapPut(Map<T,Set<U>> map,
T key,
U val)
Generic method for multimaps, a map that can contain multiple values per key.
|
static <T,U> void |
multiMapPutAll(Map<T,Set<U>> map,
T key,
Collection<U> vals)
Generic method for multimaps, a map that can contain multiple values per key.
|
static Map<String,String> |
parseLocation(String location,
String... allowedParams)
parse configuration params of the connection string.
|
static void |
readXmlConfig(InputSource is)
read a configuration file in the bridgedb xml format
|
public static Map<Xref,Set<Xref>> mapMultiFromSingle(IDMapper mapper, Collection<Xref> srcXrefs, DataSource... tgt) throws IDMapperException
This is intended for IDMappers that don't gain any advantage of mapping multiple ID's at a time. They can implement mapID(Xref, ...), and use mapMultiFromSingle to simulate mapID(Set, ...)
mapper - used for performing a single mappingsrcXrefs - xrefs to translatetgt - DataSource(s) to map to, optional.IDMapperException - when mapper.mapID throws IDMapperExceptionpublic static Set<Xref> mapSingleFromMulti(IDMapper mapper, Xref src, DataSource... tgt) throws IDMapperException
This is intended for IDMappers that have a performance advantage of mapping multiple ID's at a time. They can implement mapID(Set, ...), and use mapSingleFromMulti to simulate mapID(Xref, ...)
mapper - used for performing a multi-mappingsrc - xref to translatetgt - DataSource(s) to map to, optional.IDMapperException - when mapper.mapID throws IDMapperExceptionpublic static Map<String,String> parseLocation(String location, String... allowedParams)
location - configuration string to parse.allowedParams - allowed argument names to appear before =IllegalArgumentException - if arguments do not follow the key=val structure, or
if the key is not in allowedParamspublic static InputStream getInputStream(String source) throws IOException
IOExceptionpublic static InputStream getInputStream(URL source) throws IOException
source - location of file to download.IOException - after a number of attempts to connect to the remote server have failed.public static <T,U> void multiMapPut(Map<T,Set<U>> map, T key, U val)
T - key type of multimapU - value type of multimapmap - multimap to work onkey - key of the value to insertval - value to insert.public static <T,U> void multiMapAdd(Map<T,List<U>> map, T key, U val)
This is like multiMapPut, but uses a list instead of a set for each value of the map.
T - key type of multimapU - value type of multimapmap - multimap to work onkey - key of the value to insertval - value to insert.public static <T,U> void multiMapPutAll(Map<T,Set<U>> map, T key, Collection<U> vals)
multiMapPutAll let's you insert a collection of items at once.
T - key type of multimapU - value type of multimapmap - multimap to work onkey - key of the value to insertvals - values to insert.public static Map<DataSource,Set<Xref>> groupByDataSource(Collection<Xref> srcXrefs)
Xref set into multiple homogeneous Xref sets.
If the input contains {L:3643, L:1234, X:1004_at, X:1234_at}, then the output will contain { L=> {L:3643, L:1234}, X=> {X:1004_at, X:1234_at} }.
srcXrefs - the set to splitpublic static String joinIds(Collection<Xref> refs, String sep)
refs - Xrefs from which the ids will be concatenatedsep - separator string.public static void readXmlConfig(InputSource is) throws ParserConfigurationException, SAXException, IOException
Copyright © 2006–2021 BridgeDb project. All rights reserved.