Skip to content

Commit

Permalink
Merge pull request #6 from jmenglund/develop
Browse files Browse the repository at this point in the history
Update docs and testing
  • Loading branch information
jmenglund authored Aug 8, 2016
2 parents be154ae + 5a99163 commit 1f0e560
Show file tree
Hide file tree
Showing 9 changed files with 127 additions and 82 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@ language: python

python:
- '2.7'
- '3.3'
- '3.4'
- '3.5'

# whitelist
branches:
only:
- master

script:
py.test --cov=pandascharm.py
py.test --cov=pandascharm.py --pep8

after_success:
- codecov
40 changes: 28 additions & 12 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,29 +1,45 @@
Changelog
=========

0.1.0
0.1.2
-----

Initial release.

Includes the following functions:
* Added Python versions for Travis-CI (3.3, 3.5)
* Added ``pep8`` check to Travis-CI
* Updates to *README.rst*
- Fixed issue with one example not working (``pc.to_charmatrix()``)
- Updated text in various places
* Updates to *release-checklist.rst*

* frame_as_categorical()
* frame_as_object()
* from_bioalignment()
* from_charmatrix()
* to_bioalignment()
* to_charmatrix()
Release date: 2016-08-08

Release date: 2016-07-05
`View commits <https://github.com/jmenglund/pandas-charm/compare/v0.1.1...v0.1.2>`_


0.1.1
-----

* Simplified builds with Travis-CI.
* DOI badge added to the top of *README.rst*.
* Information on how to cite pandas-charm added to *README.rst*.
* Information on how to cite ``pandas-charm`` added to *README.rst*.

Release date: 2016-07-05

`View commits <https://github.com/jmenglund/pandas-charm/compare/v0.1.0...v0.1.1>`_


0.1.0
-----

Initial release.

Includes the following functions:

* ``frame_as_categorical()``
* ``frame_as_object()``
* ``from_bioalignment()``
* ``from_charmatrix()``
* ``to_bioalignment()``
* ``to_charmatrix()``

Release date: 2016-07-05
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015 Markus Englund
Copyright (c) 2016 Markus Englund

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
115 changes: 66 additions & 49 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,41 +1,29 @@
pandas-charm
============

.. image:: https://travis-ci.org/jmenglund/pandas-charm.svg?branch=master
:target: https://travis-ci.org/jmenglund/pandas-charm
|Build-Status| |Coverage-Status| |PyPI-Status| |License| |DOI-URI|

.. image:: https://codecov.io/gh/jmenglund/pandas-charm/branch/master/graph/badge.svg
:target: https://codecov.io/gh/jmenglund/pandas-charm

.. image:: https://img.shields.io/badge/license-MIT-blue.svg
:target: https://opensource.org/licenses/MIT

.. image:: https://zenodo.org/badge/23107/jmenglund/pandas-charm.svg
:target: https://zenodo.org/badge/latestdoi/23107/jmenglund/pandas-charm

|
pandas-charm is a small Python package (or library) for getting character
``pandas-charm`` is a small Python package for getting character
matrices (alignments) into and out of `pandas <http://pandas.pydata.org>`_.
The intention of the package is to make pandas interoperable with
other scientific packages that can be used for working with character
matrices, like for example `BioPython <http://biopython.org>`_ and
`Dendropy <http://dendropy.org>`_.
Its purpose is to make pandas interoperable with other scientific
packages that can be used for dealing with character matrices, like for example
`BioPython <http://biopython.org>`_ and `Dendropy <http://dendropy.org>`_.

With pandas-charm, it is currently possible to convert between the
With ``pandas-charm``, it is currently possible to convert between the
following objects:

* BioPython MultipleSeqAlignment <-> pandas DataFrame
* DendroPy CharacterMatrix <-> pandas DataFrame

Source repository: `<https://github.com/jmenglund/pandas-charm>`_
The code has been tested with Python 2.7, 3.3, 3.4 and 3.5.

Source repository: `<https://github.com/jmenglund/pandas-charm>`_

The name
--------
------------------------------------------

