This documentation is for v2.1.9+ (Current stable version)
The Documentation is split by files to make it easier to locate different functions.
The html is located in the public folder.index.html
This page contains the code to load the minified version of GlycoGlyph. The <head> contains the code for all libraries which need to be imported and the styles.
The entire GlycoGlyph GUI is located in the <div> with the id="glycoglyphdiv" including the scripts for GlycoGlyph located at the bottom of the <div>.
index-min.html
This page contains the code to load the individual components required for GlycoGlyph from the scripts\lib\*.js. The purpose of this page is for anyone who wants to customize the code for their own use. They can modify each component and use this page to see the changes. The <head> contains the code for all libraries which need to be imported and the styles. The entire GlycoGlyph GUI is located in the <div> with the id="glycoglyphdiv" including the scripts for GlycoGlyph located at the bottom of the <div>.
All images to be used by GlycoGlyph are located in the assets\images folder.
GlycoGlyph uses the following icons for different parts of the application:
-
images\camera.svg
-
images\cog.svg
-
images\copy.svg
-
images\eraser-solid.svg
-
images\exchange-alt-solid.svg
-
images\new.svg
-
images\plus-solid.svg
-
images\redo.svg
-
images\undo.svg
-
images\undo.svg
In addition icons for various databases such as GlyGen and GlyTouCan can be found in the images\icons folder.
images\monos.svg
In this file, each monosaccharide is defined as a <symbol> and the id for each uses the abbreviation to make it easy to identify and find. The symbol also defines the data-abbr attribute and the data-shortname attribute which is used to list the monosaccharides using the glycoglyph.listmonos() method.
The CSS used by GlycoGlyph is located in the public\css folder.glycoglyph.css
Holds all the stylesheets needed for GlycoGlyph interface to display properly.---
public\js\glycoglyph.min.js
Minified full compilation of all files in the _src\modules_ folder. The documents from the _src\modules_ folder are manually combined using command line and minified using Closure Compiler. There is probably a better way to do this but this is what I was doing.
public\js\glycoglyph.js
Compiled un-minified version of glycoglyph.min.js
public\js\initialize.js
Contains all scripts required to render the interface as well as add event listeners to different GUI elements.
public\js\introtut.js
Contains the code for the tutorials.
-
tutorialsteps: Array. Constant that holds all the steps for the tutorial. -
startTutorial(): Function. Starts the tutorial and controls each step. -
endTutorial(): Function. Stops the tutorial.
The src directory contains all source code files which are only required for development. The files in the modules directory of the src folder is compiled into one using Rollup.js. To see a sample of how this is done you can check RollupES6Template.
The following files contain all the modules for development
src\modules\globalvars.js
Contains global variables for settings etc.
-
domElements: Object. Contains the id of the elements used by GlycoGlyph for e.g. thenameInputIDis where the CFG name will be typed. -
filePaths: Object. Contains the paths to themonos.svgfile and the CSS file. Can be set using the functions in setfilepaths.js. -
childglycan: Object. Contains the information for the prepared structure to be added. The childglycan holds achildobject with all the information about the child. -
drawingSettings: Object. Contains parameters to control the default drawing settings for GlycoGlyph and is used by glycoglyph.d3glycanstructure function and is described in the documentation for that file. -
dynamicDrawingSettings: Object. Contains settings which change based on user drawing situation. e.g.multimodetoggle. -
templates: Array. Holds the information for the starter templates for N-Glycans and O-Glycans. -
terminals: Array. Holds the information for all terminals to be used as templates. -
monos: Array. Holds a list of monosaccharides used by glycoglyph.glycantojson. -
aminoacids: Array. Holds a list of amino acid letter codes. Not currently used in code. -
gctMonoList: Object. Holds dictionaries for various monosaccharides to help produce the GlycoCT in glycoct.js. Adapted from SugarSketcher by Author: Davide Alocci and Renaud Costa. -
gctSubList: Object. Holds dictionaries for substituents to help produce the GlycoCT in glycoct.js. Adapted from SugarSketcher by Author: Davide Alocci. -
commonMonos: Array. Contains an array of commonly used monosaccharides. -
commonMonosExtended: Array. Extended list of common monosaccharides including generic types like Hex and HexNAc. Used by the linkage warning system to determine which monosaccharides should have auto child linkages applied. -
monos_with_2linkage: Array. Contains monosaccharides that typically link via position 2, specifically sialic acids: ["Neu5Ac", "Neu5Gc", "KDN", "Neu", "Sia"]. -
linkageSettings: Object. Contains user preferences for linkage behavior. Properties includeapplyAutoChildLinkages(boolean, defaulttrue) which controls whether smart default child linkages are applied automatically, andwarningDismissed(boolean, defaultfalse) which tracks if the user has dismissed the linkage warning for the current session. -
svgStyle: String. Contains entire glycoglyph.css as text. -
fetchCSS: Promise state. Usesd3.textto retrieve the entire glycoglyph.css file as a text to be parsed for glycoglyph.savesvg functions. -
svgarr: Array. Contains data for all the monosaccharide symbols from the monos.svg which is fetched usingfetchSVGbelow. The data can be used by the glycoglyph.savesvg functions. -
fetchSVG: Promise state. Usesd3.xmlto fetch information for the symbols from monos.svg such as the id, the paths and innerhtml and the fullname of the monosaccharide. The promise state can then be used to trigger drawing of the buttons for the GUI in glycoglyph.listMonosaccharides function.
src\modules\addinfo.js
Contains functions for steps to add info to prepare a structure.
-
resetchildglycan(): Function. Resets thechildglycanglobal variable and clears the GUI. -
addSub(): Function. Gets the substituent information selected in the GUI and adds it to the preparedchildglycan. -
clearSub(): Function. Clears the substituent information for the preparedchildglycan -
monoselect(mono): Function. Accepts argument ofmonoas string. Gets the monosaccharide selected and adds it to the preparedchildglycan. -
addLinkage(): Function. Gets the linkage information selected in the GUI and adds it to the preparedchildglycan. -
makechildglycanname(): Function. Appends the value for thenamefield for thechildglycanby combining thesubstituent,monosaccharide,linkage.
src\modules\addmono.js
Contains functions to add monosaccharide to the glycan object and output new name.
-
addmono(path, multiple): Function. Accepts argumentspathas array of paths to the node generated byd3.hierarchyusingnodes.path(d)method on click, andmultipleas a boolean if multimode is on. Function recursively traverses the glycan object comparing thepathand pushes the child glycan at the appropriate level. The linkage applied depends on thelinkageSettings.applyAutoChildLinkagessetting: if enabled (default), applies?1-?for most monosaccharides or?2-?for sialic acids from themonos_with_2linkagearray; if disabled, applies conservative??-?linkage. After this it calls theoutputname(nameobj)and passes the updated glycan object. -
outputname(nameobj): Function. Acceptsnameobjas an object. Converts the glycan objectnameobjusingd3.hierarchy, sorts the children by link number usingsortchildren(struc)produces the name usingobjecttoname(structure). -
addfirstmono(): Function. Special case, while adding the first monosaccharide, since there is no path a special function is called.
src\modules\autocheck.js
Contains functions to check if name of glycan is correct. This is useful especially for typed names.
autoCheckName(originalName): Function. Accepts argumentsoriginalNameas a string of the name in CFG linear nomenclature format. The function checks for wrong branch orders, replaces any long or short dashes (em-dash / en-dash) with regular hyphens (-), remove any trailing linkage information and replaces any mistakes in capitalization of A in acetyls for HexNAc (e.g. GlcNac). Returns an object withoriginalName,correctedName,error. Theerrorboolean specifies if there was any error found (trueif found).
src\modules\calcmassparams.js
Contains functions to calculate the mass parameters of a glycan
outputParams(): Function. Retrieves the name from the DOM. Checks if name is present. If it is present calls thecalcMassParams()function with the name.calcMassParams(name): Function. Accepts the name as an argument. uses theglycantojson()function andd3.hierarchyto produce the list of monosaccharides and calculates the monoisotopic mass, along with the monosaccharide count. If any monosaccharides or substituents are not identified, they are counted separately. Function returns an object with the information.
src\modules\d3glycanstructure.js
Contains functions to draw the glycan in selected div.
-
d3glycanstructure(glycanname, options): Function. Acceptsglycannameas a string with the CFG name andoptionsas an object in which you can specify a number of parameters for drawing including. By defaultdrawingSettingsglobal variable is used.-
width: width of the drawing area. Number. -
height: height of the drawing area. Number. -
editingMode: whether editing mode is turned on (true) or off (false). -
orientation: drawing orientation of the glycan. String asbottom-to-toporright-to-left -
drawdivID: ID of the div in which the glycan is to be drawn. String without the # for the ID. -
symbsize: size of the SNFG symbols. Number. -
drawingareachoice: whether to draw to fit the box or adjust box size as per glycan. String asfixglycansizeorfixdrawingarea -
fucopt: option to choose how the fucose is oriented. String asfucout,fucleft,fucdownorfucoriginal -
linkageVisible: option to toggle whether linkage is visible. Boolean. -
linkRotate: option to toggle whether linkage is rotated along the bond. Boolean. -
linkAbbr: option to toggle whether linkage text should be abbreviated. Boolean. -
linkFontSize: option to set the font size of the linkage text. Number -
margin: option to set the margins of the drawing area. Object with keystop,right,bottom,left. -
drawingSettingsDivID: the Div ID where the form for the drawing settings exists. The id of the input elements within such a div must match the options above so as to override the defaults. String without the # for the ID. -
userOverrideOptions: option to let user override the default options using the GUI form with settings in thedrawSettingsDivID
-
The defaults for these can be found as the glycoglyph.drawingSettings or in the globalvars.js file. This function utilizes D3.js extensively along with the other functions below to draw the glycan depending upon some of the settings selected by the user. Hence it uses some information obtained by form fields in the GUI.
-
getUserDrawingOptions(options): Function to get all the user options from the GUI and override the configuration options which are passed in as theoptions. -
getDepth(obj): Function. Acceptsobjas object. This is to get the total depth of the glycan tree. This is used to calculate the node separation and dimensions. -
fixfucers(node,width): Function. Acceptsnodeas object with the glycan object andwidthas a number for the width of the glycan drawing. This function is used to convert the fucose to right angles or depending upon what type of fucose drawing option is selected in the GUI. -
transformlinkText(d, i, options): Function. Acceptsdas the data object for the glycan,ifor the index of the node, and the configuration asoptionsfor thelinkRotateas boolean for if rotation of link is required,linkAbbras boolean if linkage is abbreviated,symbsizeas a number for the size of the symbols. This function rotates the link text according to user option selection. -
rotateFuc(d,o, options): Function. Acceptsdas object for monosaccharide andoas object for orientation and theconfigurationasoptionsfor thefucopt. This function rotates the fucose symbol so that the apex of the triangle connects to the link.
src\modules\deletemono.js
Contains function to delete monosaccharide
deletemono(path): Function. Acceptspathas array of paths to the node generated byd3.hierarchyusingnodes.path(d)method on click. This function recursively traverses to the selected node in the glycan tree comparing thepathand deletes the children.
src\modules\getGTCID.js
Contains function to get the GlyTouCan ID from api.glycosmos.org
-
generateGTCIDTable(): Function. UsesgetGTCIDanddrawGTCIDTable(below) to get and draw the glytoucan ID table. -
getGTCID(name, glygen = false): Function. Fetches the GlyTouCan ID from api.glycosmos.org by using theglycoct2wurcsapi. Can fetch corresponding data from GlyGen however by default this is set to false and needs to be explicitly mentioned if the user wishes to fetch this. -
drawGTCIDTable(glytoucanData): Function. Produced the Glytoucan ID table. Accepts the output of thegetGTCIDmethod asglytoucanData.
src\modules\glycantoJSON.js
Contains function to take a CFG name and convert it to a glycan tree JSON data structure.
glycantojson(glycanname): Function. Acceptsglycannameas a string for the CFG name. The function uses aparseTree()function to produce a javascript object which is stringified and returned as JSON.
src\modules\glycamnotation.js
Contains functions to generate Glycam Notation from the CFG name.
-
sequenceToGlycam(sequence, {suffix = '-OH', linkerToReplace = ''} = {}): Function. Acceptssequenceas a string for the CFG name. Also accepts options as an object forsuffixandlinkerToReplace. The function replaces the linker optionally and then proceeds to generate the glycan object which can be passed intoobjectToGlycamfunction which returns the glycam name and any errors as an object. The function then adds the suffix to the glycam name, and returns the glycam object. -
objectToGlycam(obj, bindex): Function. Accepts the glycan tree object asobj. It recursively goes through the glycan object to generate a name. It returns an object withnamekey. If it has any issues producing the name, the function adds it toerrorskey as an array in the returned object.
src\modules\glycoct.js
Contains functions to produce the GlycoCT from a CFG name.
-
cfgToGlycoCT(): Function. Gets the name from the CFG name input field. Callsglycantojson()to convert the name. CallsjsonToGlycoCT()to produce the GlycoCT. Outputs the GlycoCT to the GUI. -
jsonToGlycoCT(json): Function. Acceptsjsonas JSON for the glycan tree produced byglycantojson(). Converts the glycan tree JSON to GlycoCT.
src\modules\linkagewarning.js
Contains functions to manage the linkage warning system and smart default linkages.
-
checkAndDisplayLinkageWarning(name): Function. Acceptsnameas a string for the CFG name. Checks if the structure contains any??-?linkages and displays a warning message if found (unless user has dismissed it). The warning educates users about auto child linkage positions and provides options to apply them. -
dismissLinkageWarning(): Function. Dismisses the linkage warning until the page is refreshed. SetslinkageSettings.warningDismissedtotrueand hides the warning div. -
fixUnknownLinkages(): Function. Applies auto child linkage positions to all??-?linkages in the current structure. Replaces??-?with?1-?for most monosaccharides and?2-?for sialic acids (Neu5Ac, Neu5Gc, KDN, Neu, Sia). Also enables the "Auto Child Linkages" toggle switch and updates the global setting. UsesfixLinkagesRecursive()helper function to traverse the glycan tree. -
fixLinkagesRecursive(node): Function. Acceptsnodeas an object for the current node in the glycan structure. Recursively traverses the glycan tree and fixes??-?linkages based on monosaccharide type. For uncommon monosaccharides not in thecommonMonosExtendedlist, the linkage remains as??-?(conservative approach).
src\modules\listmonos.js
Contains functions to list monosaccharides for the GUI.
-
listMonosaccharides: Function. Load the symbols for all monosaccharides in the GUI. Once all the monosaccharide symbols are fetched usingfetchSVGglobal, and thesvgarris populated, it starts appending the monosaccharide buttons. It appends buttons for each monosaccharide in either the common monosaccharides region (commonmonolist) if they are in thecommonMonosglobal array, or it appends all the symbols as buttons in the full list. -
appendbutton(mono, divid): Function. Acceptsmonoas a string for monosaccharide type anddividas a string for the<div>idwhere you would like to append the button.
src\modules\listterminals.js
Contains functions to append list of terminals in GUI and to add terminal templates to the prepared structure childglycan object.
-
appendTerminals(): Function. Appends list of buttons for the terminal templates. -
addTerminaltoChild(i): Function. Acceptsias a number for index. Retrieves the sequence from theterminalsglobal array using the indexi, converts to JSON and parses it and then adds it to thechildglycan. Gives GUI output of the terminal sequence added.
src\modules\objecttoname.js
Contains functions to convert a glycan tree object to a glycan name in CFG format.
objecttoname(obj,bindex,depth): Function. Acceptsobjas object for the glycan tree object,bindexas number for the index of the child node. This function, takes the glycan tree object, and recursively generates the CFG name from it, applying appropriate branches. It is advisable to callsortchildren()on the glycan tree before this function to get the correct name output with appropriately ordered child nodes.
src\modules\replacemono.js:
Contains functions for replacing a structure component such as monosaccharide, or linkage.
replacemono(path, multiple): Function. Accepts argumentspathas array of paths to the node generated byd3.hierarchyusingnodes.path(d)method on click, andmultipleas a boolean if multimode is on. Function recursively traverses the glycan object comparing thepathand modifies the glycan at appropriate level. After this it calls theoutputname(nameobj)and passes the updated glycan object.
src\modules\savesvg.js
Contains functions to save the svg.
savesvg(svgid): Function. Accepts argumentssvgidwhich is the ID for the SVG to be saved. This function callsreplacecss()andreplaceuse()in thesvgidand then creates a newBlobfor the SVG to be saved. At the end it redraws the glycan so that the user may still interact with it.
src\modules\setfilepaths.js
Contains async functions to set the file paths for the SVG and CSS files.
-
setMonosSVGPath(newPath, pathType): Function. AcceptsnewPathas string to set the new path. ThepathTypeis a string and can be set toabsolute(default) orrelativedepending on the path you would like to pass into the project. -
setCSSPath(newPath, pathType): Function. AcceptsnewPathas string to set the new path. ThepathTypeis a string and can be set toabsolute(default) orrelativedepending on the path you would like to pass into the project. -
setImagesPath(newPath, pathType): Function. AcceptsnewPathas string to set the new path. ThepathTypeis a string and can be set toabsolute(default) orrelativedepending on the path you would like to pass into the project.
src\modules\sortchildren.js
Contains functions to sort the children based on the link number
sortchildren(obj): Function. Acceptsobjas an object for the glycan tree object. This function recursively traverses the glycan tree and sorts the children in the proper order of linkage. It returns the correctly sorted object.
src\modules\startertemplates.js
Contains functions to display the start templates.
starttemplate(name): Function. Acceptsnameas a string for the sequence of the starter template. This function is called if the user uses the starter templates for N- and O- Glycans. It appends the appropriate starter template sequence to the name input element to produce the structure.
src\modules\tracknames.js
Contains functions to track CFG names and enables undo and redo.
-
tracknames(name): Function. Accepts arguments ofnameas a string which is the name to be tracked. This function pushes the name to thetracknameglobal array, and increments thetracknumto keep a count of the tracking number. -
undo(): Function. This function allows users to undo changes to the structure by moving appropriately backwards in thetracknameglobal array using thetracknumto keep track of where to go in the index. -
redo(): Function. This function allows users to redo changes to the structure by moving appropriately forwards in thetracknameglobal array using thetracknumto keep track of where to go in the index.