\
PyCogent 1.9 documentation

# The Readme

Download: | From github or follow the Quick installation using pip instructions.

## Dependencies

The toolkit requires Python 2.5.1 or greater, and Numpy 1.3 or greater. Aside from these the dependencies below are optional and the code will work as is. A C compiler, however, will allow external C module’s responsible for the likelihood and matrix exponentiation calculations to be compiled, resulting in significantly improved performance.

### Required

- Python: the language the toolkit is primarily written in, and in which the user writes control scripts.
- Numpy: This is a python module used for speeding up matrix computations. It is available as source code for *nix.
- zlib: This is a compression library which is available for all platforms and comes pre-installed on most too. If, by chance, your platform doesn’t have this installed then download the source from the zlib site and follow the install instructions, or refer to the instructions for compiling matplotlib.

Note

On some linux platforms (like Ubuntu), you must specifically install a `python-dev` package so that the Python header files required for building some external dependencies are available.

### Optional

- C compiler: This is standard on most *nix platforms. On Macos X this is available for free in the Developer tools which, if you don’t already have them, can be obtained from Apple.
- Matplotlib: used to plot several kinds of graphs related to codon usage. For installation, see these instructions for compiling matplotlib.
- Cython: This module is only necessary if you are a developer who wants to modify the *.pyx files.
- mpi4py: Message Passing Interface interface, required for parallel computation.
- SQLAlchemy and a mysql connector such as PyMySQL: These are required for the Ensembl querying code.

See the Quick installation using pip approach for how these can be grabbed using the `all` option..

## Installation

See the Quick installation using pip.

## Testing

`PyCogent/tests` contains all the tests. You can most readily run the tests using the `PyCogent/run_tests` shell script. This is done by typing:

    $ sh run_tests

which will automatically build extensions in place, set up the PYTHONPATH and run `PyCogent/tests/alltests.py`. Note that if certain optional applications are not installed this will be indicated in the output as “can’t find” or “not installed”. A “.” will be printed to screen for each test and if they all pass, you’ll see output like:

    Ran 3299 tests in 58.128s

    OK

## Tips for usage

A good IDE can greatly simplify writing control scripts. Features such as code completion and definition look-up are extremely useful. For a complete list of editors go here.

To get help on attributes of an object in python, use

    >>> dir(myalign)

to list the attributes of `myalign` or

    >>> help(myalign.writeToFile)

to figure out how to use the `myalign.writeToFile` method. Also note that the directory structure of the package is similar to the import statements required to use a module – to see the contents of `alignment.py` or `sequence.py` you need to look in the directory `cogent/core` path, to use the classes in those files you specify `cogent.core` for importing.