Package: evopython
evopythonevopythonis an object-oriented Python package designed for genome-scale
feature resolution from whole-genome alignment data.InstallationUsageDocumenationTestingInstallationevoythondepends on justbiopythonand can be installed withpip install evopythonUsageevopythonparses genome annotation data and whole-genome alignment data,
providing an interface for accessing the former in the context of the latter.Ensemblis a great resource for both; whole-genome alignmentMAFfiles and gene
annotationGTFfiles can
be downloaded from their FTP site, indexedhere.evopythonwas designed to support a linear, progressive form of analysis,
whereGTForBEDinstances are initialized with their respective files;these dictionary-like data structures are queried for instances of theFeatureclass; andtheseFeatureinstances are resolved from a pairwise or multiple
whole-genome alignment, represented with theMAFclass.In general, we have analyses of the form:fromevopythonimportGTF,MAFgenes=GTF("path/to/genes")wga=MAF("path/to/wga",aligned_on="species_name")forgene_nameingenes:feat=genes[gene_name]['feat']alignments=wga.get(feat)iflen(alignments)==1:# The alignment is contiguous; do something.passelse:# The alignment is discontiguous; do something else.passWe can parse any feature type in the GTF (see theGTFdescription
below) and further generate derived, secondary features with theFeatureclass's pad method (see theFeaturedescription below).For specific usage examples, see the Jupyter notebooks in theexamplesdirectory.Documentationclassevopython.GTF(gtf: str, types: tuple = tuple())A nesteddictmapping gene name to feature name to a list ofFeatureinstances; each high-level genedicthas two additional keys,attrandfeat, with the former mapping to adictwith annotated information such
as "gene_biotype" indicating whether the gene is protein-coding and the
latter mapping to the gene'sFeatureinstance.Arguments:gtf: The GTF file path.types: The feature types to parse; gene features are parsed by default.classevopython.BED(bed: str, on_name: bool = False)Adictmapping locustupleor name value toFeatureinstance; in the
former case, loci have the form(seqname, start, end, strand).Arguments:bed: The BED file path.on_name: Aboolexpressing whether name field values should be
used as keys to the features.classevopython.FeatureA stranded, genomic feature.Attributes:chrom: The chromosome name.start: The forward-mapped, 0-based, inclusive starting coordinate.end: The forward-mapped, 0-based, exclusive ending coordinate.strand: The strand, plus or minus for forward or reverse.Instance properties:is_forward: Aboolexpressing forward strand orientation.is_reverse: Aboolexpressing reverse strand orientation.Methods:locus(self, base: int = 0, strand: bool = False)Returns the locus in a generic genome browser format.Arguments:base: The coordinate system to use, 0 or 1, where the former is
half-open on the end and the latter fully closed.strand: Aboolexpressing whether to include the strand at the end
of the locus.Raises:ValueError: An invalid base was given.pad(self, pad5: int, pad3: int, center: int = 0)Pads the feature.Positive padding is tanatamount to feature extension and negative
padding to feature shrinkage; with centering, both can be used to
derive features that do not overlap the source feature.Arguments:pad5: The number of bases to add to the 5'-end of the feature.pad3: The number of bases to add to the 3'-end of the feature.center: 5, 3, or 0, indicating how to, or to not, center the padding:
passing 5 prompts 5'-centering, such that padding is applied on the 5'
coordinate; 3 likewise prompts 3'-centering; and 0, the default, prompts no
centering, such that the whole feature is padded.Returns:A new, paddedFeatureinstance.classevopython.MAFA resolver for multiple alignment formatted whole-genome alignment data.Arguments:maf_dir: The path to a directory of MAF files, each following the
naming schemechromosome_name.maf.aligned_on: The species that the chromosome names correspond to.Methods:get(self, feat: Feature, match_strand: bool = True)Finds an alignment for a feature.Arguments:feat: The feature to get an alignment for.match_strand: A bool expressing whether the alignment should match the
feature's strand; ifFalse, the alignment is mapped to the forward strand.Returns:Alistofdictsmapping species totuple, wheretuple[0]is aFeatureinstance describing the alignment's position andtuple[1]the
aligned sequence.TestingTo test feature resolution,clone the repository withgit clone https://github.com/fiszbein-lab/evopython,download the MAF files into their respective directories using the
provided FTP links;generate random test features using the command-line script,python features.py --maf path/to/maf --aligned-on species_name, wherealigned_onis the name of the species the file is indexed on
(seetests/data/meta_data.csv); andrun the test from the command line withpython -m unittest tests/test_resolution.py.