ParseGenbankManager
extends ParseDbAbstractManager
in package
Class ParseGenbankManager
Tags
Table of Contents
Constants
- FEATURE_KEYS : mixed = [ "assembly_gap", "C_region", "CDS", "centromer...
- Every feature key of the INSDC Feature Table Definition (v11.4), followed by the keys it deprecated on 15-DEC-2014 in favour of "regulatory" + /regulatory_class, which plasmid files (SnapGene, Addgene...) still use widely. A key outside this list is skipped.
Properties
- $accession : array<string|int, mixed>
- $authors : array<string|int, mixed>
- $features : array<string|int, mixed>
- $gbSequence : GbSequence
- $keywords : array<string|int, mixed>
- $references : array<string|int, mixed>
- $sequence : Sequence
- $spDatabank : array<string|int, mixed>
- $srcForm : SrcForm
- $aLines : ArrayIterator|null
Methods
- __construct() : mixed
- Constructor.
- getAccession() : array<string|int, mixed>
- getAuthors() : array<string|int, mixed>
- getEntryId() : string
- Extracts the identifier uniquely naming a GenBank entry, which is its primary accession (the key parseDataFile() gives to every row of the record, and ParseEntrezManager to its own). The LOCUS name is only a fallback for a record short of an ACCESSION line : the two differ in many records (LOCUS SCU49845, ACCESSION U49845).
- getFeatures() : array<string|int, mixed>
- getFormat() : string
- The name this format is known by in the collection records and in DatabaseParserFactory.
- getGbSequence() : GbSequence
- getKeywords() : array<string|int, mixed>
- getmin() : int
- Gets the minimum of three (usually numeric) values $x, $y, and $z.
- getReferences() : array<string|int, mixed>
- getSequence() : Sequence
- getSpDatabank() : array<string|int, mixed>
- getSrcForm() : SrcForm
- intrim() : mixed
- Removes "internal spaces" (as opposed to leading and trailing spaces) from a string.
- isEntryEnd() : bool
- Tells whether a line closes a GenBank entry.
- isEntryStart() : bool
- Tells whether a line opens a new GenBank entry.
- left() : bool|string
- Returns the first $numchars characters of a string.
- parseDataFile() : Sequence
- Parses a GenBank data file and returns a Seq object containing parsed data.
- readLocusLine() : array<string|int, mixed>
- Reads the fields of a LOCUS line, word by word (see parseLocus()). Shared with ParseEntrezManager, whose records open on the same line.
- rem_right() : bool|string
- Removes $charcount characters from the right (end) of a string.
- right() : bool|string
- Returns the substring beginning at $numchars characters from the right end of a string.
- setAccession() : void
- setAuthors() : void
- setFeatures() : void
- setGbSequence() : void
- setKeywords() : void
- setReferences() : void
- setSequence() : void
- setSpDatabank() : void
- setSrcForm() : void
- trim_element() : mixed
- trim_element() removes leading and trailing spaces from a string. In conjunction with the array_walk() function, it removes spaces from each element of an array.
- parseInsdcFeature() : mixed
- Parses one feature of an INSDC feature table, shared by GenBank and EMBL, whose columns are the same : the key from column 6, the location (possibly wrapped over several lines) and the /qualifier lines from column 22. $aFlines is read ahead to find where the feature ends : a line holding something in its first 12 columns starts another feature or section, so EMBL hands its lines with their "FT" tag blanked out.
- parseLocationBounds() : array<string|int, mixed>
- Parses an INSDC feature location (shared by GenBank and EMBL) into its outer bounds and strand, 1-based and inclusive. The location as written is kept apart (Feature::getFtLocation()) : these bounds only frame it.
- parseAccession() : mixed
- Parses ACCESSION field : the primary accession, then the secondary ones, possibly continued on lines whose first 12 columns are blank. A record cut out of a larger one (a CON or contig sub-range) follows them with "REGION: from..to", which is not an accession.
- parseDefinition() : mixed
- Parses DEFINITION field @ param array $flines
- parseKeywords() : mixed
- Parses KEYWORDS field, possibly continued on lines whose first 12 columns are blank : the keywords are separated by ";" and the field closed by a period, alone when there is none.
- parseLocus() : mixed
- Parses line LOCUS. NCBI writes its fields in fixed columns - name 13-28, length 30-40, strandedness 45-47, molecule type 48-53, topology 56-63, division 65-67, date 69-79 - but shifts them all right when the name is longer than its 16 columns (a WGS contig such as NZ_JAAXYZ010000001), so they are read as words : the name, the length before its unit (bp or aa), then the molecule type (absent from a protein record), topology, division and date, any of which may be missing.
- parseOrganism() : mixed
- Parses information about organism
- parseReferences() : mixed
- Parses a REFERENCE and its AUTHORS, CONSRTM, TITLE, JOURNAL, MEDLINE, PUBMED and REMARK lines, each possibly continued on lines whose first 12 columns are blank. Lines are read ahead : the iterator is left on the reference's last line, so that the section following it (FEATURES, COMMENT, the next REFERENCE) is read by the main loop and not skipped.
- parseVersion() : mixed
- Parses VERSION field
- readContinuedField() : array<string|int, string>
- Returns the data of the current line, past its 12 label columns, and of the lines continuing it (first 12 columns blank), leaving the iterator on the last of them.
- setRecordKey() : void
- Gives the record its key, on the Sequence and on its GbSequence together : the one table joins the other on it, so they must never hold different values. LOCUS sets it first (the name), ACCESSION then replaces it with the primary accession, which is what getEntryId() indexes the record by.
Constants
FEATURE_KEYS
Every feature key of the INSDC Feature Table Definition (v11.4), followed by the keys it deprecated on 15-DEC-2014 in favour of "regulatory" + /regulatory_class, which plasmid files (SnapGene, Addgene...) still use widely. A key outside this list is skipped.
public
mixed
FEATURE_KEYS
= [
"assembly_gap",
"C_region",
"CDS",
"centromere",
"D-loop",
"D_segment",
"exon",
"gap",
"gene",
"iDNA",
"intron",
"J_segment",
"mat_peptide",
"misc_binding",
"misc_difference",
"misc_feature",
"misc_recomb",
"misc_RNA",
"misc_structure",
"mobile_element",
"modified_base",
"mRNA",
"ncRNA",
"N_region",
"old_sequence",
"operon",
"oriT",
"polyA_site",
"precursor_RNA",
"prim_transcript",
"primer_bind",
"propeptide",
"protein_bind",
"regulatory",
"repeat_region",
"rep_origin",
"rRNA",
"S_region",
"sig_peptide",
"source",
"stem_loop",
"STS",
"telomere",
"tmRNA",
"transit_peptide",
"tRNA",
"unsure",
"V_region",
"V_segment",
"variation",
"3'UTR",
"5'UTR",
// Deprecated 15-DEC-2014
"enhancer",
"promoter",
"CAAT_signal",
"TATA_signal",
"-35_signal",
"-10_signal",
"RBS",
"GC_signal",
"polyA_signal",
"attenuator",
"terminator",
"misc_signal",
]
Properties
$accession
protected
array<string|int, mixed>
$accession
= null
$authors
protected
array<string|int, mixed>
$authors
= null
$features
protected
array<string|int, mixed>
$features
= null
$gbSequence
protected
GbSequence
$gbSequence
= null
$keywords
protected
array<string|int, mixed>
$keywords
= null
$references
protected
array<string|int, mixed>
$references
= null
$sequence
protected
Sequence
$sequence
= null
$spDatabank
protected
array<string|int, mixed>
$spDatabank
= null
$srcForm
protected
SrcForm
$srcForm
= null
$aLines
private
ArrayIterator|null
$aLines
= null
Methods
__construct()
Constructor.
public
__construct() : mixed
getAccession()
public
getAccession() : array<string|int, mixed>
Return values
array<string|int, mixed>getAuthors()
public
getAuthors() : array<string|int, mixed>
Return values
array<string|int, mixed>getEntryId()
Extracts the identifier uniquely naming a GenBank entry, which is its primary accession (the key parseDataFile() gives to every row of the record, and ParseEntrezManager to its own). The LOCUS name is only a fallback for a record short of an ACCESSION line : the two differ in many records (LOCUS SCU49845, ACCESSION U49845).
public
static getEntryId(array<string|int, mixed> $aFlines, string $sLine) : string
Parameters
- $aFlines : array<string|int, mixed>
-
The lines of the entry (or the whole file, buffered)
- $sLine : string
-
The line opening the entry
Return values
stringgetFeatures()
public
getFeatures() : array<string|int, mixed>
Return values
array<string|int, mixed>getFormat()
The name this format is known by in the collection records and in DatabaseParserFactory.
public
static getFormat() : string
Return values
stringgetGbSequence()
public
getGbSequence() : GbSequence
Return values
GbSequencegetKeywords()
public
getKeywords() : array<string|int, mixed>
Return values
array<string|int, mixed>getmin()
Gets the minimum of three (usually numeric) values $x, $y, and $z.
public
getmin(int $x, int $y, int $z) : int
For now, this can't handle situations when one or more arguments is FALSE.
Parameters
- $x : int
- $y : int
- $z : int
Return values
intgetReferences()
public
getReferences() : array<string|int, mixed>
Return values
array<string|int, mixed>getSequence()
public
getSequence() : Sequence
Return values
SequencegetSpDatabank()
public
getSpDatabank() : array<string|int, mixed>
Return values
array<string|int, mixed>getSrcForm()
public
getSrcForm() : SrcForm
Return values
SrcFormintrim()
Removes "internal spaces" (as opposed to leading and trailing spaces) from a string.
public
intrim(string $string) : mixed
Parameters
- $string : string
isEntryEnd()
Tells whether a line closes a GenBank entry.
public
static isEntryEnd(string $sLine) : bool
Parameters
- $sLine : string
-
The line to analyze
Return values
boolisEntryStart()
Tells whether a line opens a new GenBank entry.
public
static isEntryStart(string $sLine) : bool
Parameters
- $sLine : string
-
The line to analyze
Return values
boolleft()
Returns the first $numchars characters of a string.
public
left(string $str, int $numchars) : bool|string
Parameters
- $str : string
- $numchars : int
Return values
bool|stringparseDataFile()
Parses a GenBank data file and returns a Seq object containing parsed data.
public
parseDataFile(array<string|int, mixed> $aFlines) : Sequence
Parameters
- $aFlines : array<string|int, mixed>
-
The lines the script has to parse
Tags
Return values
Sequence —$oSequence
readLocusLine()
Reads the fields of a LOCUS line, word by word (see parseLocus()). Shared with ParseEntrezManager, whose records open on the same line.
public
static readLocusLine(string $sLine) : array<string|int, mixed>
Parameters
- $sLine : string
Return values
array<string|int, mixed> —["name" => string, "length" => int, "molType" => string, "strands" => ?string (SINGLE, DOUBLE, MIXED), "topology" => string, "division" => string, "date" => string], the last three upper-cased, "" when absent
rem_right()
Removes $charcount characters from the right (end) of a string.
public
rem_right(string $str[, int $charcount = 1 ]) : bool|string
Parameters
- $str : string
- $charcount : int = 1
Return values
bool|stringright()
Returns the substring beginning at $numchars characters from the right end of a string.
public
right(string $str, int $numchars) : bool|string
Parameters
- $str : string
- $numchars : int
Return values
bool|stringsetAccession()
public
setAccession(array<string|int, mixed> $accession) : void
Parameters
- $accession : array<string|int, mixed>
setAuthors()
public
setAuthors(array<string|int, mixed> $authors) : void
Parameters
- $authors : array<string|int, mixed>
setFeatures()
public
setFeatures(array<string|int, mixed> $features) : void
Parameters
- $features : array<string|int, mixed>
setGbSequence()
public
setGbSequence(GbSequence $gbSequence) : void
Parameters
- $gbSequence : GbSequence
setKeywords()
public
setKeywords(array<string|int, mixed> $keywords) : void
Parameters
- $keywords : array<string|int, mixed>
setReferences()
public
setReferences(array<string|int, mixed> $references) : void
Parameters
- $references : array<string|int, mixed>
setSequence()
public
setSequence(Sequence $sequence) : void
Parameters
- $sequence : Sequence
setSpDatabank()
public
setSpDatabank(array<string|int, mixed> $spDatabank) : void
Parameters
- $spDatabank : array<string|int, mixed>
setSrcForm()
public
setSrcForm(SrcForm $srcForm) : void
Parameters
- $srcForm : SrcForm
trim_element()
trim_element() removes leading and trailing spaces from a string. In conjunction with the array_walk() function, it removes spaces from each element of an array.
public
trim_element(mixed &$value, mixed $key) : mixed
Parameters
- $value : mixed
- $key : mixed
parseInsdcFeature()
Parses one feature of an INSDC feature table, shared by GenBank and EMBL, whose columns are the same : the key from column 6, the location (possibly wrapped over several lines) and the /qualifier lines from column 22. $aFlines is read ahead to find where the feature ends : a line holding something in its first 12 columns starts another feature or section, so EMBL hands its lines with their "FT" tag blanked out.
protected
parseInsdcFeature(ArrayIterator $oLines, array<string|int, mixed> $aFlines, string $sKey) : mixed
Parameters
- $oLines : ArrayIterator
-
The parser's line iterator, on the feature's key line
- $aFlines : array<string|int, mixed>
-
The lines, as read ahead
- $sKey : string
-
The feature key
Tags
parseLocationBounds()
Parses an INSDC feature location (shared by GenBank and EMBL) into its outer bounds and strand, 1-based and inclusive. The location as written is kept apart (Feature::getFtLocation()) : these bounds only frame it.
protected
parseLocationBounds(string $sLocation) : array<string|int, mixed>
- complement(), join() and order() wrappers and the "<" / ">" partial marks are stripped ;
- "a..b" spans a to b, "a" is one base, "a.b" one base somewhere in a..b and "a^b" the site between two bases : both give a..b ;
- a segment of another entry ("J00194.1:100..202") lies on another sequence and is left out ; a location made of such segments only has no bounds here (null, null) ;
- the segments of a join() are listed in the order they are transcribed. When the record is circular, all of them lie on the same strand and that order goes back past the origin (join(4900..5000,1..100), or join(complement(1..100),complement(4900..5000)) on the other strand), that order goes back exactly once, from the last base of the molecule to the first, and the join is not an order(), the bounds are from = 4900, to = 100 : from > to, the origin-crossing convention of PlasmidFeature, as for a single segment written "4900..100". Otherwise - a linear record, an order(), a trans-spliced gene (plant organelle nad1, rps12) whose segments are listed out of order - they are the lowest start and the highest end.
Parameters
- $sLocation : string
-
The raw location text, e.g. "complement(join(<1..10,50..>60))".
Return values
array<string|int, mixed> —[$iFrom, $iTo, $sStrand] - $sStrand is "-" when every segment of this entry is complemented, "+" when none is, null when the location lies on both strands (a trans-spliced join(complement(a..b),c..d)).
parseAccession()
Parses ACCESSION field : the primary accession, then the secondary ones, possibly continued on lines whose first 12 columns are blank. A record cut out of a larger one (a CON or contig sub-range) follows them with "REGION: from..to", which is not an accession.
private
parseAccession() : mixed
Format : ACCESSION NC_000913 REGION: 1..1000
Tags
parseDefinition()
Parses DEFINITION field @ param array $flines
private
parseDefinition(mixed $flines) : mixed
Parameters
- $flines : mixed
Tags
parseKeywords()
Parses KEYWORDS field, possibly continued on lines whose first 12 columns are blank : the keywords are separated by ";" and the field closed by a period, alone when there is none.
private
parseKeywords() : mixed
Format : KEYWORDS RefSeq; MANE Select.
Tags
parseLocus()
Parses line LOCUS. NCBI writes its fields in fixed columns - name 13-28, length 30-40, strandedness 45-47, molecule type 48-53, topology 56-63, division 65-67, date 69-79 - but shifts them all right when the name is longer than its 16 columns (a WGS contig such as NZ_JAAXYZ010000001), so they are read as words : the name, the length before its unit (bp or aa), then the molecule type (absent from a protein record), topology, division and date, any of which may be missing.
private
parseLocus() : mixed
Tags
parseOrganism()
Parses information about organism
private
parseOrganism(mixed $flines) : mixed
Parameters
- $flines : mixed
Tags
parseReferences()
Parses a REFERENCE and its AUTHORS, CONSRTM, TITLE, JOURNAL, MEDLINE, PUBMED and REMARK lines, each possibly continued on lines whose first 12 columns are blank. Lines are read ahead : the iterator is left on the reference's last line, so that the section following it (FEATURES, COMMENT, the next REFERENCE) is read by the main loop and not skipped.
private
parseReferences(array<string|int, mixed> $aFlines) : mixed
The authors are separated by ", " and the last one by " and " ; a name keeps its own comma and initials ("Roemer,T."). Each consortium of the CONSRTM line is kept as an author.
Parameters
- $aFlines : array<string|int, mixed>
-
The lines the script has to parse
Tags
parseVersion()
Parses VERSION field
private
parseVersion() : mixed
Tags
readContinuedField()
Returns the data of the current line, past its 12 label columns, and of the lines continuing it (first 12 columns blank), leaving the iterator on the last of them.
private
readContinuedField() : array<string|int, string>
Return values
array<string|int, string>setRecordKey()
Gives the record its key, on the Sequence and on its GbSequence together : the one table joins the other on it, so they must never hold different values. LOCUS sets it first (the name), ACCESSION then replaces it with the primary accession, which is what getEntryId() indexes the record by.
private
setRecordKey(string $sKey) : void
Parameters
- $sKey : string