pandas-charm got its name from the pandas library plus an acronym for
CHARacter Matrix.
.. contents:: Table of contents
:backlinks: top
:local:


Installation
Expand All @@ -49,7 +37,7 @@ hosted on `PyPI <https://pypi.python.org/>`_:
$ pip install pandas-charm
The project is hosted at https://github.com/jmenglund/pandas-charm and
can be installed using git:
can also be installed using git:

.. code-block::
Expand All @@ -58,25 +46,30 @@ can be installed using git:
$ python setup.py install
You may consider installing ``pandas-charm`` and its required Python packages
within a virtual environment in order to avoid cluttering your system's
Python path. See for example the environment management system
`conda <http://conda.pydata.org>`_ or the package
`virtualenv <https://virtualenv.pypa.io/en/latest/>`_.


Running tests
-------------

After installing the pandas-charm, you may want to check that everything
works as expected. Below is an example of how to run the tests with pytest.
The packages BioPython, DendroPy, pytest, coverage, and pytest-cov need
to be installed.
Testing is carried out with `pytest <http://pytest.org>`_. Here is an
example on how to run the test suite and generating a coverage report:

.. code-block::
$ cd pandas-charm
$ py.test -v --cov-report term-missing --cov pandascharm.py
$ pip install pytest pytest-cov pytest-pep8 dendropy biopython
$ py.test -v --cov-report term-missing --cov pandascharm.py --pep8
Usage
-----

Below are a few examples on how to use pandas-charm. The examples are
written with Python 3 code, but pandas-charm should work also with
written with Python 3 code, but ``pandas-charm`` should work also with
Python 2.7. You need to install BioPython and/or DendroPy manually
before you start:

Expand All @@ -86,8 +79,8 @@ before you start:
$ pip install dendropy
Converting a DendroPy CharacterMatrix to a pandas DataFrame
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DendroPy CharacterMatrix to pandas DataFrame
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: pycon
Expand All @@ -112,9 +105,9 @@ Converting a DendroPy CharacterMatrix to a pandas DataFrame
3 A A A
4 A A A
As seen above, characters are stored as rows and sequences as
columns in the DataFrame. If you want rows to hold sequences,
it is easy to transpose the matrix in pandas:
By default, characters are stored as rows and sequences as columns
in the DataFrame. If you want rows to hold sequences, just transpose
the matrix in pandas:

.. code-block:: pycon
Expand All @@ -125,8 +118,8 @@ it is easy to transpose the matrix in pandas:
t3 T G - A A
Converting a pandas DataFrame to a Dendropy CharacterMatrix
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pandas DataFrame to Dendropy CharacterMatrix
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: pycon
Expand All @@ -145,16 +138,16 @@ Converting a pandas DataFrame to a Dendropy CharacterMatrix
3 A A A
4 A A A
>>> matrix = pc.to_charmatrix(df, type='dna')
>>> matrix = pc.to_charmatrix(df, data_type='dna')
>>> print(matrix.as_string('phylip'))
3 5
t1 TCCAA
t2 TGCAA
t3 TG-AA
Converting a BioPython MultipleSeqAlignment to a pandas DataFrame
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BioPython MultipleSeqAlignment to pandas DataFrame
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: pycon
Expand All @@ -180,8 +173,8 @@ Converting a BioPython MultipleSeqAlignment to a pandas DataFrame
4 A A A
Converting a pandas DataFrame to a BioPython MultipleSeqAlignment
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pandas DataFrame to BioPython MultipleSeqAlignment
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: pycon
Expand All @@ -208,11 +201,19 @@ Converting a pandas DataFrame to a BioPython MultipleSeqAlignment
TG-AA t3
The name
--------

``pandas-charm`` got its name from the pandas library plus an acronym for
CHARacter Matrix.


License
-------

pandas-charm is distributed under
`the MIT license <https://opensource.org/licenses/MIT>`_.
``pandas-charm`` is distributed under the
`MIT license <https://opensource.org/licenses/MIT>`_.


Citing
Expand All @@ -222,8 +223,24 @@ If you use results produced with this package in a scientific
publication, please just mention the package name in the text and
cite the Zenodo DOI of this project:

