GffFeatureWriter
in package
implements
GffFeatureWriterInterface
The inverse of GffFeatureReader. Coordinates need no conversion : GFF3, like PlasmidFeature, is 1-based inclusive. An origin-crossing feature (start > end) is written the GFF3 way, with end = its real end + the molecule length, which therefore has to be given ; a landmark line spanning 1..length and flagged Is_circular=true is then written too (or, when a feature read in as that "region" landmark is among the features, that line is flagged instead), so GffFeatureReader can fold the feature back. Without the length, such a feature is rejected by throwing.
GFF3 requires a phase on every CDS. A CDS whose phase is unknown is written with phase 0, i.e. as starting on a complete codon, the usual assumption for a complete CDS ; any other type gets ".".
A feature read in FROM a GFF3 file carries its original "type" column in
getMetadata()["gffType"] ; that exact term is reused here so a read-then-write round trip is
lossless. A feature built some other way (hand-constructed, imported from GenBank, produced by
neighbor-joining-adjacent tooling...) has no such metadata, and FeatureType's own richer
vocabulary (INSERT, MARKER, REPORTER, TAG, RESTRICTION_SITE...) has no exact Sequence Ontology
counterpart for most of its members ; those fall back to the genuine generic SO term
"sequence_feature" rather than a plausible-looking but wrong guess.
Class GffFeatureWriter
Tags
Table of Contents
Interfaces
- GffFeatureWriterInterface
- Interface GffFeatureWriterInterface - the inverse of GffFeatureReaderInterface : serializes PlasmidFeature instances into GFF3 text.
Constants
- GENERIC_SO_TERM : mixed = "sequence_feature"
- SO_TERM_BY_FEATURE_TYPE : array<string, string> = [\Amelaye\BioPHP\Domain\Cloning\ValueObject\Fea...
Methods
- write() : string
- escapeAttributeValue() : string
- Percent-encodes the GFF3 column-9 reserved characters (and control characters that would otherwise break the one-line-per-feature format).
- formatPhase() : string
- isCircularLandmark() : bool
- True for a feature read in from GFF3 as the "region" landmark spanning the whole molecule.
- writeFeatureLine() : string
Constants
GENERIC_SO_TERM
private
mixed
GENERIC_SO_TERM
= "sequence_feature"
SO_TERM_BY_FEATURE_TYPE
private
array<string, string>
SO_TERM_BY_FEATURE_TYPE
= [\Amelaye\BioPHP\Domain\Cloning\ValueObject\FeatureType::CDS => "CDS", \Amelaye\BioPHP\Domain\Cloning\ValueObject\FeatureType::PROMOTER => "promoter", \Amelaye\BioPHP\Domain\Cloning\ValueObject\FeatureType::TERMINATOR => "terminator", \Amelaye\BioPHP\Domain\Cloning\ValueObject\FeatureType::ORIGIN_OF_REPLICATION => "origin_of_replication"]
Methods
write()
public
write(string $sSeqId, array<string|int, PlasmidFeature> $aFeatures[, int|null $iSequenceLength = null ]) : string
Parameters
- $sSeqId : string
- $aFeatures : array<string|int, PlasmidFeature>
- $iSequenceLength : int|null = null
-
Length of the circular molecule the features lie on ; required to write an origin-crossing feature, which GFF3 encodes as end + this length on a landmark flagged Is_circular=true
Return values
stringescapeAttributeValue()
Percent-encodes the GFF3 column-9 reserved characters (and control characters that would otherwise break the one-line-per-feature format).
private
escapeAttributeValue(string $sValue) : string
Parameters
- $sValue : string
Return values
stringformatPhase()
private
formatPhase(PlasmidFeature $oFeature) : string
Parameters
- $oFeature : PlasmidFeature
Return values
string —"0", "1" or "2" on a CDS (0 when unknown), "." otherwise
isCircularLandmark()
True for a feature read in from GFF3 as the "region" landmark spanning the whole molecule.
private
isCircularLandmark(PlasmidFeature $oFeature, int $iSequenceLength) : bool
Parameters
- $oFeature : PlasmidFeature
- $iSequenceLength : int
Return values
boolwriteFeatureLine()
private
writeFeatureLine(string $sSeqId, PlasmidFeature $oFeature, int|null $iSequenceLength, bool $bIsLandmark) : string
Parameters
- $sSeqId : string
- $oFeature : PlasmidFeature
- $iSequenceLength : int|null
- $bIsLandmark : bool
-
Flags the line as the circular landmark