Monday, June 13, 2011

Grabbing NeXML data: Part II

In this blog I will show how metadata can be extracted from an OTU element.


<otu id="otu9" label="Alligator_mississippiensis">
<meta content="835" datatype="xsd:long" id="meta82796" property="tb:identifier.taxon" xsi:type="nex:LiteralMeta"/>
<meta content="2038" datatype="xsd:long" id="meta82795" property="tb:identifier.taxonVariant" xsi:type="nex:LiteralMeta"/>
<meta content="Alligator mississippiensis" datatype="xsd:string" id="meta82794" property="skos:prefLabel" xsi:type="nex:LiteralMeta"/>
<meta href="http://purl.uniprot.org/taxonomy/8496" id="meta82793" rel="skos:closeMatch" xsi:type="nex:ResourceMeta"/>
<meta content="Alligator mississipiensis" datatype="xsd:string" id="meta82792" property="skos:altLabel" xsi:type="nex:LiteralMeta"/>
<meta href="http://www.ubio.org/authority/metadata.php?lsid=urn:lsid:ubio.org:namebank:2813218" id="meta82791" rel="skos:closeMatch" xsi:type="nex:ResourceMeta"/>
<meta href="http://purl.org/phylo/treebase/phylows/study/TB2:S2108" id="meta82790" rel="rdfs:isDefinedBy" xsi:type="nex:ResourceMeta"/>
</otu>

The above otu is attached to some node.
You can get the OTU attached to a node as

OTU otu= node.getOTU();

Then you can extract the set of annotations as follows.

Set<Annotation> s1= otu.getAnnotations("skos:closeMatch");
Set<Object> s2=otu.getAnnotationValues("tb:identifier.taxon");

The values are easy to extract after this. Since there are no NeXML files with geographic coordinates attached to nodes, and manually making changes in an NeXML files is a cumbersome process I am thinking of creating a utility which takes an NeXML file as input and a csv file which stores the lat/long and other metadata and the program should be able to attach the latitude/longitude metadata to the NeXML file. I still have to consult this with my mentor !!!

No comments:

Post a Comment