.. image:: https://zenodo.org/badge/23107/jmenglund/pandas-charm.svg
:target: https://zenodo.org/badge/latestdoi/23107/jmenglund/pandas-charm
|DOI-URI|

You can select a citation style from the dropdown menu in the
*"Cite as"* section on the Zenodo page.
"Cite as" section on the Zenodo page.


Author
------

Markus Englund, `orcid.org/0000-0003-1688-7112 <http://orcid.org/0000-0003-1688-7112>`_

.. |Build-Status| image:: https://travis-ci.org/jmenglund/pandas-charm.svg?branch=master
:target: https://travis-ci.org/jmenglund/pandas-charm
.. |Coverage-Status| image:: https://codecov.io/gh/jmenglund/pandas-charm/branch/master/graph/badge.svg
:target: https://codecov.io/gh/jmenglund/pandas-charm
.. |PyPI-Status| image:: https://img.shields.io/pypi/v/pandas-charm.svg
:target: https://pypi.python.org/pypi/pandas-charm
.. |License| image:: https://img.shields.io/pypi/l/pandas-charm.svg
:target: https://raw.githubusercontent.com/jmenglund/pandas-charm/master/LICENSE.txt
.. |DOI-URI| image:: https://zenodo.org/badge/23107/jmenglund/pandas-charm.svg
:target: https://zenodo.org/badge/latestdoi/23107/jmenglund/pandas-charm
8 changes: 4 additions & 4 deletions pandascharm.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

__authors__ = 'Markus Englund'
__license__ = 'MIT'
__version__ = '0.1.1'
__version__ = '0.1.2'


def frame_as_categorical(frame, include_categories=None):
Expand Down Expand Up @@ -97,15 +97,15 @@ def to_bioalignment(frame, alphabet='generic_alphabet'):
if alphabet not in [
'generic_alphabet', 'generic_dna',
'generic_nucleotide', 'generic_protein', 'generic_rna']:
raise ValueError( # pragma: no cover
raise ValueError(
'Invalid BioPython alphabet: {}'
.format(alphabet))
try:
import Bio.Alphabet
from Bio.AlignIO import MultipleSeqAlignment
from Bio.Seq import Seq
from Bio.SeqRecord import SeqRecord
except ImportError as ex: # pragma: no cover
except ImportError as ex:
raise ImportError(
'\'to_bioalignment\' requires BioPython.\n{ex}'.format(ex=str(ex)))
alignment = MultipleSeqAlignment([])
Expand All @@ -131,7 +131,7 @@ def to_charmatrix(frame, data_type):
"""
try:
import dendropy
except ImportError as ex: # pragma: no cover
except ImportError as ex:
raise ImportError(
'\'to_charmatrix\' requires DendroPy.\n{ex}'.format(ex=str(ex)))
d = frame.apply(lambda x: ''.join(x), axis=0).to_dict()
Expand Down
14 changes: 9 additions & 5 deletions release-checklist.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,30 @@ Release checklist

Things to remember when making a new release of pandas-charm.

#. Changes should be made to some branch other than master (a pull request
should then be created before making the release).
#. Changes should be made to some branch other than master (a pull request should then be created before making the release).

#. Update the release (version) numbers in *setup.py* and *pandascharm.py*.

#. Make desirable changes to the code.

#. Check coding style with pep8.
#. Run tests with coverage report and PEP8 check:

.. code-block::
$ py.test -v --cov-report term-missing --cov predsim.py --pep8
#. Update the documentation in *README.rst*.

#. Update *CHANGELOG.rst*.

#. Create pull request(s) with changes for the new release.

#. Create the release in GitHub.
#. Create the new release in GitHub.

#. Create distributions and upload the files to PyPI.
#. Create distributions and upload the files to `PyPI <https://pypi.python.org/pypi>`_.

.. code-block::
$ python setup.py bdist_wheel --universal
$ python setup.py sdist
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pandas>=0.16
pytest>=2.8
codecov
pytest-pep8
pytest-cov
DendroPy>=4.0
BioPython
Loading

0 comments on commit 1f0e560

Please sign in to comment.