Skip to content

Commit

Permalink
Merge 6e82c33 into 2b97849
Browse files Browse the repository at this point in the history
  • Loading branch information
dwhswenson committed Oct 5, 2017
2 parents 2b97849 + 6e82c33 commit cd1fabd
Show file tree
Hide file tree
Showing 15 changed files with 259 additions and 51 deletions.
11 changes: 11 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[report]
omit =
*/python?.?/*
*/*/tests/*
*/mdtraj/*
*/setup.py
*/version.py
exclude_lines =
pragma: no cover
def __repr__
raise NotImplementedError
32 changes: 32 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
language: python

python:
- "2.7"
- "3.4"
- "3.5"
- "3.6"
#- "3.7-dev" # need to do custom requirements install for this

env:
- MDTRAJ="release"
- MDTRAJ="dev"

matrix:
exclude: # don't run MDTRAJ dev for everything
- env: MDTRAJ="dev"
python: "3.4"
- env: MDTRAJ="dev"
python: "3.5"

install:
- source ci/pip-install/install.sh
- pip install -r ci/pip-install/testing_requirements.txt
- if [ "$MDTRAJ" = "dev" ]; then pip install --upgrade --force-reinstall -r ci/pip-install/mdtraj_dev.txt; fi
- pip list

script:
- py.test -vv --cov=contact_map

after_success:
- coveralls

1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include contact_map/tests/trajectory.pdb
43 changes: 43 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# See also:
# https://github.com/ogrisel/python-appveyor-demo/blob/master/appveyor.yml

branches:
only:
- master

max_jobs: 4

environment:
global:
CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\ci\\appveyor\\run_with_env.cmd"
PYTHONUNBUFFERED: 1

matrix:
- PYTHON: "C:\\Miniconda"
CONDA_PY: "27"
ARCH: "32"
- PYTHON: "C:\\Miniconda-x64"
CONDA_PY: "27"
ARCH: "64"
- PYTHON: "C:\\Miniconda36"
CONDA_PY: "36"
ARCH: "32"
- PYTHON: "C:\\Miniconda36-x64"
CONDA_PY: "36"
ARCH: "64"

build: false

install:
# install python
- SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%
# test python version
- "%CMD_IN_ENV% conda config --add channels omnia" # TODO: switch to conda-forge?
- "%CMD_IN_ENV% conda update -yq --all"
- "%CMD_IN_ENV% conda install -yq conda-build"
- "%CMD_IN_ENV% python --version"
- "%CMD_IN_ENV% python -c \"import struct; print(struct.calcsize('P') * 8)\""
# now we do our own install

test_script:
- "%CMD_IN_ENV% conda build --quiet ci\\conda-recipe"
51 changes: 51 additions & 0 deletions ci/appveyor/run_with_env.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
:: To build extensions for 64 bit Python 3, we need to configure environment
:: variables to use the MSVC 2010 C++ compilers from GRMSDKX_EN_DVD.iso of:
:: MS Windows SDK for Windows 7 and .NET Framework 4 (SDK v7.1)
::
:: To build extensions for 64 bit Python 2, we need to configure environment
:: variables to use the MSVC 2008 C++ compilers from GRMSDKX_EN_DVD.iso of:
:: MS Windows SDK for Windows 7 and .NET Framework 3.5 (SDK v7.0)
::
:: 32 bit builds do not require specific environment configurations.
::
:: Note: this script needs to be run with the /E:ON and /V:ON flags for the
:: cmd interpreter, at least for (SDK v7.0)
::
:: More details at:
:: https://github.com/cython/cython/wiki/64BitCythonExtensionsOnWindows
:: http://stackoverflow.com/a/13751649/163740
::
:: Author: Olivier Grisel
:: License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/

:: Modified for use with conda environment variables
:: Taken from mdtraj

@ECHO OFF

SET COMMAND_TO_RUN=%*
SET WIN_SDK_ROOT=C:\Program Files\Microsoft SDKs\Windows

SET MAJOR_PYTHON_VERSION="%CONDA_PY:~0,1%"
IF %MAJOR_PYTHON_VERSION% == "2" (
SET WINDOWS_SDK_VERSION="v7.0"
) ELSE IF %MAJOR_PYTHON_VERSION% == "3" (
SET WINDOWS_SDK_VERSION="v7.1"
) ELSE (
ECHO Unsupported Python version: "%MAJOR_PYTHON_VERSION%"
EXIT 1
)

IF "%ARCH%"=="64" (
ECHO Configuring Windows SDK %WINDOWS_SDK_VERSION% for Python %MAJOR_PYTHON_VERSION% on a 64 bit architecture
SET DISTUTILS_USE_SDK=1
SET MSSdk=1
"%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Setup\WindowsSdkVer.exe" -q -version:%WINDOWS_SDK_VERSION%
"%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Bin\SetEnv.cmd" /x64 /release
ECHO Executing: %COMMAND_TO_RUN%
call %COMMAND_TO_RUN% || EXIT 1
) ELSE (
ECHO Using default MSVC build environment for 32 bit architecture
ECHO Executing: %COMMAND_TO_RUN%
call %COMMAND_TO_RUN% || EXIT 1
)
47 changes: 47 additions & 0 deletions ci/conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package:
name: contact_map
version: "0.1.0"

source:
path: ../../

build:
preserve_egg_dir: True
number: 0
script: python setup.py install --single-version-externally-managed --record record.txt

requirements:
build:
- python
- setuptools
- mdtraj
- numpy
- scipy
- pandas

run:
- python
- mdtraj
- numpy
- scipy
- pandas

test:
requires:
- pytest
#- pytest-cov
#- python-coveralls

