Skip to content

Commit 1f0e560

Browse files
authoredAug 8, 2016
Merge pull request #6 from jmenglund/develop
Update docs and testing
2 parents be154ae + 5a99163 commit 1f0e560

9 files changed

+127
-82
lines changed
 

‎.travis.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@ language: python
22

33
python:
44
- '2.7'
5+
- '3.3'
56
- '3.4'
7+
- '3.5'
68

79
# whitelist
810
branches:
911
only:
1012
- master
1113

1214
script:
13-
py.test --cov=pandascharm.py
15+
py.test --cov=pandascharm.py --pep8
1416

1517
after_success:
1618
- codecov

‎CHANGELOG.rst

+28-12
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,45 @@
11
Changelog
22
=========
33

4-
0.1.0
4+
0.1.2
55
-----
66

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

11-
* frame_as_categorical()
12-
* frame_as_object()
13-
* from_bioalignment()
14-
* from_charmatrix()
15-
* to_bioalignment()
16-
* to_charmatrix()
14+
Release date: 2016-08-08
1715

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

2018

2119
0.1.1
2220
-----
2321

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

2826
Release date: 2016-07-05
2927

28+
`View commits <https://github.com/jmenglund/pandas-charm/compare/v0.1.0...v0.1.1>`_
29+
30+
31+
0.1.0
32+
-----
33+
34+
Initial release.
35+
36+
Includes the following functions:
37+
38+
* ``frame_as_categorical()``
39+
* ``frame_as_object()``
40+
* ``from_bioalignment()``
41+
* ``from_charmatrix()``
42+
* ``to_bioalignment()``
43+
* ``to_charmatrix()``
44+
45+
Release date: 2016-07-05

‎LICENSE.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2015 Markus Englund
3+
Copyright (c) 2016 Markus Englund
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

‎README.rst

+66-49
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,29 @@
11
pandas-charm
22
============
33

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

7-
.. image:: https://codecov.io/gh/jmenglund/pandas-charm/branch/master/graph/badge.svg
8-
:target: https://codecov.io/gh/jmenglund/pandas-charm
9-
10-
.. image:: https://img.shields.io/badge/license-MIT-blue.svg
11-
:target: https://opensource.org/licenses/MIT
12-
13-
.. image:: https://zenodo.org/badge/23107/jmenglund/pandas-charm.svg
14-
:target: https://zenodo.org/badge/latestdoi/23107/jmenglund/pandas-charm
15-
16-
|
17-
18-
pandas-charm is a small Python package (or library) for getting character
6+
``pandas-charm`` is a small Python package for getting character
197
matrices (alignments) into and out of `pandas <http://pandas.pydata.org>`_.
20-
The intention of the package is to make pandas interoperable with
21-
other scientific packages that can be used for working with character
22-
matrices, like for example `BioPython <http://biopython.org>`_ and
23-
`Dendropy <http://dendropy.org>`_.
8+
Its purpose is to make pandas interoperable with other scientific
9+
packages that can be used for dealing with character matrices, like for example
10+
`BioPython <http://biopython.org>`_ and `Dendropy <http://dendropy.org>`_.
2411

25-
With pandas-charm, it is currently possible to convert between the
12+
With ``pandas-charm``, it is currently possible to convert between the
2613
following objects:
2714

2815
* BioPython MultipleSeqAlignment <-> pandas DataFrame
2916
* DendroPy CharacterMatrix <-> pandas DataFrame
3017

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

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

34-
The name
35-
--------
22+
------------------------------------------
3623

37-
pandas-charm got its name from the pandas library plus an acronym for
38-
CHARacter Matrix.
24+
.. contents:: Table of contents
25+
:backlinks: top
26+
:local:
3927

4028

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

5442
.. code-block::
5543
@@ -58,25 +46,30 @@ can be installed using git:
5846
$ python setup.py install
5947
6048
49+
You may consider installing ``pandas-charm`` and its required Python packages
50+
within a virtual environment in order to avoid cluttering your system's
51+
Python path. See for example the environment management system
52+
`conda <http://conda.pydata.org>`_ or the package
53+
`virtualenv <https://virtualenv.pypa.io/en/latest/>`_.
54+
55+
6156
Running tests
6257
-------------
6358

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

6962
.. code-block::
7063
71-
$ cd pandas-charm
72-
$ py.test -v --cov-report term-missing --cov pandascharm.py
64+
$ pip install pytest pytest-cov pytest-pep8 dendropy biopython
65+
$ py.test -v --cov-report term-missing --cov pandascharm.py --pep8
7366
7467
7568
Usage
7669
-----
7770

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

@@ -86,8 +79,8 @@ before you start:
8679
$ pip install dendropy
8780
8881
89-
Converting a DendroPy CharacterMatrix to a pandas DataFrame
90-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
82+
DendroPy CharacterMatrix to pandas DataFrame
83+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9184

