Package: alifedata-phyloinformatics-convert
alifedata-phyloinformatics-convert helps apply traditional phyloinformatics software to alife standardized dataFree software: MIT licenseDocumentation:https://alifedata-phyloinformatics-convert.readthedocs.io.UsageUseapc’sRosettaTreeinterface for flexible conversion between phylogenetic data structures and schemas.
First, create aRosettaTreeobject from any supported structure/schemaimportioimportpathlibimportalifedata_phyloinformatics_convertasapcimportanytreeimportBioimportdendropyimportete3aseteimportnetworkximportpandasimportphylotrackpynewickstr="((A,B),(C,D));"forobjin[anytree.AnyNode(),Bio.Phylo.read(io.StringIO(newickstr),"newick"),dendropy.Tree.get(data=newickstr,schema="newick"),ete.Tree(newickstr),networkx.DiGraph(),pandas.DataFrame({"id":[0],"ancestor_list":"[None]"}),# alife standardphylotrackpy.systematics.Systematics(lambdax:x),]:converter=apc.RosettaTree(obj)# from phyloinformatics schema# ... nexml and nexus also supported!converter=apc.RosettaTree.from_newick(newickstr)converter=apc.RosettaTree.from_newick(pathlib.Path("read.newick"))withopen("read.newick","r")asfp:converter=apc.RosettaTree.from_newick(fp)# from alife standard data via Pandasconverter=apc.RosettaTree(pandas.read_csv("read-alifestd.csv"))Then, convert or serialize data# ... converter created as aboveconverter.as_alife# pandas DataFrameconverter.as_biopythonconverter.as_dendropyconverter.as_eteconverter.as_networkxconverter.as_phylotrack# serialization, nexml and nexus schemata also supportedconverter.to_newick()# returns newick stringconverter.to_newick(pathlib.Path("write.newick"))# writes to pathwithopen("write.newick","w")asfp:# writes to file objectconverter.to_newick(fp)# alifestd serializationconverter.as_alife.to_csv("write-alifestd.csv",index=False)Useapc’s functional interface to convert between alife format other libraries’ tree objectsimportalifedata_phyloinformatics_convertasapcimportpandasalife_df=pandas.read_csv('alifedata.csv')# biopythontree=apc.alife_dataframe_tobiopython_tree(alife_df)frame=apc.biopython_tree_to_alife_dataframe(tree)# dendropytree=apc.alife_dataframe_to_dendropy_tree(alife_df)frame=apc.dendropy_tree_to_alife_dataframe(tree)# eteete_tree=apc.alife_dataframe_to_ete_tree(alife_df)frame=apc.ete_tree_to_alife_dataframe(tree)# networkxdigraph=apc.alife_dataframe_to_networkx_digraph(alife_df)frame=apc.networkx_digraph_to_alife_dataframe(digraph)# phylotrackpysystematics=apc.alife_dataframe_to_phylotrack_systematics(alife_df)frame=apc.phylotrack_systematics_to_alife_dataframe(systematics)# partial support is also included for,# - adjacency lists# - anytree trees# - scipy linkage matrices# ... see API documentation for detailsCommand Line InterfaceUseapc’s CLItoalifedatacommand to convert newick, nexml, and nexus data to alife standard phylogenetics dataUsage:alifedata-phyloinformatics-converttoalifedata[OPTIONS]convertstandardalifephylogenydatatophloinformaticsformatOptions:--input-fileFILENAMEphyloinformaticsdatafilepath;defaultstdin--input-schemaTEXTphyloinformaticsdataformatschema;optionsincludenewick,nexml,andnexus[required]--output-fileFILENAMEalifedatafilepath;defaultstdout--output-formatTEXTalifedatafileformat;defaultcsv--suppress-unifurcations/--keep-unifurcationsCompresssequencesofnodeswithsingledescendants--helpShowthismessageandexit.Use thefromalifedatacommand to convert to other formats from alife standard phylogenetics dataUsage:alifedata-phyloinformatics-convertfromalifedata[OPTIONS]convertphloinformaticsdatatostandardalifephylogenyformatOptions:--input-fileFILENAMEalifedatafilepath;defaultstdin--input-formatTEXTalifedatafileformat;defaultcsv--output-fileFILENAMEphyloinformaticsdatafilepath;defaultstdout--output-schemaTEXTphyloinformaticsdataformatschema;optionsincludenewick,nexml,andnexus[required]--suppress-unifurcations/--keep-unifurcationsCompresssequencesofnodeswithsingledescendants--helpShowthismessageandexit.InstallationInstall from PyPipip3installalifedata-phyloinformatics-convertCreditsBuilt using theDendroPylibrary.
This package was created withCookiecutterand theaudreyr/cookiecutter-pypackageproject template.