source_files:
- contact_map/tests/*

imports:
- contact_map

commands:
- py.test -vv

about:
home: https://github.com/dwhswenson/contact_map
license: LGPL-2.1 or later
summary: "Contact maps based on MDTraj"
5 changes: 5 additions & 0 deletions ci/pip-install/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pip install --upgrade pip
pip install cython # may be required for numpy override?
pip install --upgrade --force-reinstall numpy # override Travis numpy
pip install -r requirements.txt
pip install .
1 change: 1 addition & 0 deletions ci/pip-install/mdtraj_dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
git+https://github.com/mdtraj/mdtraj.git
3 changes: 3 additions & 0 deletions ci/pip-install/testing_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pytest
pytest-cov
python-coveralls
4 changes: 2 additions & 2 deletions contact_map/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from contact_map import (
from .contact_map import (
ContactMap, ContactFrequency, ContactDifference
)

from min_dist import NearestAtoms, MinimumDistanceCounter
from .min_dist import NearestAtoms, MinimumDistanceCounter

# import concurrence
13 changes: 7 additions & 6 deletions contact_map/contact_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,17 @@ def save_to_file(self, filename, mode="w"):
filename : string
the file to write to
mode : 'w' or 'a'
file writing mode. Use 'w' to overwrite, 'a' to append.
file writing mode. Use 'w' to overwrite, 'a' to append. Note
that writing by bytes ('b' flag) is automatically added.
"""
f = open(filename, mode)
pickle.dump(self, f)
f.close()
with open(filename, mode+"b") as f:
pickle.dump(self, f)

@classmethod
def from_file(cls, filename):
f = open(filename, "r")
return pickle.load(f)
with open(filename, "rb") as f:
reloaded = pickle.load(f)
return reloaded

def __sub__(self, other):
return ContactDifference(positive=self, negative=other)
Expand Down
3 changes: 2 additions & 1 deletion contact_map/tests/test_contact_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
import numpy as np
from numpy.testing import assert_array_equal
import mdtraj as md
from .utils import *

# stuff to be testing in this file
from contact_map.contact_map import *

traj = md.load("./trajectory.pdb")
traj = md.load(test_file("trajectory.pdb"))

traj_atom_contact_count = {
frozenset([0, 8]): 1,
Expand Down
6 changes: 6 additions & 0 deletions contact_map/tests/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import os
from pkg_resources import resource_filename

def test_file(fname):
return resource_filename('contact_map', os.path.join('tests', fname))

5 changes: 5 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
future
numpy
scipy
pandas
mdtraj
85 changes: 43 additions & 42 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,20 @@

##########################
VERSION = "0.1.0"
ISRELEASED = True
ISRELEASED = False
__version__ = VERSION
PACKAGE_VERSION = VERSION
REQUIREMENTS=['future', 'numpy', 'mdtraj', 'scipy', 'pandas']
##########################

DESCRIPTION="""
Contact maps based on MDTraj; useful for studying for intramolecular and
intermolecular contacts from simulations of biomolecular systems. For a
more detailed description, see package's documentation.
"""
if os.path.isfile('README.rst'):
DESCRIPTION = open('README.rst').read()

################################################################################
# Writing version control information to the module
################################################################################
Expand Down Expand Up @@ -84,46 +94,37 @@ def write_version_py(filename='contact_map/version.py'):

write_version_py()

def buildKeywordDictionary():
# from distutils.core import Extension
setupKeywords = {}
setupKeywords["name"] = "contact_map"
setupKeywords["version"] = "0.1.0"
setupKeywords["author"] = "David W.H. Swenson"
setupKeywords["author_email"] = "dwhs@hyperblazer.net"
setupKeywords["license"] = "LGPL 2.1 of greater"
setupKeywords["download_url"] = "http://github.com/dwhswenson/contact_map"
setupKeywords["packages"] = ['contact_map',
'contact_map.tests']
setupKeywords["package_dir"] = {
'contact_map' : 'contact_map',
'contact_map.tests' : 'contact_map/tests'
}
setupKeywords["data_files"] = []
setupKeywords["ext_modules"] = []
setupKeywords["platforms"] = ["Linux", "Mac OS X", "Windows"]
setupKeywords["description"] = "MDTraj-based contact maps"
setupKeywords["requires"] = ["mdtraj", "nose"]
setupKeywords["long_description"] = """Blah
"""
outputString=""
firstTab = 40
secondTab = 60
for key in sorted( setupKeywords.iterkeys() ):
value = setupKeywords[key]
outputString += (key.rjust(firstTab)
+ str(value).rjust(secondTab) + "\n")

print("%s" % outputString)

return setupKeywords


def main():
setupKeywords = buildKeywordDictionary()
setup(**setupKeywords)

if __name__ == '__main__':
main()
setup(
name="contact_map",
author="David W.H. Swenson",
author_email="dwhs@hyperblazer.net",
version=PACKAGE_VERSION,
license="LGPL",
url="http//github.com/dwhswenson/contact_map",
packages=['contact_map', 'contact_map.tests'],
package_dir= {
'contact_map': 'contact_map',
'contact_map.tests': 'contact_map/tests'
},
package_data={'contact_map.tests': ['contact_map/tests/*pdb']},
ext_modules=[],
scripts=[],
long_description=DESCRIPTION,
platforms=['Linux', 'Mac OS X', 'Unix', 'Windows'],
install_requires=REQUIREMENTS,
requires=REQUIREMENTS,
tests_require=["pytest", "pytest-cov", "python-coveralls"],
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)',
'Operating System :: POSIX',
'Operating System :: Microsoft :: Windows',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Topic :: Scientific/Engineering :: Bio-Informatics',
'Topic :: Scientific/Engineering :: Chemistry'
]
)


0 comments on commit cd1fabd

Please sign in to comment.