= GRITS Glycan Database Handling = GRITS supports pre-defined databases of Glycan structures stored in XML format. This document describes the basic structure and how to read and load the structures for processing within GRITS[[BR]] [[BR]] == Glycan XML Basics == GRITS Objects (plugin org.grits.toolbox.ms.annotation): 1) org.grits.toolbox.ms.annotation.structure.Database.java ("database")[[BR]] Contains: a) ** List of GlycanStructures (tag = "glycan") ** [[BR]] b) ** name **[[BR]] c) description, structureCount[[BR]] 2) org.grits.toolbox.ms.annotation.structure.GlycanStructure.java[[BR]] Contains: a) ** id **[[BR]] b) Sequence & Sequence Format[[BR]] c) Sequence in Glycoworkbench (GWB) Format[[BR]] ** To create Glycan cartoons, you will need the GWB format. You can set this directly, or you can convert a sequence of other type to GWB sequence if you provide the "Sequence Format"**[[BR]] [[Image(GRITS_db.jpg)]][[BR]] == Reading Glycan DB XML == 1) Create instance of org.grits.toolbox.ms.om.data.GlycanFilter.java {{{ GlycanFilter filter = new GlycanFilter(); filter.setDatabase( ); }}} 2) Create a class that implements IStructureHandler (or use class org.grits.toolbox.ms.annotation.structure.StructureHandlerJarFile) a) Populate a List of GlycanStructure objects using the GlycanFilter (specifies the path to the database) {{{ public List getStructures(GlycanFilter a_filter) throws StructureHandlerException { try { JAXBContext jaxbContext = JAXBContext.newInstance(GlycanDatabase.class); GlycanDatabase db = new GlycanDatabase(); InputStream input = new FileInputStream(a_filter.getDatabase()); if (input != null) { jaxbContext = JAXBContext.newInstance(GlycanDatabase.class); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); db = (GlycanDatabase) jaxbUnmarshaller.unmarshal(input); return db.getStructures(); } return null; } catch (Exception e) { e.printStackTrace(); return null; } } }}} == Populating Glycan Cache for GRITS Processing == Depending on the expected use for the GlycanStructure objects, it may make sense to make org.eurocarbdb.application.glycanbuilder.Glycan objects in order to perform GWB fragmentation, create Glycan cartoons, and perform other calculations. Gelato uses a built-in cache of org.grits.toolbox.ms.annotation.structure.GelatoGlycan objects to store both the GlycanStructure and the Glycan for each unique structure id.[[BR]][[BR]] The following code shows a method for populating the Gelato cache, using utility classes to convert between different sequence format types as necessary: {{{ public void populateGlycanObjects() { for (GlycanStructure structure : lStructures) { Glycan glycan = null; GelatoGlycan gelatoGlycan = null; Sugar t_sugar = null; if( GlycanStructureAnnotation.hmGelatoGlycansByStructureId.containsKey(structure.getId()) ) { continue; } else { gelatoGlycan = new GelatoGlycan(); } if( structure.getGWBSequence() != null && ! structure.getGWBSequence().equals("")) { glycan = Glycan.fromString(structure.getGWBSequence()); if( structure.getSequenceFormat() == null || ! structure.getSequenceFormat().equals(GlycanAnnotation.SEQ_FORMAT_GLYCOCT_CONDENSED) ) { structure.setSequence( glycan.toGlycoCTCondensed() ); } } else if( structure.getSequence() != null && ! structure.getSequence().equals("") ){ if( structure.getSequenceFormat() == null || structure.getSequenceFormat().equals(GlycanAnnotation.SEQ_FORMAT_GLYDEII) ) { t_sugar = GlycanExtraInfo.glydeToSugar(structure.getSequence()); String t_glycoCT = GlycanExtraInfo.sugarToGlycoCT(t_sugar); glycan = Glycan.fromGlycoCTCondensed(t_glycoCT); structure.setSequence(glycan.toGlycoCTCondensed()); } else if( structure.getSequenceFormat().equals(GlycanAnnotation.SEQ_FORMAT_GLYCOCT_CONDENSED) ) { glycan = Glycan.fromGlycoCTCondensed(structure.getSequence() ); } else if( structure.getSequenceFormat().equals(GlycanAnnotation.SEQ_FORMAT_GLYCOCT_XML) ) { glycan = Glycan.fromGlycoCT(structure.getSequence() ); structure.setSequence(glycan.toGlycoCTCondensed()); } else { throw new Exception("Unsupported sequence type (" + structure.getSequenceFormat() + ") for structure: " + structure.getId()); } } else { throw new Exception("Sequence not specfied for structure: " + structure.getId()); } structure.setSequenceFormat(GlycanAnnotation.SEQ_FORMAT_GLYCOCT_CONDENSED); if( glycan != null && structure.getGWBSequence() == null ) { structure.setGWBSequence( glycan.toString() ); } gelatoGlycan.setGlycan(glycan); gelatoGlycan.setGlycanStructure(structure); GlycanStructureAnnotation.hmGelatoGlycansByStructureId.put(structure.getId(), gelatoGlycan); } } }}}