In a previous post we showed how you can use BioGroovy to download a data file from a webservice. In this post, we’ll show you how to parse the file that you’ve downloaded.
After handling all of the imports (shown in the first block of code), the real work starts with the EntrezGeneSlurper. We create a file reference to the datafile we downloaded earlier, and then call the fetcher.read() method to read the datafile and print the results out to the console.
Grab (group='org.biogroovy', module='biogroovy', version='1.1')
import org.biogroovy.io.eutils.EntrezGeneSlurper
import org.biogroovy.models.Gene
import java.io.File
import java.io.FileInputStream
EntrezGeneSlurper fetcher = new EntrezGeneSlurper();
File file = new File("/path/to/file.gene.xml");
Gene gene = fetcher.read(new FileInputStream(file));
println gene;
