Ticket #57 (new)

Opened 23 months ago

Implement a "org.bridgedb.webservice.uniprot"

Reported by: martijn Owned by: martijn
Milestone: Component: Core library
Version: Severity: major
Keywords: Cc:

Description

As suggested by Igor Rodchenkov:

Implementing a "org.bridgedb.webservice.uniprot" should not be difficult (but requires time and care) because of the following ideas:

-  http://www.uniprot.org/faq/28 -  http://www.uniprot.org/uniprot/?format=tab&columns=id,organism,taxon,database(ensembl),sequence&query=accession:Q0VCL1

e.g., this way:

public class SimpleUniprotQuery? {

public static final String QUERYBASE = " http://www.uniprot.org/uniprot/?format=tab&";

public static final Pattern PATTERN = Pattern

.compile("([A-N,R-Z][0-9][A-Z][A-Z, 0-9][A-Z, 0-9][0-9])|([O,P,Q][0-9][A-Z, 0-9][A-Z, 0-9][A-Z, 0-9][0-9])$");

public static String getPrimaryId(String id) {

String query = QUERYBASE + "columns=id&query=accession:" + id;

try {

URL url = new URL(query);

BufferedReader? in = new BufferedReader?(new InputStreamReader?(url.openStream()));

in.readLine(); // skip title

String line = in.readLine();

Matcher matcher = PATTERN.matcher(line.trim());

if (matcher.find()) { return matcher.group(); }

} catch (IOException ex) {

throw new RuntimeException?("Cannot get result from " + query, ex);

}

return null;

}

}

Note: See TracTickets for help on using tickets.