Skip to content

Commit

Permalink
Merge pull request #31 from fsimkovic/master
Browse files Browse the repository at this point in the history
Updates, fixes and added features
  • Loading branch information
linucks committed Jan 6, 2018
2 parents d807161 + e67ca3d commit a642a4a
Show file tree
Hide file tree
Showing 30 changed files with 1,108 additions and 690 deletions.
95 changes: 63 additions & 32 deletions CHANGELOG.rst
Expand Up @@ -2,48 +2,79 @@
Changelog
=========

v0.8.3
------
- General
- ``requirements.txt`` file re-added for easier dependency installation
- Distance definitions accept floating point values
- ``_BandwidthCalc`` class renamed to ``BandwidthBase``
- Abstractified ``BandwidthBase``, and ``Parser`` with all subparser classes
- Refactored ``conkit/io/__init__.py`` to avoid duplication of code
[Unreleased]
------------
Added
~~~~~
- ``Entity.top`` property to always return the first child in the list
- ``ContactMap.find`` function accepts ``strict`` keyword argument to find contact pairs with both residues in ``register``
- ``PdbParser`` takes a distance cutoff of ``0`` to include all Cb-Cb contacts in the protein structure
- ``ContactMatchState`` enumerated type for definitions of state constants for contact
- ``SequenceAlignmentState`` enumerated type for definitions of state constants for each sequence file
- ``NcontParser`` added to extract contact pairs identified by NCONT (CCP4 Software Suite)
Changed
~~~~~~~
- Optimized some functions and comparisons according to the recommended Python optimization instructions
- ``ContactMap.match`` does __not__ modifiy ``other`` by default anymore. Specify ``match_other=True`` as kwarg!
- ``ContactMap.calculate_kernel_density`` renamed to ``ContactMap.calculate_contact_density``
- ``ContactDensityFigure`` draws domain boundary lines instead of symbols

- New features
- ``LinearBW`` calculator added for linear bandwidth calculation in analysis
- ``seq_ascii`` property to ``Sequence`` for encoded sequence
- ``ascii_matrix`` property to ``SequenceFile`` for encoded alignment
- ``SequenceFile`` and ``ContactFile`` classes have new ``empty`` properties
- ``flib`` format for ``ContactFile`` classes to allow easier conversions for the Flib-Coevo fragment picking library
[0.8.3]
-------
Added
~~~~~
- ``requirements.txt`` file re-added for easier dependency installation
- ``LinearBW`` calculator added for linear bandwidth calculation in analysis
- ``seq_ascii`` property to ``Sequence`` for encoded sequence
- ``ascii_matrix`` property to ``SequenceFile`` for encoded alignment
- ``SequenceFile`` and ``ContactFile`` classes have new ``empty`` properties
- ``flib`` format for ``ContactFile`` classes to allow easier conversions for the Flib-Coevo fragment picking library
Changed
~~~~~~~
- Distance definitions accept floating point values
- ``_BandwidthCalc`` class renamed to ``BandwidthBase``
- Abstractified ``BandwidthBase``, and ``Parser`` with all subparser classes
- Refactored ``conkit/io/__init__.py`` to avoid duplication of code
Fixed
~~~~~
- ``PconsParser`` class accepts negative ``raw_score`` values
- ``SequenceFile.neff`` returns ``float`` instead of ``int``
- ``CCMpredParser.read()`` returns empty ``ContactFile`` when matrix file empty

- Bug fix
- ``PconsParser`` class accepts negative ``raw_score`` values
- ``SequenceFile.neff`` returns ``float`` instead of ``int``
- ``CCMpredParser.read()`` returns empty ``ContactFile`` when matrix file empty

v0.8.2
------

- Critical bug fix for automated opening of filehandle in Python2.7
[0.8.2]
-------
Added
~~~~~
- Test function skipping added for ``SequenceFile.filter()`` when SciPy not installed
Changed
~~~~~~~
- Renamed conkit/io/tests files for filenames to agree with modules in conkit/io
- Performance of ``write()`` in parsers improved by construction of string and single call to ``write()`` of filehandle
Fixed
~~~~~
- Critical bug fix for automated opening of filehandle in Python2.7

