}
}
if (refs.isEmpty() && !useSelectedNodes)
{
StringInputDialog dialog = new StringInputDialog(main.getShell(), "Query Pathways",
"Enter UniProt or Entrez Gene ID", null);
String ids = dialog.open();
if (ids != null && ids.trim().length() > 0)
{
for (String id : ids.split(" "))
{
if (id.length() < 1) continue;
String dbtext = Character.isDigit(id.charAt(0)) ?
XRef.ENTREZ_GENE : XRef.UNIPROT;
refs.add(new XRef(dbtext + ":" + id));
}
}
}
if (!refs.isEmpty())
{
try
{
main.lockWithMessage("Querying Pathway Commons Database ...");
PathwayCommonsIOHandler ioHandler = new PathwayCommonsIOHandler(new SimpleIOHandler());
Map<String, String> pathToID = new HashMap<String, String>();
List<String> resultPathways = new ArrayList<String>();
XRef xr = XRef.getFirstRef(refs,
new String[]{XRef.CPATH, XRef.ENTREZ_GENE, XRef.UNIPROT});
refs.clear();
if (xr != null)
{
refs.add(xr);
}
else
{
MessageDialog.openError(main.getShell(), "No Reference ID",
"No CPATH, Entrez Gene or UniProt ID found to query.");
}
for (XRef ref : refs)
{
if (ref.getDb().equalsIgnoreCase(XRef.CPATH))
{
ioHandler.setInputIdType(PathwayCommonsIOHandler.ID_TYPE.CPATH_ID);
}
else if (ref.getDb().equalsIgnoreCase(XRef.UNIPROT))
{
ioHandler.setInputIdType(PathwayCommonsIOHandler.ID_TYPE.UNIPROT);
}
else if (ref.getDb().equalsIgnoreCase(XRef.ENTREZ_GENE))
{
ioHandler.setInputIdType(PathwayCommonsIOHandler.ID_TYPE.ENTREZ_GENE);
}
else
{
continue;
}
System.out.println("Querying pathways for " + ref);
List<List<String>> resultList = ioHandler.getPathways(ref.getRef());
main.unlock();
if (resultList.get(0).get(0).contains("xml"))
{
MessageDialog.openError(main.getShell(), "Error!", "Unexpected error!");
resultList.clear();
}
else if (resultList.get(1).size() == 2)
{
// MessageDialog.openInformation(main.getShell(), "No results",
// "No results found.");
resultList.clear();
}
else
{
resultList.remove(0);
}
// Prepare the result as listable pathway items
for (List<String> columns : resultList)
{
assert columns.size() == 4;
String cpathid = columns.get(3);
if (!pathToID.containsValue(cpathid))
{
String pathwayName = columns.get(1);
String db = columns.get(2);
String line = "[" + db + "] " + pathwayName;
resultPathways.add(line);
pathToID.put(line, cpathid);
}
}
}
if (!resultPathways.isEmpty())
{
ArrayList<String> selectedItems = new ArrayList<String>();
ItemSelectionDialog dialog = new ItemSelectionDialog(main.getShell(),
500,
"Pathway Selection Dialog",
"Select pathways to retrieve",
resultPathways, selectedItems,
true, true, null);
dialog.setMinValidSelect(1);
dialog.open();
List<String> idList = new ArrayList<String>();
if (!dialog.isCancelled())
{
for (String item : selectedItems)
{
idList.add(pathToID.get(item));
}