Skip to content

Commit

Permalink
Merge pull request #8 from dwhswenson/codacy
Browse files Browse the repository at this point in the history
More code quality improvements
  • Loading branch information
dwhswenson authored Oct 6, 2017
2 parents c611e4a + 5890eb7 commit 46094dc
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 16 deletions.
2 changes: 0 additions & 2 deletions .bandit

This file was deleted.

5 changes: 5 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ engines:
enabled: true
exclude_paths:
- "*/tests/"
config:
threshold: "C"

fixme:
enabled: true
Expand All @@ -11,6 +13,9 @@ engines:

duplication:
enabled: true
languages:
python:
mass_threshold: 35

ratings:
paths:
Expand Down
10 changes: 7 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ python:
#- "3.7-dev" # need to do custom requirements install for this

env:
- MDTRAJ="release"
- MDTRAJ="dev"
global:
- CODECLIMATE="" # add this later
matrix:
- MDTRAJ="release"
- MDTRAJ="dev"

matrix:
exclude: # don't run MDTRAJ dev for everything
Expand All @@ -30,7 +33,8 @@ install:
- pip list

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

after_success:
- coveralls
- python-codacy-coverage -r cov.xml
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
[![Linux Build Status](https://travis-ci.org/dwhswenson/contact_map.svg?branch=master)](https://travis-ci.org/dwhswenson/contact_map)
[![Windows Build status](https://ci.appveyor.com/api/projects/status/em3fo96sjrg2vmcc/branch/master?svg=true)](https://ci.appveyor.com/project/dwhswenson/contact-map/branch/master)
[![Coverage Status](https://coveralls.io/repos/github/dwhswenson/contact_map/badge.svg?branch=master)](https://coveralls.io/github/dwhswenson/contact_map?branch=master)
[![codebeat badge](https://codebeat.co/badges/c7fb604a-35a8-4ccf-afea-18d6bd494726)](https://codebeat.co/projects/github-com-dwhswenson-contact_map-master)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/f7f3cf53698e4655ac8895f13fa5dea6)](https://www.codacy.com/app/dwhswenson/contact_map?utm_source=github.com&utm_medium=referral&utm_content=dwhswenson/contact_map&utm_campaign=Badge_Grade)
[![Code Climate](https://codeclimate.com/github/dwhswenson/contact_map/badges/gpa.svg)](https://codeclimate.com/github/dwhswenson/contact_map)

# Contact Maps

Expand Down
2 changes: 2 additions & 0 deletions bandit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
exclude_dirs:
- /tests
16 changes: 7 additions & 9 deletions contact_map/contact_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def residue_ignore_atom_idxs(self):
return result

def most_common_atoms_for_residue(self, residue):
(residue, residue_idx) = _residue_and_index(residue, self.topology)
residue = _residue_and_index(residue, self.topology)[0]
residue_atoms = set(atom.index for atom in residue.atoms)
results = []
for contact in self.atom_contacts.most_common_idx():
Expand All @@ -203,16 +203,14 @@ def most_common_atoms_for_residue(self, residue):
return results

def most_common_atoms_for_contact(self, contact_pair):
contact_pair = frozenset(contact_pair)
res_A = list(contact_pair)[0]
res_B = list(contact_pair)[1]
(res_A, res_A_idx) = _residue_and_index(res_A, self.topology)
(res_B, res_B_idx) = _residue_and_index(res_B, self.topology)
atom_idxs_A = set(atom.index for atom in res_A.atoms)
atom_idxs_B = set(atom.index for atom in res_B.atoms)
contact_pair = list(contact_pair)
res_1 = _residue_and_index(contact_pair[0], self.topology)[0]
res_2 = _residue_and_index(contact_pair[1], self.topology)[0]
atom_idxs_1 = set(atom.index for atom in res_1.atoms)
atom_idxs_2 = set(atom.index for atom in res_2.atoms)
all_atom_pairs = [
frozenset(pair)
for pair in itertools.product(atom_idxs_A, atom_idxs_B)
for pair in itertools.product(atom_idxs_1, atom_idxs_2)
]
result = [([self.topology.atom(idx) for idx in contact[0]], contact[1])
for contact in self.atom_contacts.most_common_idx()
Expand Down
2 changes: 2 additions & 0 deletions contact_map/min_dist.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import collections
import itertools
import mdtraj as md

class NearestAtoms(object):
Expand Down
5 changes: 3 additions & 2 deletions contact_map/tests/test_contact_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
from numpy.testing import assert_array_equal
import mdtraj as md

# pylint: disable=W0401, R0201
# wildcard imports, method could be function
# pylint: disable=wildcard-import, missing-docstring, protected-access
# pylint: disable=attribute-defined-outside-init, invalid-name, no-self-use
# pylint: disable=wrong-import-order, unused-wildcard-import

from .utils import *

Expand Down

0 comments on commit 46094dc

Please sign in to comment.