9285
.. code-block:: pycon
9386
@@ -112,9 +105,9 @@ Converting a DendroPy CharacterMatrix to a pandas DataFrame
112105
3 A A A
113106
4 A A A
114107
115-
As seen above, characters are stored as rows and sequences as
116-
columns in the DataFrame. If you want rows to hold sequences,
117-
it is easy to transpose the matrix in pandas:
108+
By default, characters are stored as rows and sequences as columns
109+
in the DataFrame. If you want rows to hold sequences, just transpose
110+
the matrix in pandas:
118111

119112
.. code-block:: pycon
120113
@@ -125,8 +118,8 @@ it is easy to transpose the matrix in pandas:
125118
t3 T G - A A
126119
127120
128-
Converting a pandas DataFrame to a Dendropy CharacterMatrix
129-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
121+
pandas DataFrame to Dendropy CharacterMatrix
122+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
130123

131124
.. code-block:: pycon
132125
@@ -145,16 +138,16 @@ Converting a pandas DataFrame to a Dendropy CharacterMatrix
145138
3 A A A
146139
4 A A A
147140
148-
>>> matrix = pc.to_charmatrix(df, type='dna')
141+
>>> matrix = pc.to_charmatrix(df, data_type='dna')
149142
>>> print(matrix.as_string('phylip'))
150143
3 5
151144
t1 TCCAA
152145
t2 TGCAA
153146
t3 TG-AA
154147
155148
156-
Converting a BioPython MultipleSeqAlignment to a pandas DataFrame
157-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
149+
BioPython MultipleSeqAlignment to pandas DataFrame
150+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
158151

159152
.. code-block:: pycon
160153
@@ -180,8 +173,8 @@ Converting a BioPython MultipleSeqAlignment to a pandas DataFrame
180173
4 A A A
181174
182175
183-
Converting a pandas DataFrame to a BioPython MultipleSeqAlignment
184-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
176+
pandas DataFrame to BioPython MultipleSeqAlignment
177+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
185178

186179
.. code-block:: pycon
187180
@@ -208,11 +201,19 @@ Converting a pandas DataFrame to a BioPython MultipleSeqAlignment
208201
TG-AA t3
209202
210203
204+
205+
The name
206+
--------
207+
208+
``pandas-charm`` got its name from the pandas library plus an acronym for
209+
CHARacter Matrix.
210+
211+
211212
License
212213
-------
213214

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

217218

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

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

228228
You can select a citation style from the dropdown menu in the
229-
*"Cite as"* section on the Zenodo page.
229+
"Cite as" section on the Zenodo page.
230+
231+
232+
Author
233+
------
234+
235+
Markus Englund, `orcid.org/0000-0003-1688-7112 <http://orcid.org/0000-0003-1688-7112>`_
236+
237+
.. |Build-Status| image:: https://travis-ci.org/jmenglund/pandas-charm.svg?branch=master
238+
:target: https://travis-ci.org/jmenglund/pandas-charm
239+
.. |Coverage-Status| image:: https://codecov.io/gh/jmenglund/pandas-charm/branch/master/graph/badge.svg
240+
:target: https://codecov.io/gh/jmenglund/pandas-charm
241+
.. |PyPI-Status| image:: https://img.shields.io/pypi/v/pandas-charm.svg
242+
:target: https://pypi.python.org/pypi/pandas-charm
243+
.. |License| image:: https://img.shields.io/pypi/l/pandas-charm.svg
244+
:target: https://raw.githubusercontent.com/jmenglund/pandas-charm/master/LICENSE.txt
245+
.. |DOI-URI| image:: https://zenodo.org/badge/23107/jmenglund/pandas-charm.svg
246+
:target: https://zenodo.org/badge/latestdoi/23107/jmenglund/pandas-charm

‎pandascharm.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
__authors__ = 'Markus Englund'
88
__license__ = 'MIT'
9-
__version__ = '0.1.1'
9+
__version__ = '0.1.2'
1010

1111

