@gmod/gff
Version:
read and write GFF3 data as streams
167 lines (166 loc) • 5.94 kB
TypeScript
/**
* Unescape a string value used in a GFF3 attribute.
*
* @param stringVal - Escaped GFF3 string value
* @returns An unescaped string value
*/
export declare function unescape(stringVal: string): string;
/**
* Escape a value for use in a GFF3 attribute value.
*
* @param rawVal - Raw GFF3 attribute value
* @returns An escaped string value
*/
export declare function escape(rawVal: string | number): string;
/**
* Escape a value for use in a GFF3 column value.
*
* @param rawVal - Raw GFF3 column value
* @returns An escaped column value
*/
export declare function escapeColumn(rawVal: string | number): string;
/**
* Parse the 9th column (attributes) of a GFF3 feature line.
*
* @param attrString - String of GFF3 9th column
* @returns Parsed attributes
*/
export declare function parseAttributes(attrString: string): GFF3Attributes;
/**
* Parse a GFF3 feature line
*
* @param line - GFF3 feature line
* @returns The parsed feature
*/
export declare function parseFeature(line: string): GFF3FeatureLine;
/**
* Parse a GFF3 directive line.
*
* @param line - GFF3 directive line
* @returns The parsed directive
*/
export declare function parseDirective(line: string): GFF3Directive | GFF3SequenceRegionDirective | GFF3GenomeBuildDirective | null;
/**
* Format an attributes object into a string suitable for the 9th column of GFF3.
*
* @param attrs - Attributes
* @returns GFF3 9th column string
*/
export declare function formatAttributes(attrs: GFF3Attributes): string;
/**
* Format a feature object or array of feature objects into one or more lines of
* GFF3.
*
* @param featureOrFeatures - A feature object or array of feature objects
* @returns A string of one or more GFF3 lines
*/
export declare function formatFeature(featureOrFeatures: GFF3FeatureLine | GFF3FeatureLineWithRefs | (GFF3FeatureLine | GFF3FeatureLineWithRefs)[]): string;
/**
* Format a directive into a line of GFF3.
*
* @param directive - A directive object
* @returns A directive line string
*/
export declare function formatDirective(directive: GFF3Directive): string;
/**
* Format a comment into a GFF3 comment.
* Yes I know this is just adding a # and a newline.
*
* @param comment - A comment object
* @returns A comment line string
*/
export declare function formatComment(comment: GFF3Comment): string;
/**
* Format a sequence object as FASTA
*
* @param seq - A sequence object
* @returns Formatted single FASTA sequence string
*/
export declare function formatSequence(seq: GFF3Sequence): string;
/**
* Format a directive, comment, sequence, or feature, or array of such items,
* into one or more lines of GFF3.
*
* @param itemOrItems - A comment, sequence, or feature, or array of such items
* @returns A formatted string or array of strings
*/
export declare function formatItem(itemOrItems: GFF3FeatureLineWithRefs | GFF3Directive | GFF3Comment | GFF3Sequence | (GFF3FeatureLineWithRefs | GFF3Directive | GFF3Comment | GFF3Sequence)[]): string | string[];
/** A record of GFF3 attribute identifiers and the values of those identifiers */
export declare type GFF3Attributes = Record<string, string[] | undefined>;
/** A representation of a single line of a GFF3 file */
export interface GFF3FeatureLine {
/** The ID of the landmark used to establish the coordinate system for the current feature */
seq_id: string | null;
/** A free text qualifier intended to describe the algorithm or operating procedure that generated this feature */
source: string | null;
/** The type of the feature */
type: string | null;
/** The start coordinates of the feature */
start: number | null;
/** The end coordinates of the feature */
end: number | null;
/** The score of the feature */
score: number | null;
/** The strand of the feature */
strand: string | null;
/** For features of type "CDS", the phase indicates where the next codon begins relative to the 5' end of the current CDS feature */
phase: string | null;
/** Feature attributes */
attributes: GFF3Attributes | null;
}
/**
* A GFF3 Feature line that includes references to other features defined in
* their "Parent" or "Derives_from" attributes
*/
export interface GFF3FeatureLineWithRefs extends GFF3FeatureLine {
/** An array of child features */
child_features: GFF3Feature[];
/** An array of features derived from this feature */
derived_features: GFF3Feature[];
}
/**
* A GFF3 feature, which may include multiple individual feature lines
*/
export declare type GFF3Feature = GFF3FeatureLineWithRefs[];
/** A GFF3 directive */
export interface GFF3Directive {
/** The name of the directive */
directive: string;
/** The string value of the directive */
value?: string;
}
/** A GFF3 sequence-region directive */
export interface GFF3SequenceRegionDirective extends GFF3Directive {
/** The string value of the directive */
value: string;
/** The sequence ID parsed from the directive */
seq_id: string;
/** The sequence start parsed from the directive */
start: string;
/** The sequence end parsed from the directive */
end: string;
}
/** A GFF3 genome-build directive */
export interface GFF3GenomeBuildDirective extends GFF3Directive {
/** The string value of the directive */
value: string;
/** The genome build source parsed from the directive */
source: string;
/** The genome build name parsed from the directive */
buildName: string;
}
/** A GFF3 comment */
export interface GFF3Comment {
/** The text of the comment */
comment: string;
}
/** A GFF3 FASTA single sequence */
export interface GFF3Sequence {
/** The ID of the sequence */
id: string;
/** The description of the sequence */
description?: string;
/** The sequence */
sequence: string;
}
export declare type GFF3Item = GFF3Feature | GFF3Directive | GFF3Comment | GFF3Sequence;