[Biojava-l] Retrieve Information from GenBank file
jc.lucky
jc.lucky at laposte.net
Fri Oct 22 08:11:43 UTC 2010
Hi
I'm trying to convert a GenBank file into a rdf file. The gene of interest can be found a t : http://www.ncbi.nlm.nih.gov/protein/284794945
With the below code I can read the GenBank file and I manage to retrieve information and convert them in a rdf format. However I don't succeed in retrieving some information such as Title, protein or product. According to this page (http://www.biojava.org/wiki/BioJava:BioJavaXDocs#GenBan)it is possible to do so.
Please help me find what I do wrong or what should be done to achieve my goal.
//read the GeneBank File
public static RichSequenceIterator readFile(String input,
RichSequenceBuilderFactory seqFactory,
Namespace ns)
throws IOException, NoSuchElementException, BioException
{
ns = null;
InputStream stream = new FileInputStream(input);
BufferedReader rdfFile = new BufferedReader(new InputStreamReader(stream));
RichSequenceIterator seqs = RichSequence.IOTools.readGenbankDNA(rdfFile,ns);
return seqs;
}
//Retrieve information and convert them in rdf format
public void writeToRDFFile(RichSequenceIterator rsi, String output)
throws IOException, NoSuchElementException, BioException {
//create model for the ontology
OntModel model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, null);
OntClass parents;
String URI = "http://pbr.wur.nl/#";
while(rsi.hasNext())
{
RichSequence seq = rsi.nextRichSequence();
String id = seq.getName();
parents = model.createClass(URI + id);
Set author = seq.getRankedDocRefs();//code to clean up Set&convert toString
String definition = seq.getDescription(); //code to clean up String
//Add to model
parents.addProperty(DC.description, definition);
parents.addProperty(DC.publisher, authors);
parents.addComment(taxonomy, "EN");
parents.addProperty(DC.type, organism);
//print in rdf format
model.write(out, "RDF/XML");
out.close(); }
}
Thanks,
Jean-Charles Ferrières
Une messagerie gratuite, garantie à vie et des services en plus, ça vous tente ?
Je crée ma boîte mail www.laposte.net
More information about the Biojava-l
mailing list