Several years ago a friend of mine introduced me to mindmaps as a tool for helping people visualize and link concepts (see below). The Online Mendelian Inheritance In Man (OMIM) database, created by Johns Hopkins University contains information on the genetic origins of diseases. It gives scientists a good overview of a disease and often serves as a starting point for further research. In this BioGroovy hack, I’ll show you how to create a simple script to convert an OMIM record into a mindmap. You’ll need to download and install FreeMind in order to visualize the results.
The script itself is rather simple (albeit longwinded). It downloads and parses an OMIM XML record, and then uses a series of GPath expressions to parse out the interesting bits of the record and put the results into an output file (in this case “omim2.mm”). Once you’ve run the script, open the output file with FreeMind. Clicking on any of the nodes will fire up a browser and display the results. For a bit of added fun, you can export the results as a Flash site and explore it with your browser. You can also publish the Flash site to a website and share it with your colleagues.
def omim = new
XmlParser().parse('http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=omim&id=260350&retmode=xml&rettype=full')
// GPath definitions
def title = omim.'Mim-entry'.'Mim-entry_title'.text()
def main_text = omim.'Mim-entry'.'Mim-entry_text'.'Mim-text'.'Mim-text_text'.text()
def omimLink = omim.'Mim-entry'.'Mim-entry_mimNumber'.text()
def symbolList = omim.'Mim-entry'.'Mim-entry_symbol'.text().split(",")
def pmidList = omim.'Mim-entry'.'Mim-entry_text'.'Mim-text'.'Mim-text_neighbors'.'Mim-link'.'Mim-link_uids'.text().split(",")
def textFieldList = omim.'Mim-entry'.'Mim-entry_textfields'.'Mim-text'
def nucList = omim.'Mim-entry'.'Mim-entry_nucleotideLinks'.'Mim-link'.'Mim-link_uids'.text().split(",")
def protList = omim.'Mim-entry'.'Mim-entry_proteinLinks'.'Mim-link'.'Mim-link_uids'.text().split(",")
def refList = omim.'Mim-entry'.'Mim-entry_references'.'Mim-reference'
// URL definitions
def entrezgeneUrl = "";
def pubmedUrl = "http://www.ncbi.nlm.nih.gov/sites/entrez?holding=&db=pubmed&cmd=search&term="
def omimUrl = "http://www.ncbi.nlm.nih.gov/entrez/dispomim.cgi?id="
def nucUrl = "http://www.ncbi.nlm.nih.gov/nucleotide/"
def protUrl = "http://www.ncbi.nlm.nih.gov/protein/"
FileOutputStream out = new FileOutputStream(new File('omim2.mm'));
out << '<?xml version="1.0"?>\n'
out << '<map>\n'
out << "<node text=\"${title}\" link='${omimUrl}${omimLink}'>\n"
// handle description
out
<< "<richcontent
type=\"note\"><html><head/><body>${main_text}</body></html></richcontent>"
// handle Gene Symbol Nodes
out << '<node text="genes" position=\"left\">'
symbolList.each(){
out << "<node text=\"${it.trim()}\"
link='http://www.ncbi.nlm.nih.gov/sites/entrez?holding=&db=gene&cmd=search&term=${it}%20AND%20Homo%20Sapiens[organism]'/>"
}
out << '</node>'
// handle references
out << '<node text="References" folded="true">'
refList.each(){node ->
def citTitle = node.'Mim-reference_citationTitle'.text();
def uid = node.'Mim-reference_pubmedUID'.text()
out << "<node text=\"${citTitle}\" link=\"${pubmedUrl}${uid}\"/>"
}
out << '</node>'
// handle TEXT nodes
textFieldList.each(){
def reftitle = it.'Mim-text_label'.text();
def text = it.'Mim-text_text'.text()
out << "<node text=\"${reftitle}\" folded=\"true\">"
out << "<richcontent
type=\"note\"><html><head/><body><![CDATA[${text}]]></body></html></richcontent>"
def uids = it.'Mim-text_neighbors'.'Mim-link'.'Mim-link_uids'.text().split(",")
uids.each(){pmid ->
if (pmid != ""){
out << "<node text=\"${pmid}\" link=\"${pubmedUrl}${pmid}\"/>"
}
}
out << "</node>"
}
// handle nucleotide links
out << "<node text=\"Nucleotides\" position=\"left\">"
nucList.each(){
out << "<node text=\"${it}\" link=\"${nucUrl}${it}\"/>"
}
out << "</node>"
// handle protein links
out << "<node text=\"Proteins\" position=\"left\">"
protList.each(){
out << "<node text=\"${it}\" link=\"${protUrl}${it}\"/>"
}
out << "</node>"out << '</node></map>'
out.flush();
out.close();

Hi,
Thank you for creating such a great tool. I am looking forward to producing some interesting mindmaps.
I am not experienced with groovy though, so I expect a steep learning curve. Could you please help me figure out why I don’t get the finished output file. I downloaded groovy and ran your script but I don’t find an omim2.mm output file anywhere.
I replaced ‘Mim-entry” by a know disease name, is that correct, or should I enter an ID number?
Thank you,
Fabio
The script uses an OMIM ID as a parameter in the URL in line 2. You can replace the “id” parameter with any other disease and it should create a mindmap file for you. The output file should be located in the same directory as the script.
Sorry about that, I just added the link to the RSS feed. Let me know if you have any problems.