Package: perseuspy
perseuspy READMEThis repository contains the source code of theperseuspysoftware package.perseuspycontains convenience functions which allow for faster and easier development
of plugins forPerseusin the Python programming language.
This page contains installation instructions and developer information onperseuspy, for high-level information please
refer to the manuscript listed below.perseuspywas designed to work in conjunction with thePluginInteropplugin, but can also be used stand-alone.CitationIf you useperseuspyin your projects, please citeRudolph, J D and Cox, J 2018,A network module for the Perseus software for computational proteomics facilitates proteome interaction graph analysisdoi:10.1101/447268.Installationperseuspycan be installed directly frompip. If you are new to Python, more detailed installation instructions for windows are provided below.pipinstallperseuspyDeveloping pluginsPerseus provides activities to call Python scripts from within the workflow viaPluginInterop, e.g.Matrix => Python.
Developing a plugin therefore translates to writing a Python script that follows
a small set of conventions. By adhering to these conventions, Perseus will be
able to successfully communicate with R and transfer inputs and results between
the programs.perseuspyprovides the neccessary functions to make plugin development
in Python easy and straight forward.Matrix pluginThis example Python script extracts the first 15 rows from the matrix. While its functionality
is very simple. It can serve as a starting point for more extensive scripts.importsysfromperseuspyimportpdfromperseuspy.parametersimport*_,infile,outfile=sys.argv# read arguments from the command linedf=pd.read_perseus(infile)# read the input matrix into a pandas.DataFramedf2=df.head(15)# keep only the first 15 rows of the tabledf2.to_perseus(outfile)# write pandas.DataFrame in Perseus txt formatNetwork pluginThe following snippet can be used as a starting point for network analyses.importsysfromperseuspyimportnx,pd,read_networks,write_networks_,infolder,outfolder=sys.argv# read arguments from the command linenetworks_table,networks=read_networks(infolder)# networks in tabular formgraphs=nx.from_perseus(networks_table,networks)# graphs as networkx objects# perform some analysis_networks_table,_networks=nx.to_perseus(graphs)# convert back into tabular formwrite_networks(tmp_dir,networks_table,networks)# write to folderUpdating to the latest versionpipinstall--upgradeperseuspyInstallation (Windows long)First open a terminal by searching forcmd.exein the start menu. Here we can easily
check if all required programs are installed.Check to see if thepipexecutable is already available.pip install perseuspyIf there is no error you are already done. If it fails, continue with the next steps.Navigate to the installation directory of your Python installation. If it is installed
e.g.D:/Programs/Python/we would first change the drive letter (maybe unnecessary)
and then go to the installation directory.D:
cd Programs/PythonNow we should be able to runpythonfrom the command line.python.exe --versionThis should print the installed version of pythonNavigate to theScriptsdirectory and run the installationcd Scripts
pip install perseuspyIf you want to upgrade you installation, runpip install --upgrade perseuspyTest the installation by navigating back to the Python folder and trying to importperseuspy.cd ..
python.exeNow you should be inside thepythoninterpreter. Check the installation by running.import perseuspyIf the command doesn’t produce any error you can exitpythonby pressingCTRL+c.Addpythonto yourPATH(optional, recommended). Makes it easier for Perseus to find the Python
installation. There are many resources on how to add programs to thePATHavailable online. No description
is provided here since instructions are specific to the version of Windows that is used.UsageYou can useperseuspyjust like any other python module.# import a monkey-patched version of pandasfromperseuspyimportpddf=pd.read_perseus('matrix1.txt')df2=df.dropna()df2.to_perseus('matrix2.txt')Generating the developer documentationRun./generate_docs.shfrombash.Licensing and Contributionsperseuspyis licensed under the MIT lisence.
Contributions are welcome! If you are interested in contributing to code or documentation,
please readCONTRIBUTING.rst.