1212
def frame_as_categorical(frame, include_categories=None):
@@ -97,15 +97,15 @@ def to_bioalignment(frame, alphabet='generic_alphabet'):
9797
if alphabet not in [
9898
'generic_alphabet', 'generic_dna',
9999
'generic_nucleotide', 'generic_protein', 'generic_rna']:
100-
raise ValueError( # pragma: no cover
100+
raise ValueError(
101101
'Invalid BioPython alphabet: {}'
102102
.format(alphabet))
103103
try:
104104
import Bio.Alphabet
105105
from Bio.AlignIO import MultipleSeqAlignment
106106
from Bio.Seq import Seq
107107
from Bio.SeqRecord import SeqRecord
108-
except ImportError as ex: # pragma: no cover
108+
except ImportError as ex:
109109
raise ImportError(
110110
'\'to_bioalignment\' requires BioPython.\n{ex}'.format(ex=str(ex)))
111111
alignment = MultipleSeqAlignment([])
@@ -131,7 +131,7 @@ def to_charmatrix(frame, data_type):
131131
"""
132132
try:
133133
import dendropy
134-
except ImportError as ex: # pragma: no cover
134+
except ImportError as ex:
135135
raise ImportError(
136136
'\'to_charmatrix\' requires DendroPy.\n{ex}'.format(ex=str(ex)))
137137
d = frame.apply(lambda x: ''.join(x), axis=0).to_dict()

‎release-checklist.rst

+9-5
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,30 @@ Release checklist
33

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

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

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

1110
#. Make desirable changes to the code.
1211

13-
#. Check coding style with pep8.
12+
#. Run tests with coverage report and PEP8 check:
13+
14+
.. code-block::
15+
16+
$ py.test -v --cov-report term-missing --cov predsim.py --pep8
1417
1518
#. Update the documentation in *README.rst*.
1619

1720
#. Update *CHANGELOG.rst*.
1821

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

21-
#. Create the release in GitHub.
24+
#. Create the new release in GitHub.
2225

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

2528
.. code-block::
2629
2730
$ python setup.py bdist_wheel --universal
2831
$ python setup.py sdist
32+

‎requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
pandas>=0.16
22
pytest>=2.8
33
codecov
4+
pytest-pep8
45
pytest-cov
56
DendroPy>=4.0
67
BioPython

‎setup.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
setup(
1010
name='pandas-charm',
11-
version='0.1.1',
11+
version='0.1.2',
1212
description=(
1313
'A small Python library for getting character matrices '
1414
'(alignments) into and out of pandas'),
@@ -32,7 +32,9 @@
3232
'Programming Language :: Python :: 2',
3333
'Programming Language :: Python :: 2.7',
3434
'Programming Language :: Python :: 3',
35-
'Programming Language :: Python :: 3.4'
35+
'Programming Language :: Python :: 3.3',
36+
'Programming Language :: Python :: 3.4',
37+
'Programming Language :: Python :: 3.5',
3638
],
3739
keywords=['alignment', 'BioPython', 'DendroPy', 'pandas'],
3840
)

‎test_pandascharm.py

+11-8
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ def test_conversion(self):
7272
assert_frame_equal(frame_as_object(self.frame_cat), self.frame_obj)
7373

7474

75-
7675
class TestCharmatrixConversion():
7776

7877
dna_charmatrix_string = '3 5\nt1 TCCAA\nt2 TGCAA\nt3 TG-AA\n'
@@ -108,11 +107,11 @@ class TestCharmatrixConversion():
108107
't3': ['0', '2', '-', '1', '0']}, dtype='category')
109108

110109
def test_from_charmatrix_dna(self):
111-
assert_frame_equal (
110+
assert_frame_equal(
112111
from_charmatrix(self.dna_charmatrix), self.dna_frame)
113-
112+
114113
def test_from_charmatrix_dna_object(self):
115-
assert_frame_equal (
114+
assert_frame_equal(
116115
from_charmatrix(self.dna_charmatrix, categorical=False),
117116
frame_as_object(self.dna_frame))
118117

@@ -122,7 +121,7 @@ def test_to_charmatrix_dna(self):
122121
.as_string('phylip') == self.dna_charmatrix.as_string('phylip'))
123122

124123
def test_from_charmatrix_rna(self):
125-
assert_frame_equal (
124+
assert_frame_equal(
126125
from_charmatrix(self.rna_charmatrix), self.rna_frame)
127126

128127
def test_to_charmatrix_rna(self):
@@ -131,7 +130,7 @@ def test_to_charmatrix_rna(self):
131130
.as_string('phylip') == self.rna_charmatrix.as_string('phylip'))
132131

133132
def test_from_charmatrix_protein(self):
134-
assert_frame_equal (
133+
assert_frame_equal(
135134
from_charmatrix(self.protein_charmatrix), self.protein_frame)
136135

137136
def test_to_charmatrix_protein(self):
@@ -141,7 +140,7 @@ def test_to_charmatrix_protein(self):
141140
.as_string('phylip'))
142141

143142
def test_from_charmatrix_standard(self):
144-
assert_frame_equal (
143+
assert_frame_equal(
145144
from_charmatrix(self.standard_charmatrix), self.standard_frame)
146145

147146
def test_to_charmatrix_standard(self):
@@ -180,10 +179,14 @@ def dict_to_bioalignment(d, alphabet='generic_alphabet', sorted=True):
180179
't3': ['T', 'G', '-', 'A', 'A']}, dtype='category')
181180

182181
def test_from_bioalignment_dna(self):
183-
assert_frame_equal (
182+
assert_frame_equal(
184183
from_bioalignment(self.dna_bioalignment), self.dna_frame)
185184

186185
def test_to_bioalignment_dna(self):
187186
assert (
188187
to_bioalignment(self.dna_frame, alphabet='generic_dna')
189188
.format('phylip') == self.dna_bioalignment.format('phylip'))
189+
190+
def test_invalid_alphabet(self):
191+
with pytest.raises(ValueError):
192+
to_bioalignment(self.dna_frame, alphabet='dna')

0 commit comments

Comments
 (0)
Please sign in to comment.