GenbankWriter
in package
implements
GenbankWriterInterface
Covers the subset of the GenBank flat-file format GenbankPlasmidMapper reads back : LOCUS, DEFINITION, ACCESSION, a FEATURES table (a synthetic "source 1..length" line plus one entry per PlasmidFeature) and an ORIGIN sequence block. It does not attempt REFERENCE, COMMENT, VERSION, a real division code or submission date - Plasmid carries none of those, and inventing plausible- looking values for them would misrepresent the record rather than describe it. The LOCUS line follows NCBI's fixed columns (see writeLocusLine()), except for a locus name longer than 16 characters, written in full rather than truncated.
A REVERSE-strand feature is written as "complement(start..end)" with start <= end, the standard GenBank convention. A feature crossing the origin (start > end) is written as INSDC does on a circular molecule, "join(start..length,1..end)", wrapped in complement() on the REVERSE strand - the form GenbankPlasmidMapper reads back as the same origin-crossing feature.
DEFINITION and qualifier lines wrap at 79 characters, as NCBI writes them. The source feature carries /organism and /mol_type when the plasmid's metadata gives them (GenbankPlasmidMapper keeps those of the record it read).
A feature with no /gene, /label or /product metadata is written with its name as /label.
INSDC has no notation for an unstranded feature : a location without complement() lies on the direct strand. A Strand::NONE feature is therefore written as a plain range followed by /biophp_strand="none" (UNSTRANDED_QUALIFIER), a qualifier of this library's own, which GenbankPlasmidMapper reads back as Strand::NONE. Any other reader ignores it and, as INSDC says, reads the feature on the direct strand.
A CDS phase is written as /codon_start = phase + 1, a bare number as INSDC specifies. A PROMOTER or
TERMINATOR with no GenBank key of its own is written as "regulatory" with the matching
/regulatory_class, the "promoter" and "terminator" keys being deprecated since 15-DEC-2014.
A feature's GenBank key and its /gene, /label, /product, /note qualifiers are read back from
getMetadata()/getNote() exactly as GenbankPlasmidMapper wrote them when importing, so a
read-then-write round trip of a feature that originated from GenBank is lossless. A feature with
no such metadata (hand-built, imported from GFF3/BED...) falls back to a FeatureType-derived key ;
FeatureType's richer vocabulary (INSERT, MARKER, REPORTER, TAG, RESTRICTION_SITE...) has no GenBank
feature-key equivalent for most of its members, so those honestly fall back to "misc_feature"
rather than a plausible-looking but wrong guess.
Class GenbankWriter
Tags
Table of Contents
Interfaces
- GenbankWriterInterface
- Interface GenbankWriterInterface - serializes a Plasmid into GenBank flat-file text. The counterpart of GenbankPlasmidMapper, not of ParseGenbankManager directly : it writes a Plasmid aggregate, not the raw Feature entities the legacy parser produces.
Constants
- UNSTRANDED_QUALIFIER : mixed = "biophp_strand"
- The qualifier marking a feature on no particular strand, which INSDC cannot write
- BASES_PER_GROUP : mixed = 10
- BASES_PER_LINE : mixed = 60
- GENBANK_KEY_BY_FEATURE_TYPE : array<string, string> = [\Amelaye\BioPHP\Domain\Cloning\ValueObject\Fea...
- MAX_LINE_LENGTH : mixed = 79
- REGULATORY_CLASS_BY_FEATURE_TYPE : array<string, string> = [\Amelaye\BioPHP\Domain\Cloning\ValueObject\Fea...
- The /regulatory_class a "regulatory" feature built from these types is written with, INSDC having deprecated the "promoter" and "terminator" keys on 15-DEC-2014.
Methods
- write() : string
- locationSignature() : string
- wrap() : string
- Writes a text over as many lines of at most 79 characters as it needs, the first opening on $sPrefix, the next ones indented as deep. Lines break at blanks ; a word longer than a whole line is cut.
- writeFeature() : string
- writeLocusLine() : string
- NCBI's fixed LOCUS columns (1-based) : name 13-28, length right-justified 30-40, "bp" 42-43, molecule type 48-53, topology 56-63. A name longer than the 16 columns it is given is written in full, the remaining fields separated by spaces, as NCBI itself does for long locus names ; ParseGenbankManager::parseLocus() reads both back, word by word.
- writeOriginBlock() : string
- writeQualifier() : string
Constants
UNSTRANDED_QUALIFIER
The qualifier marking a feature on no particular strand, which INSDC cannot write
public
mixed
UNSTRANDED_QUALIFIER
= "biophp_strand"
BASES_PER_GROUP
private
mixed
BASES_PER_GROUP
= 10
BASES_PER_LINE
private
mixed
BASES_PER_LINE
= 60
GENBANK_KEY_BY_FEATURE_TYPE
private
array<string, string>
GENBANK_KEY_BY_FEATURE_TYPE
= [\Amelaye\BioPHP\Domain\Cloning\ValueObject\FeatureType::CDS => "CDS", \Amelaye\BioPHP\Domain\Cloning\ValueObject\FeatureType::PROMOTER => "regulatory", \Amelaye\BioPHP\Domain\Cloning\ValueObject\FeatureType::TERMINATOR => "regulatory", \Amelaye\BioPHP\Domain\Cloning\ValueObject\FeatureType::ORIGIN_OF_REPLICATION => "rep_origin"]
MAX_LINE_LENGTH
private
mixed
MAX_LINE_LENGTH
= 79
REGULATORY_CLASS_BY_FEATURE_TYPE
The /regulatory_class a "regulatory" feature built from these types is written with, INSDC having deprecated the "promoter" and "terminator" keys on 15-DEC-2014.
private
array<string, string>
REGULATORY_CLASS_BY_FEATURE_TYPE
= [\Amelaye\BioPHP\Domain\Cloning\ValueObject\FeatureType::PROMOTER => "promoter", \Amelaye\BioPHP\Domain\Cloning\ValueObject\FeatureType::TERMINATOR => "terminator"]
Methods
write()
public
write(Plasmid $oPlasmid) : string
Parameters
- $oPlasmid : Plasmid
Return values
stringlocationSignature()
private
locationSignature(PlasmidFeature $oFeature) : string
Parameters
- $oFeature : PlasmidFeature
Return values
string —What a feature shares with another one that the reader cannot tell it from
wrap()
Writes a text over as many lines of at most 79 characters as it needs, the first opening on $sPrefix, the next ones indented as deep. Lines break at blanks ; a word longer than a whole line is cut.
private
wrap(string $sPrefix, string $sText) : string
Parameters
- $sPrefix : string
-
The label or indentation opening the first line
- $sText : string
Return values
stringwriteFeature()
private
writeFeature(PlasmidFeature $oFeature, int $iLength[, bool $bSharesItsLocation = false ]) : string
Parameters
- $oFeature : PlasmidFeature
- $iLength : int
-
The plasmid length, where an origin-crossing feature wraps
- $bSharesItsLocation : bool = false
-
Another feature of the same key lies next to it, at the same place
Return values
stringwriteLocusLine()
NCBI's fixed LOCUS columns (1-based) : name 13-28, length right-justified 30-40, "bp" 42-43, molecule type 48-53, topology 56-63. A name longer than the 16 columns it is given is written in full, the remaining fields separated by spaces, as NCBI itself does for long locus names ; ParseGenbankManager::parseLocus() reads both back, word by word.
private
writeLocusLine(string $sName, int $iLength) : string
Parameters
- $sName : string
- $iLength : int
Return values
stringwriteOriginBlock()
private
writeOriginBlock(string $sSequence) : string
Parameters
- $sSequence : string
Return values
stringwriteQualifier()
private
writeQualifier(string $sQualifier, string $sValue) : string
Parameters
- $sQualifier : string
- $sValue : string