### Start Document (Java) Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/CgviewFactory.html Implements the startDocument method from the ContentHandler interface. This method is called by the SAX parser at the beginning of an XML document. ```Java public void startDocument() { // Implementation details omitted for brevity } ``` -------------------------------- ### Sort Features by Start - Java Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/FeatureSlot.html Sorts the features within this FeatureSlot based on their starting base position. The sorting order (ascending or descending) depends on whether the slot is for the direct or reverse strand, improving visual clarity when using arrows. ```Java public void sortFeaturesByStart() Sorts the features in this FeatureSlot by start base. If this is a DIRECT_STRAND slot the features are sorted in ascending order. If this is a REVERSE_STRAND slot the features are sorted in descending order. This sorting produces a more visually pleasing feature appearance when arrows are used. ``` -------------------------------- ### POST /FeatureSlot/SortFeaturesByStart/compare Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/FeatureSlot.SortFeaturesByStart.html Compares two feature objects based on their start positions to facilitate sorting. ```APIDOC ## POST /FeatureSlot/SortFeaturesByStart/compare ### Description Compares two objects (features) to determine their relative order based on start position. This method implements the Comparator interface. ### Method POST ### Endpoint /ca.ualberta.stothard.cgview/FeatureSlot.SortFeaturesByStart/compare ### Parameters #### Request Body - **o1** (Object) - Required - The first feature object to compare. - **o2** (Object) - Required - The second feature object to compare. ### Request Example { "o1": { "start": 100 }, "o2": { "start": 200 } } ### Response #### Success Response (200) - **result** (int) - A negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second. #### Response Example { "result": -1 } ``` -------------------------------- ### SortFeaturesByStart Class Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/FeatureSlot.SortFeaturesByStart.html The SortFeaturesByStart class implements the Comparator interface to facilitate the sorting of feature objects based on their start coordinates. ```APIDOC ## POST /SortFeaturesByStart/compare ### Description Compares two feature objects to determine their relative order based on start position. ### Method POST ### Endpoint /SortFeaturesByStart/compare ### Parameters #### Request Body - **o1** (Object) - Required - The first feature object to compare. - **o2** (Object) - Required - The second feature object to compare. ### Request Example { "o1": { "start": 100 }, "o2": { "start": 200 } } ### Response #### Success Response (200) - **result** (int) - Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second. #### Response Example { "result": -1 } ``` ```APIDOC ## POST /SortFeaturesByStart/equals ### Description Determines if the current comparator instance is equal to another object. ### Method POST ### Endpoint /SortFeaturesByStart/equals ### Parameters #### Request Body - **obj** (Object) - Required - The object to compare for equality. ### Request Example { "obj": "ComparatorInstance" } ### Response #### Success Response (200) - **result** (boolean) - Returns true if the objects are equal, false otherwise. #### Response Example { "result": true } ``` -------------------------------- ### Get Bases Per Minimum Feature - Java Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/FeatureSlot.html Calculates and returns the minimum number of bases that can be accurately drawn as a feature at a given zoom level. Features smaller than this are enlarged for visibility, guiding window size selection for calculations. ```Java public double getBasesPerMinFeature(double zoom) Returns the minimum feature length in bases that can be drawn accurately in this FeatureSlot, at the given zoom value. Feature lengths smaller than this length are automatically drawn larger so that they are visible. This method should be used when deciding on the appropriate window size (length of bases) to use when calculating a value to present on the map. For example, if you plan to display percent GC content on the map, and this method returns `98.0003`, you should choose a window size of 99 or greater when calculating percent GC. In other words, you would create a Feature object containing a FeatureRange object spanning bases 1 to 99, a second FeatureRange spanning bases 100 to 199, and so on. Each FeatureRange would be decorated in some way to convey the %GC value calculated for the segment of bases it contains (using [`FeatureRange.setProportionOfThickness(float)`](FeatureRange.html#setProportionOfThickness(float)) for example). Parameters: `zoom` - the zoom value to be used when drawing the Cgview map. ``` -------------------------------- ### Implement SAX Document Lifecycle Methods Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/CgviewFactory.html Methods to handle the start and end of an XML document parsing process. These methods are typically used to initialize or finalize resources during SAX parsing. ```java public void startDocument() {} public void endDocument() {} ``` -------------------------------- ### Label Constructor Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/Label.html Constructs a new Label object with specified parameters for cgview, text, hyperlink, mouseover text, font, color, label forcing, line start radians, and strand. ```java protected Label(ca.ualberta.stothard.cgview.Cgview cgview, String labelText, String hyperlink, String mouseover, Font font, Color color, boolean forceLabel, double lineStartRadians, int strand) ``` -------------------------------- ### Define image series zoom values Source: https://github.com/paulstothard/cgview/blob/master/docs/application.html Specifies a comma-separated list of zoom levels for linked map series generation, starting with 1. ```bash java -jar cgview.jar -i input.xml -f png -s linked_series -x 1,6,36,216 ``` -------------------------------- ### Implement SAX Element Parsing Methods Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/CgviewFactory.html Methods to handle the start and end of XML elements, including attribute processing. These methods are triggered by the SAX parser when encountering tags. ```java public void startElement(String uri, String name, String qName, Attributes atts) throws SAXException {} public void endElement(String uri, String name, String qName) throws SAXException {} ``` -------------------------------- ### SortFeatureRangesByStart Constructor Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/Feature.SortFeatureRangesByStart.html Initializes a new instance of the SortFeatureRangesByStart class. This class is used for sorting feature ranges by their start positions. ```APIDOC ## SortFeatureRangesByStart Constructor ### Description Initializes a new instance of the SortFeatureRangesByStart class. ### Method `public SortFeatureRangesByStart()` ### Endpoint N/A (Constructor) ### Parameters None ### Request Example ```json {} ``` ### Response N/A (Constructor) ``` -------------------------------- ### Get Start Position of FeatureRange in Java Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/FeatureRange.html Returns the position of the first base in this FeatureRange. This method is used to retrieve the starting coordinate of the feature range. ```Java public int getStart() ``` -------------------------------- ### Constructor: CgviewFactoryPtt() Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/CgviewFactoryPtt.html Initializes a new instance of the CgviewFactoryPtt class. ```APIDOC ## Constructor: CgviewFactoryPtt() ### Description Constructs a new CgviewFactoryPtt object used to parse tab-delimited feature files. ### Method Constructor ### Parameters None ### Request Example ```java CgviewFactoryPtt factory = new CgviewFactoryPtt(); ``` ### Response - **Object** (CgviewFactoryPtt) - A new instance of the factory class. ``` -------------------------------- ### Get Feature Start Position - Java Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/Feature.html Determines the smallest start value among all feature ranges associated with this feature. If no feature ranges are present, it returns -1. ```Java protected int getStart() Returns the smallest start value from the featureRanges in this Feature, or -1 if there are no featureRanges. Returns: the smallest featureRange start in this featureRange or -1. ``` -------------------------------- ### Main Method (Java) Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/CgviewIO.html The main entry point for the Java application. This method typically handles command-line arguments and initiates the program's execution flow. ```java public static void main(String[] args) ``` -------------------------------- ### Get Sequence Origin in CGView Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/Cgview.html Retrieves the current origin setting for the sequence in degrees. This indicates how many degrees the sequence start is offset counterclockwise from the three o'clock position. ```java public double getOrigin() ``` -------------------------------- ### POST /cgview/createFromFile Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/CgviewFactory.html Generates a Cgview object by reading and parsing an XML file from the local filesystem. ```APIDOC ## POST /cgview/createFromFile ### Description Generates a Cgview object from an XML file. ### Method POST ### Endpoint /cgview/createFromFile ### Parameters #### Request Body - **filename** (String) - Required - The path to the XML file to read. ### Request Example { "filename": "/path/to/data.xml" } ### Response #### Success Response (200) - **cgview** (Object) - The newly created Cgview object. #### Response Example { "status": "success", "data": { "id": "cgview_001", "type": "circular" } } ``` -------------------------------- ### POST /addTableStart Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/CgviewHTMLDocument.html Adds table and tbody opening tags to the document. ```APIDOC ## POST /addTableStart ### Description Adds table and tbody opening tags to the document with specified dimensions. ### Method POST ### Parameters #### Request Body - **width** (int) - Required - The width of the table in pixels. - **border** (int) - Optional - The width of the border in pixels. ### Request Example { "width": 800, "border": 1 } ``` -------------------------------- ### Get Zoom Range Boundaries (Java) Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/Cgview.html Retrieves the start and stop base numbers for the first and second zoom ranges. These ranges define the visible base positions when a zoomed map is rendered. The methods return integer values representing the base indices. ```Java protected int getZoomRangeOneStop() { // Returns the number of the last base inside the first zoom range. // When drawing a zoomed map, two ranges are calculated. These ranges contain all the base positions that should be drawn. return 0; // Placeholder implementation } protected int getZoomRangeTwoStart() { // Returns the number of the first base inside the second zoom range. // When drawing a zoomed map, two ranges are calculated. These ranges contain all the base positions that should be drawn. return 0; // Placeholder implementation } protected int getZoomRangeTwoStop() { // Returns the number of the last base inside the second zoom range. // When drawing a zoomed map, two ranges are calculated. These ranges contain all the base positions that should be drawn. return 0; // Placeholder implementation } ``` -------------------------------- ### Label Constructor with Cgview Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/class-use/Cgview.html Constructs a new Label object. Similar to InnerLabel, this constructor requires a Cgview object and parameters for label text, hyperlink, mouseover text, font, color, a boolean to force the label, line start radians, and strand. ```java new Label(cgview, labelText, hyperlink, mouseover, font, color, forceLabel, lineStartRadians, strand); ``` -------------------------------- ### Application Entry Point Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/Plasmid.html The standard main method used as the entry point for the CGView application execution. ```java public static void main(String[] ars); ``` -------------------------------- ### FeatureRange Constructor in Java Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/FeatureRange.html Constructs a new FeatureRange object. It takes a Feature object, a start position, and a stop position. The start and stop positions refer to the direct strand. If start is greater than stop, the feature is assumed to extend from start, across the end of the sequence, to stop. If start equals stop, the FeatureRange refers to a single base. ```Java public FeatureRange(Feature feature, int start, int stop) ``` -------------------------------- ### InnerLabel Constructor with Cgview Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/class-use/Cgview.html Constructs a new InnerLabel object. This constructor takes a Cgview object and several parameters for label text, hyperlink, mouseover text, font, color, a boolean to force the label, line start radians, and strand. ```java new InnerLabel(cgview, labelText, hyperlink, mouseover, font, color, forceLabel, lineStartRadians, strand); ``` -------------------------------- ### Construct Feature objects Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/Feature.html Demonstrates the various ways to instantiate a Feature object, either by initializing with a FeatureSlot, setting shading preferences, or using the default constructor. ```java Feature f1 = new Feature(featureSlot); Feature f2 = new Feature(); Feature f3 = new Feature(true); ``` -------------------------------- ### Get Label Text in Java Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/Label.html Retrieves the text content of a Label object. This method is used to get the string displayed by the label. It returns a String representing the label's text. ```java protected String getLabelText() Returns the text of this Label. Returns: the text of this Label. ``` -------------------------------- ### Main Entry Point (Java) Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/Plasmid.html The main method for the CGView application. It serves as the entry point for program execution and typically handles command-line arguments or initialization logic. ```java static void main(String[] ars) ``` -------------------------------- ### POST /Label/create Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/index-all.html Constructs a new Label object for facilitating label layout and drawing on a Cgview map. ```APIDOC ## POST /Label/create ### Description Constructs a new Label object used by Cgview objects to facilitate label layout and drawing. ### Method POST ### Endpoint ca.ualberta.stothard.cgview.Label ### Parameters #### Request Body - **cgview** (Cgview) - Required - The parent Cgview object. - **text** (String) - Required - The label text. - **font** (Font) - Required - The font for the label. - **color** (Color) - Required - The color for the label. ### Response #### Success Response (200) - **status** (string) - Label object successfully instantiated. ### Response Example { "status": "success", "label_id": "lbl_001" } ``` -------------------------------- ### GET /labels/clashes Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/Label.html Checks for spatial collisions between labels to ensure clear visualization. ```APIDOC ## GET /labels/clashes ### Description Determines if a specific label clashes with another label or a collection of labels. ### Method GET ### Endpoint /labels/clashes ### Query Parameters - **testLabel** (Label) - Required - The label to test against - **labels** (ArrayList) - Optional - A list of labels to check for collisions ### Response #### Success Response (200) - **clashes** (boolean) - Returns true if a collision is detected, false otherwise ``` -------------------------------- ### POST /cgview/create Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/class-use/Cgview.html Endpoints for creating a new Cgview object from various input formats. ```APIDOC ## POST /cgview/create ### Description Generates a new Cgview object from an external data source such as an XML file, string content, or tab-delimited feature file. ### Method POST ### Endpoint /cgview/create ### Parameters #### Request Body - **source** (String) - Required - The path to the file, URL, or raw XML string content. - **type** (String) - Required - The format type (e.g., 'xml', 'ptt', 'tab'). ### Request Example { "source": "data.xml", "type": "xml" } ### Response #### Success Response (200) - **cgview** (Object) - The instantiated Cgview object. #### Response Example { "status": "success", "cgview_id": "cgv_12345" } ``` -------------------------------- ### Generate CGView XML with BLAST files Source: https://github.com/paulstothard/cgview/blob/master/scripts/cgview_xml_builder/README.md This command demonstrates how to generate a CGView XML file by providing a GenBank sequence file and multiple BLAST result files using the -blast option. It also configures the tick density for the output visualization. ```perl perl cgview_xml_builder.pl \ -sequence sample_input/R_denitrificans.gbk \ -output R_denitrificans.xml \ -tick_density 0.7 -blast file1.txt file2.txt ``` -------------------------------- ### GET /getCenter Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/Cgview.html Calculates and returns the center point of the CGView map. ```APIDOC ## GET /getCenter ### Description Returns a Point2D specifying the center of this cgview. ### Method GET ### Endpoint /getCenter ### Response #### Success Response (200) - **center** (Point2D) - The center coordinates of the cgview. #### Response Example { "x": 500.0, "y": 500.0 } ``` -------------------------------- ### Manage Label Text in LegendItem Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/LegendItem.html Methods to get and set the text label associated with a LegendItem. ```java public String getLabel() { return this.label; } public void setLabel(String label) { this.label = label; } ``` -------------------------------- ### POST /createCgviewFromFile Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/CgviewFactoryPtt.html Generates a Cgview object from a tab-delimited feature file. ```APIDOC ## POST /createCgviewFromFile ### Description Generates a Cgview object from a tab-delimited feature file provided by filename. ### Method POST ### Parameters #### Request Body - **filename** (String) - Required - Path to the tab-delimited file. ### Request Example { "filename": "/path/to/features.txt" } ``` -------------------------------- ### GET /getLabelBounds Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/Cgview.html Retrieves the bounding boxes for all labels currently defined in the CGView. ```APIDOC ## GET /getLabelBounds ### Description Returns an ArrayList of LabelBounds objects associated with this Cgview. ### Method GET ### Endpoint /getLabelBounds ### Response #### Success Response (200) - **bounds** (ArrayList) - An arrayList of LabelBounds objects. #### Response Example { "bounds": [{"x": 0, "y": 0, "width": 10, "height": 5}] } ``` -------------------------------- ### Cgview Initialization and Configuration Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/Cgview.html Methods for creating a Cgview instance and managing its fundamental properties such as sequence length and map dimensions. ```APIDOC ## POST /Cgview ### Description Constructs a new Cgview object with a specified sequence length. ### Method POST ### Endpoint /Cgview ### Parameters #### Request Body - **sequenceLength** (int) - Required - The length of the sequence to be mapped. ### Response #### Success Response (200) - **status** (string) - Success message indicating object creation. --- ## PUT /Cgview/sequenceLength ### Description Updates the length of the sequence to be mapped. ### Method PUT ### Endpoint /Cgview/sequenceLength ### Parameters #### Request Body - **bases** (int) - Required - The new sequence length. --- ## GET /Cgview/dimensions ### Description Retrieves the current dimensions of the map, including width, height, and the smallest dimension. ### Method GET ### Endpoint /Cgview/dimensions ### Response #### Success Response (200) - **width** (int) - The width of the map. - **height** (int) - The height of the map. - **smallestDimension** (int) - The smaller of the two dimensions. ``` -------------------------------- ### GET /FeatureSlot/isRoom Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/index-all.html Checks if a specific feature can fit within a feature slot without causing overlaps. ```APIDOC ## GET /FeatureSlot/isRoom ### Description Determines whether the supplied Feature object can fit in this FeatureSlot without overlapping with existing Feature objects. ### Method GET ### Endpoint ca.ualberta.stothard.cgview.FeatureSlot#isRoom(Feature) ### Parameters #### Request Body - **Feature** (Object) - Required - The feature object to check for fitment. ### Response #### Success Response (200) - **result** (boolean) - Returns true if the feature fits, false otherwise. ### Response Example { "result": true } ``` -------------------------------- ### Build CGView XML Map with Labels and Zoom (Docker) Source: https://github.com/paulstothard/cgview/blob/master/README.md Builds a CGView XML map with feature labels and custom title/label font sizes. This command also prepares for zooming by specifying label font size. ```bash docker run --rm -v "$(pwd)":/dir -u "$(id -u)":"$(id -g)" -w /dir pstothard/cgview perl /usr/bin/cgview_xml_builder.pl -sequence prokka_multicontig.gbk -gc_content T -gc_skew T -size large-v2 -tick_density 0.05 -draw_divider_rings T -custom showBorder=false title="Example map" titleFontSize=200 labelFontSize=60 -feature_labels T -output map_labels.xml ``` -------------------------------- ### POST /feature/configuration Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/index-all.html Configures specific visual settings for individual features or feature ranges. ```APIDOC ## POST /feature/configuration ### Description Updates the visual properties for a specific feature or feature range. ### Method POST ### Endpoint /feature/configuration ### Parameters #### Request Body - **showLabel** (int) - Optional - Sets whether a label should be drawn. - **showShading** (boolean) - Optional - Sets whether the feature should be drawn with shading. ### Request Example { "showLabel": 1, "showShading": true } ### Response #### Success Response (200) - **status** (string) - Feature configuration updated. #### Response Example { "status": "success" } ``` -------------------------------- ### Get Legend Bounds in Java Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/Legend.html Returns the bounding rectangle of the Legend. This is useful for layout calculations and positioning. ```java protected Rectangle2D getBounds() { // Returns the bounds of this Legend. } ``` -------------------------------- ### POST /labels Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/Label.html Constructs a new Label object for a CGView visualization. ```APIDOC ## POST /labels ### Description Constructs a new Label object within the CGView context, defining text, hyperlinks, and positioning. ### Method POST ### Endpoint /labels ### Request Body - **cgview** (Object) - Required - The parent Cgview instance - **labelText** (String) - Required - The text to display - **hyperlink** (String) - Optional - URL for the label - **mouseover** (String) - Optional - Text for mouseover events - **font** (Font) - Required - Font configuration - **color** (Color) - Required - Label color - **forceLabel** (boolean) - Required - Whether to force label visibility - **lineStartRadians** (double) - Required - Starting position in radians - **strand** (int) - Required - Strand orientation ### Response #### Success Response (200) - **status** (string) - Label object created successfully ``` -------------------------------- ### GET /InnerLabel/clashesWithAny Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/InnerLabel.html Checks if the current label overlaps with other labels on the map. ```APIDOC ## GET /InnerLabel/clashesWithAny ### Description Determines if this label currently clashes with other Label objects in the containing Cgview object. ### Method GET ### Endpoint /InnerLabel/clashesWithAny ### Response #### Success Response (200) - **clashes** (boolean) - True if a collision is detected, false otherwise. #### Response Example { "clashes": false } ``` -------------------------------- ### Comparator: SortLabelsByRadians Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/SortLabelsByRadians.html This component provides a comparison mechanism to sort label objects based on their radial start position. ```APIDOC ## [METHOD] compare ### Description Compares two Label objects to determine their relative order based on the `getLineStartRadians()` value. ### Method POST (Internal Logic) ### Endpoint ca.ualberta.stothard.cgview.SortLabelsByRadians#compare(Object, Object) ### Parameters #### Request Body - **o1** (Object) - Required - The first Label object to compare. - **o2** (Object) - Required - The second Label object to compare. ### Response #### Success Response (200) - **result** (int) - Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second. ### Response Example { "result": -1 } ``` -------------------------------- ### CgviewIO Class Documentation Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/CgviewIO.html Documentation for the CgviewIO class, which handles image generation for Cgview objects. ```APIDOC ## Class CgviewIO ### Description This class contains static methods for converting Cgview objects to image files. Images can be generated in PNG, JPG, SVG, and SVGZ (gzipped SVG) formats. ### Author Paul Stothard ### Implements `CgviewConstants` ### Constructor Summary * `CgviewIO()`: Default constructor. ### Method Summary * `static void main(String[] args)`: Main method for executing CgviewIO functionality. ### Fields Inherited from Interface `CgviewConstants` This class inherits numerous constants from the `CgviewConstants` interface, including definitions for bases, bounds, decorations, labels, positions, and swatches. ``` -------------------------------- ### Define sequence features using CGView XML Source: https://github.com/paulstothard/cgview/blob/master/docs/xml_feature.html An example of a CGView XML document demonstrating the use of the feature element to define sequence features. It includes multiple featureRange elements to specify the exact positions and visual overrides for each feature. ```xml ``` -------------------------------- ### POST /cgview/createFromString Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/CgviewFactory.html Generates a Cgview object by parsing a provided string containing XML content. ```APIDOC ## POST /cgview/createFromString ### Description Generates a Cgview object from a String of XML content. ### Method POST ### Endpoint /cgview/createFromString ### Parameters #### Request Body - **xml** (String) - Required - The XML content string to be parsed. ### Request Example { "xml": "..." } ### Response #### Success Response (200) - **cgview** (Object) - The newly created Cgview object. #### Response Example { "status": "success", "data": { "id": "cgview_002", "type": "circular" } } ``` -------------------------------- ### GET /getInnerLabels Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/Cgview.html Retrieves the list of inner labels associated with the current CGView instance. ```APIDOC ## GET /getInnerLabels ### Description Returns an ArrayList of InnerLabel objects associated with this Cgview. ### Method GET ### Endpoint /getInnerLabels ### Response #### Success Response (200) - **labels** (ArrayList) - An arrayList of InnerLabel objects. #### Response Example { "labels": [{"id": 1, "text": "geneA"}] } ``` -------------------------------- ### Write HTML File for Cgview Map (Java) Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/CgviewIO.html Generates an HTML file that links to a Cgview map. It includes hyperlink and mouseover information, embedding it directly in SVG maps or using image maps for PNG/JPG. Requires Cgview object, image file details, and output HTML filename. Can throw FileNotFoundException or IOException. ```java public static void writeHTMLFile(Cgview cgview, String imageFilename, String imageFormat, String htmlFilename, boolean useOverlib) throws FileNotFoundException, IOException ``` -------------------------------- ### Export Cgview to HTML file Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/CgviewIO.html Creates an HTML file that links to a Cgview map. It supports optional configuration for Overlib integration. ```java public static void writeHTMLFile(Cgview cgview, String imageFilename, String imageFormat, String htmlFilename); public static void writeHTMLFile(Cgview cgview, String imageFilename, String imageFormat, String htmlFilename, boolean useOverlib); ``` -------------------------------- ### Manage Text Alignment in LegendItem Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/LegendItem.html Methods to set and get the alignment of the legend item relative to its parent container using CgviewConstants. ```java public int getTextAlignment() { // Returns LEGEND_ITEM_ALIGN_LEFT, CENTER, or RIGHT } public void setTextAlignment(int textAlignment) { // Sets alignment using CgviewConstants } ``` -------------------------------- ### Interaction and Rendering Methods Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/FeatureRange.html Methods for configuring shading and interactive web elements like hyperlinks and mouseover text. ```APIDOC ## POST /FeatureRange/Shading ### Description Sets whether the FeatureRange should be drawn with shading. ### Parameters #### Request Body - **showShading** (boolean) - Required - True to enable shading. ## POST /FeatureRange/Hyperlink ### Description Associates a hyperlink with the FeatureRange for SVG or HTML image map output. ### Parameters #### Request Body - **hyperlink** (String) - Required - The URL string. ## POST /FeatureRange/Mouseover ### Description Sets the mouseover text for the FeatureRange in generated outputs. ### Parameters #### Request Body - **mouseover** (String) - Required - The text to display on mouseover. ``` -------------------------------- ### Initialize OuterLabel in Java Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/OuterLabel.html Demonstrates the construction of an OuterLabel object using the primary constructor. This requires a reference to the Cgview instance, label text, hyperlink, mouseover text, font, color, and positioning parameters. ```java protected OuterLabel(Cgview cgview, String labelText, String hyperlink, String mouseover, Font font, Color color, boolean forceLabel, double lineStartRadians, int strand); ``` -------------------------------- ### Get Image Height (Java) Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/Plasmid.html Retrieves the current height of the circular map. Returns an integer representing the height. ```java public int getImageHeight() Returns the height of this map. Returns: the height of the map. ``` -------------------------------- ### POST /addHeader Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/CgviewHTMLDocument.html Initializes the HTML document by adding the header section and meta tags. ```APIDOC ## POST /addHeader ### Description Adds header information to the CgviewHTMLDocument, including the HTML opening tag. This should be the first method called. ### Method POST ### Parameters #### Request Body - **title** (String) - Required - The title in the header. - **zoom** (String) - Required - The value for the 'zoom' meta tag. - **zoomCenter** (String) - Required - The value for the 'zoomCenter' meta tag. - **imageFormat** (String) - Required - The format of the image. - **useOverlib** (Boolean) - Required - Whether to use the overlib.js library. - **useExternalStyleSheet** (Boolean) - Required - Whether to use an external stylesheet. ### Request Example { "title": "My Map", "zoom": "1.0", "zoomCenter": "500", "imageFormat": "PNG", "useOverlib": true, "useExternalStyleSheet": false } ``` -------------------------------- ### Get Image Width (Java) Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/Plasmid.html Retrieves the current width of the circular map. Returns an integer representing the width. ```java public int getImageWidth() Returns the width of this map. Returns: the width of the map. ``` -------------------------------- ### Set and Get FeatureRange Label Text Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/FeatureRange.html Methods to define and retrieve the text string associated with a FeatureRange label. ```java public void setLabel(String label); public String getLabel(); ``` -------------------------------- ### Get Legend Font Color in Java Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/Legend.html Retrieves the default font color used for text in the Legend. This color can be overridden by individual LegendItems. ```java public Color getFontColor() { // Returns the default color that will be used for the text in this Legend. This color can be changed for individual LegendItem objects using LegendItem.setFontColor(Color). // Returns: // the default text color for the text in this Legend. } ``` -------------------------------- ### Manage LegendItem Visuals Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/LegendItem.html Methods to configure and retrieve visual properties such as font color, swatch color, and swatch visibility for a LegendItem. ```java public void setFontColor(Color fontColor); public Color getFontColor(); public void setSwatchColor(Color swatchColor); public Color getSwatchColor(); public void setDrawSwatch(int drawSwatch); ``` -------------------------------- ### Build CGView XML Map with Docker Source: https://github.com/paulstothard/cgview/blob/master/README.md Runs the CGView Docker image to build an XML map file from a genome sequence. It uses `cgview_xml_builder.pl` and allows customization of map features like GC content, size, and title. ```bash docker run --rm -v "$(pwd)":/dir -u "$(id -u)":"$(id -g)" -w /dir pstothard/cgview perl /usr/bin/cgview_xml_builder.pl -sequence prokka_multicontig.gbk -gc_content T -gc_skew T -size large-v2 -tick_density 0.05 -draw_divider_rings T -custom showBorder=false title="Example map" titleFontSize="200" -output map.xml ``` -------------------------------- ### Get Legend Swatch Height in Java Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/Legend.html Returns the appropriate height for LegendItem swatches. This ensures consistent sizing of visual elements within the legend. ```java protected double getSwatchHeight() { // Returns the height that is suitable for any LegendItem swatches drawn in this Legend. } ``` -------------------------------- ### Get Feature Shading - Java Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/FeatureSlot.html Checks if sequence features in this FeatureSlot are currently configured to be drawn with shading. Returns a boolean indicating the shading status. ```Java public boolean getShowShading() Returns whether or not items in this FeatureSlot should be drawn with shading. Returns: whether or not items in this featureSlot should be drawn with shading. ``` -------------------------------- ### Calculating Line Geometry Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/Label.html Methods to retrieve geometric representations of lines, such as converting a line to an Area object or calculating the starting coordinate point for a label line. ```java protected Area getLineAsArea(double startRadius, double startRadians, double endRadius, double endRadians) { // Returns an Area representing the line } protected Point2D getLineStart() { // Returns the starting Point2D of the label line } ``` -------------------------------- ### Initialize Javadoc Navigation Scripts Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/Feature.html Standard Javadoc-generated JavaScript used to manage navigation and script loading within the API documentation pages. ```javascript var pathtoroot = "../../../../"; loadScripts(document, 'script'); ``` -------------------------------- ### Get Title Font - Java Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/Cgview.html Retrieves the font currently applied to the map title of the Cgview. This method returns a java.awt.Font object. ```java public Font getTitleFont() Returns the font of the map title. ``` -------------------------------- ### POST /api/features/create Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/index-all.html Constructs a new sequence feature object within the CGView system. ```APIDOC ## POST /api/features/create ### Description Constructs a new Feature object representing a sequence feature. ### Method POST ### Endpoint /api/features/create ### Parameters #### Request Body - **featureSlot** (string) - Required - The slot identifier to associate with the feature. - **name** (string) - Optional - The name of the feature. ### Request Example { "featureSlot": "slot_A", "name": "Gene_01" } ### Response #### Success Response (200) - **featureId** (string) - The unique ID of the created feature. #### Response Example { "featureId": "feat_9982" } ``` -------------------------------- ### Get Backbone Radius (Java) Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/Cgview.html Retrieves the current radius of the circle representing the DNA sequence. The method returns a double value. ```Java public double getBackboneRadius() ``` -------------------------------- ### Generate CGView XML with advanced configuration Source: https://github.com/paulstothard/cgview/blob/master/scripts/cgview_xml_builder/README.md This command generates a CGView XML file from a sequence file while enabling GC content and GC skew calculations. It also specifies a large map size for the final output. ```perl perl cgview_xml_builder.pl -sequence test_input/prokka_multicontig.gbk \ -output prokka_map.xml -gc_content T -gc_skew T -size large-v2 ``` -------------------------------- ### Legend Background Configuration Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/Legend.html Endpoints for managing the opacity and color of the Legend background. ```APIDOC ## POST /legend/background/opacity ### Description Sets the opacity of the background of the Legend. ### Method POST ### Parameters #### Request Body - **opacity** (float) - Required - The opacity value between 0 and 1. ### Request Example { "opacity": 0.5 } ## GET /legend/background/opacity ### Description Returns the current opacity of the Legend background. ### Method GET ### Response #### Success Response (200) - **opacity** (float) - The current opacity value. ## POST /legend/background/color ### Description Sets the background color of the Legend. ### Method POST ### Parameters #### Request Body - **color** (String) - Required - The color representation (e.g., hex or name). ### Request Example { "color": "#FFFFFF" } ## GET /legend/background/color ### Description Returns the current background color of the Legend. ### Method GET ### Response #### Success Response (200) - **color** (String) - The current background color. ``` -------------------------------- ### Get Feature Thickness - Java Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/FeatureSlot.html Returns the current thickness of the arc used for drawing sequence features. This value dictates how visually thick the feature representations will be. ```Java public float getFeatureThickness() Returns the thickness of the arc used to represent sequence features in this FeatureSlot. Returns: the feature thickness. ``` -------------------------------- ### Get Feature Label Line Length in CGView Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/Cgview.html Retrieves the current length of the lines connecting features to their labels. The length is returned as a double. ```java public double getLabelLineLength() ``` -------------------------------- ### POST /plasmid/configuration Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/index-all.html Configures global visual settings for the Plasmid object, including labels, legends, and shading. ```APIDOC ## POST /plasmid/configuration ### Description Updates the visual configuration of a Plasmid instance. ### Method POST ### Endpoint /plasmid/configuration ### Parameters #### Request Body - **showInnerLabels** (boolean) - Optional - Sets whether labels are allowed on the inside. - **showLabels** (boolean) - Optional - Sets whether labels are drawn on the map. - **showLegend** (boolean) - Optional - Sets whether a legend is drawn. - **showShading** (boolean) - Optional - Sets whether items are drawn with shading. - **showTitle** (boolean) - Optional - Sets whether a title is drawn. ### Request Example { "showLabels": true, "showLegend": true, "showShading": true } ### Response #### Success Response (200) - **status** (string) - Configuration updated successfully. #### Response Example { "status": "success" } ``` -------------------------------- ### createCgviewFromFile Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/CgviewFactory.html Generates a Cgview object from an XML file. ```APIDOC ## Cgview createCgviewFromFile(String filename) ### Description Generates a Cgview object from an XML file. ### Method GET (or equivalent for creation) ### Endpoint N/A (This is a method call within a Java application) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **filename** (String) - Required - The path to the XML file to create the Cgview from. ### Request Example ```java String xmlFilePath = "path/to/your/cgview.xml"; Cgview cgview = CgviewFactory.createCgviewFromFile(xmlFilePath); ``` ### Response #### Success Response (200) - **cgview** (Cgview) - The newly created Cgview object. #### Response Example ```json { "cgview": { ... Cgview object representation ... } } ``` ``` -------------------------------- ### Get Feature Label Line Thickness in CGView Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/Cgview.html Returns the current thickness of the lines that extend from features to their labels. The value is returned as a float. ```java public float getLabelLineThickness() ``` -------------------------------- ### Get Legend Text Color (Java) Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/Cgview.html Retrieves the default color for text used in Legend objects. The method returns a java.awt.Color object. ```Java public Color getLegendTextColor() ``` -------------------------------- ### LabelBounds Constructor with Cgview Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/class-use/Cgview.html Constructs a new LabelBounds object. This constructor takes a Cgview object as its only parameter. ```java new LabelBounds(cgview); ``` -------------------------------- ### Get Title Font Color (Java) Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/Cgview.html Retrieves the current color of the text used for the sequence title. The method returns a java.awt.Color object. ```Java public Color getTitleFontColor() ``` -------------------------------- ### Download Test Genome File Source: https://github.com/paulstothard/cgview/blob/master/README.md Downloads a sample genome file in GenBank format using `wget`. This file is used as input for generating CGView maps. ```bash wget https://paulstothard.github.io/cgview/downloads/prokka_multicontig.gbk ``` -------------------------------- ### Get Ruler Font Color (Java) Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/Cgview.html Retrieves the current color of the text used for the sequence ruler. The method returns a java.awt.Color object. ```Java public Color getRulerFontColor() ``` -------------------------------- ### Cgview Configuration API Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/index-all.html Provides methods to retrieve configuration settings for the CGView map, including ruler appearance and sequence details. ```APIDOC ## GET /api/cgview/configuration ### Description Retrieves various configuration settings for the CGView map, such as radians conversion constants, ruler appearance, and sequence length. ### Method GET ### Endpoint /api/cgview/configuration ### Parameters #### Query Parameters None ### Request Example ```json { "example": "GET /api/cgview/configuration" } ``` ### Response #### Success Response (200) - **radiansShiftConstant** (float) - Constant controlling label movement along the backbone. - **radiusShiftAmount** (float) - Distance labels are moved away from the backbone. - **rulerFont** (string) - The font used for sequence ruler labels. - **rulerFontColor** (string) - The color of the text for the sequence ruler. - **rulerTextPadding** (float) - Spacing between ruler labels and tick marks. - **rulerUnits** (string) - Units used for the sequence ruler. - **sequenceLength** (integer) - The length of the sequence being mapped. - **shadingProportion** (float) - Proportion of feature width for highlighting/shadowing. #### Response Example ```json { "radiansShiftConstant": 0.1, "radiusShiftAmount": 5.0, "rulerFont": "Arial", "rulerFontColor": "#000000", "rulerTextPadding": 2.0, "rulerUnits": "bp", "sequenceLength": 10000, "shadingProportion": 0.8 } ``` ## GET /api/cgview/radians ### Description Converts a given base value (double or integer) into radians. ### Method GET ### Endpoint /api/cgview/radians ### Parameters #### Query Parameters - **base** (number) - Required - The value to convert to radians. Can be an integer or a double. ### Request Example ```json { "example": "GET /api/cgview/radians?base=180" } ``` ### Response #### Success Response (200) - **radians** (float) - The radians representation of the base value. #### Response Example ```json { "radians": 3.14159 } ``` ``` -------------------------------- ### Set HTML image tag path Source: https://github.com/paulstothard/cgview/blob/master/docs/application.html Defines the custom path for the map image source within the generated HTML file. This overrides the default output path. ```bash java -jar cgview.jar -i input.xml -o output.png -f png -h output.html -p /maps/images/output.png ``` -------------------------------- ### Get Backbone Thickness (Java) Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/Cgview.html Retrieves the current thickness of the line used for the DNA sequence circle. The method returns a double value. ```Java public double getBackboneThickness() ``` -------------------------------- ### Get Hyperlink for Label in Java Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/Label.html Retrieves the hyperlink associated with a Label object. This method returns the URL previously set for the label. It returns a String representing the hyperlink. ```java protected String getHyperlink() Returns the hyperlink to be associated with this Label. Returns: the hyperlink to be associated with this Label. ``` -------------------------------- ### Initialize LegendItem Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/LegendItem.html Constructs a new LegendItem object associated with a specific Legend container. ```java public LegendItem(Legend legend) { // Constructor implementation } ``` -------------------------------- ### Constructing a Label Object Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/Label.html The Label constructor initializes a label with specific text, styling, and positioning parameters. It requires a reference to the parent Cgview object and various visual properties like font, color, and strand orientation. ```java protected Label(Cgview cgview, String labelText, String hyperlink, String mouseover, Font font, Color color, boolean forceLabel, double lineStartRadians, int strand) { // Implementation initializes label properties and positioning } ``` -------------------------------- ### Implement SAX Character Data Handling Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/CgviewFactory.html Method to process the character data found between XML tags. It receives a character array, a start index, and the length of the data segment. ```java public void characters(char[] ch, int start, int length) {} ``` -------------------------------- ### Constructor: Legend Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/Legend.html Initializes a new Legend object associated with a specific Cgview map instance. ```APIDOC ## POST /legend/create ### Description Constructs a new Legend object to be used for adding legend entries to a Cgview map. ### Method POST ### Endpoint /legend/create ### Parameters #### Request Body - **cgview** (Cgview object) - Required - The Cgview map instance to which this legend will be attached. ### Request Example { "cgview": "instance_id_001" } ### Response #### Success Response (200) - **status** (string) - Confirmation of legend creation. #### Response Example { "status": "success", "legend_id": "legend_001" } ``` -------------------------------- ### Initialize CgviewHTMLDocument Source: https://github.com/paulstothard/cgview/blob/master/docs/apidocs/ca/ualberta/stothard/cgview/CgviewHTMLDocument.html Demonstrates the instantiation of the CgviewHTMLDocument class, which serves as the base object for building HTML structures for Cgview. ```java import ca.ualberta.stothard.cgview.CgviewHTMLDocument; // Construct a new CgviewHTMLDocument object CgviewHTMLDocument doc = new CgviewHTMLDocument(); ```