Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added a wrapper for the functionality to guess identifier types
  • Loading branch information
egonw committed Jan 11, 2012
1 parent bb3ba81 commit af5fd32
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Expand Up @@ -11,14 +11,18 @@
package net.bioclipse.bridgedb.business;

import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import net.bioclipse.core.business.BioclipseException;
import net.bioclipse.managers.business.IBioclipseManager;

import org.apache.log4j.Logger;
import org.bridgedb.BridgeDb;
import org.bridgedb.DataSource;
import org.bridgedb.DataSourcePatterns;
import org.bridgedb.IDMapper;
import org.bridgedb.IDMapperException;
import org.bridgedb.Xref;
Expand Down Expand Up @@ -66,6 +70,17 @@ public Set<String> search(String restService, String query, int limit) throws Bi
}
}

public Set<DataSource> guessIdentifierType(String identifier) throws BioclipseException {
Map<DataSource, Pattern> patterns = DataSourcePatterns.getPatterns();

Set<DataSource> sources = new HashSet<DataSource>();
for (DataSource source : patterns.keySet()) {
Matcher matcher = patterns.get(source).matcher(identifier);
if (matcher.matches()) sources.add(source);
}
return sources;
}

public Set<String> map(String restService, String identifier, String source) throws BioclipseException {
return map(restService, identifier, source, null);
}
Expand Down
Expand Up @@ -57,6 +57,13 @@ public interface IBridgedbManager extends IBioclipseManager {
)
public DataSource getSource(String source) throws BioclipseException;

@Recorded
@PublishedMethod(
methodSummary="Guesses the data source type from the given identifire using a set of predefined patterns.",
params="String identifier"
)
public Set<DataSource> guessIdentifierType(String identifier) throws BioclipseException;

@Recorded
@PublishedMethod(
methodSummary="List all data sources."
Expand Down

0 comments on commit af5fd32

Please sign in to comment.