v0.8.1
------

[0.8.1]
-------
Changed
~~~~~~~
- Revoked catching of ``SystemExit(0)`` exception in scripts when invoked with ``--help`` flag
Fixed
~~~~~
- Bug fix relating to Python3 automatic opening of file handles - Thanks to Miguel Correa for reporting this bug

v0.8
----

- Default value in ``calculate_meff()`` and ``calculate_weights()`` changed from 0.7 to 0.8 [more commonly used in literature]
- Bug fix with PyPi installation where ``requirements.txt`` not found; fix includes removal of ``requirements.txt`` and addition of ``install_requires`` to ``setup.py`` instead. - Thanks to Miguel Correa for reporting this bug
[0.8]
-----
Added
~~~~~
- Logging message coloring according to message level
- ``filter()`` function added for redundancy/distant homolog removal from ``SequenceFile``
- License text added to each module
- ``io`` sub-package caches modules and imports upon request
Changed
~~~~~~~
- Default value in ``calculate_meff()`` and ``calculate_weights()`` changed from 0.7 to 0.8 [more commonly used in literature]
- ``core`` classes extracted to individual module files
- License text added to each module
Fixed
~~~~~
- Bug fix with PyPi installation where ``requirements.txt`` not found; fix includes removal of ``requirements.txt`` and addition of ``install_requires`` to ``setup.py`` instead. - Thanks to Miguel Correa for reporting this bug
31 changes: 17 additions & 14 deletions conkit/command_line/__init__.py
Expand Up @@ -35,6 +35,7 @@

import logging
import os
import sys


def setup_logging(level='info', logfile=None):
Expand All @@ -55,26 +56,27 @@ def setup_logging(level='info', logfile=None):
Instance of a :obj:`logger <logging.Logger>`
"""

class ColorFormatter(logging.Formatter):
"""Formatter to color console logging output"""

# ANSI foreground color codes
colors = {
colors = {
logging.DEBUG: 34, # blue
logging.INFO: 0 , # reset to default
logging.WARNING: 33, # yellow
logging.ERROR: 31, # red
logging.CRITICAL: 31, # red
}

def format(self, record):
if record.exc_info is None:
# REM: get the ANSI FG color code
color = ColorFormatter.colors[record.levelno]
prefix = '\033[{}m'.format(color)
record.msg = os.linesep.join([prefix + l for l in str(record.msg).splitlines()])

if record.levelno in self.colors:
prefix = '\033[1;{}m'.format(
ColorFormatter.colors[record.levelno])
postfix = '\033[0m'
record.msg = os.linesep.join(
[prefix + l +
postfix for l in str(record.msg).splitlines()]
)
return logging.Formatter.format(self, record)

# Reset any Handlers or Filters already in the logger to start from scratch
Expand All @@ -91,7 +93,7 @@ def format(self, record):
logging.getLogger().setLevel(logging.DEBUG)

# create console handler with a higher log level
ch = logging.StreamHandler()
ch = logging.StreamHandler(stream=sys.stdout)
ch.setLevel(logging_levels.get(level, logging.INFO))
ch.setFormatter(ColorFormatter('%(message)s'))
logging.getLogger().addHandler(ch)
Expand All @@ -101,12 +103,13 @@ def format(self, record):
fh = logging.FileHandler(logfile)
fh.setLevel(logging.NOTSET)
fh.setFormatter(
logging.Formatter('%(asctime)s\t%(name)s [%(lineno)d]\t%(levelname)s\t%(message)s')
logging.Formatter(
'%(asctime)s\t%(name)s [%(lineno)d]\t%(levelname)s\t%(message)s')
)
logging.getLogger().addHandler(fh)

logging.getLogger().debug('Console logger level: %s', logging_levels.get(level, logging.INFO))
logging.getLogger().debug('Console logger level: %s',
logging_levels.get(level, logging.INFO))
logging.getLogger().debug('File logger level: %s', logging.NOTSET)

return logging.getLogger()

0 comments on commit a642a4a

Please sign in to comment.