-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #102 from Ecogenomics/master
Merge master branch for release 0.2.1
- Loading branch information
Showing
103 changed files
with
144,979 additions
and
5,231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
global-exclude config.py | ||
global-include pfam_search.pl | ||
global-include *.pm | ||
include genome_1.fna genome_2.fna genome_3.fna | ||
global-exclude genome_*_protein.fna | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
############################################################################### | ||
# # | ||
# This program is free software: you can redistribute it and/or modify # | ||
# it under the terms of the GNU General Public License as published by # | ||
# the Free Software Foundation, either version 3 of the License, or # | ||
# (at your option) any later version. # | ||
# # | ||
# This program is distributed in the hope that it will be useful, # | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of # | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # | ||
# GNU General Public License for more details. # | ||
# # | ||
# You should have received a copy of the GNU General Public License # | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. # | ||
# # | ||
############################################################################### | ||
|
||
__author__ = 'Donovan Parks' | ||
__copyright__ = 'Copyright 2014' | ||
__credits__ = ['Donovan Parks'] | ||
__license__ = 'GPL3' | ||
__maintainer__ = 'Donovan Parks' | ||
__email__ = 'donovan.parks@gmail.com' | ||
|
||
import os | ||
import errno | ||
import sys | ||
import logging | ||
import ntpath | ||
import re | ||
import gzip | ||
|
||
|
||
def is_float(s): | ||
"""Check if a string can be converted to a float. | ||
Parameters | ||
---------- | ||
s : str | ||
String to evaluate. | ||
Returns | ||
------- | ||
boolean | ||
True if string can be converted, else False. | ||
""" | ||
|
||
try: | ||
float(s) | ||
except ValueError: | ||
return False | ||
|
||
return True | ||
|
||
|
||
def check_file_exists(input_file): | ||
"""Check if file exists.""" | ||
if not os.path.exists(input_file) or not os.path.isfile(input_file): | ||
logger = logging.getLogger('timestamp') | ||
logger.error('Input file does not exists: ' + input_file + '\n') | ||
sys.exit() | ||
|
||
|
||
def check_dir_exists(input_dir): | ||
"""Check if directory exists.""" | ||
if not os.path.exists(input_dir) or not os.path.isdir(input_dir): | ||
logger = logging.getLogger('timestamp') | ||
logger.error('Input directory does not exists: ' + input_dir + '\n') | ||
sys.exit() | ||
|
||
|
||
def make_sure_path_exists(path): | ||
"""Create directory if it does not exist.""" | ||
|
||
if not path: | ||
# lack of a path qualifier is acceptable as this | ||
# simply specifies the current directory | ||
return | ||
|
||
try: | ||
os.makedirs(path) | ||
except OSError as exception: | ||
if exception.errno != errno.EEXIST: | ||
logger = logging.getLogger('timestamp') | ||
logger.error('Specified path could not be created: ' + path + '\n') | ||
sys.exit() | ||
|
||
|
||
def remove_extension(filename, extension=None): | ||
"""Remove extension from filename. | ||
A specific extension can be specified, otherwise | ||
the extension is taken as all characters after the | ||
last period. | ||
""" | ||
f = ntpath.basename(filename) | ||
|
||
if extension and f.endswith(extension): | ||
f = f[0:f.rfind(extension)] | ||
else: | ||
f = os.path.splitext(f)[0] | ||
|
||
if f[-1] == '.': | ||
f = f[0:-1] | ||
|
||
return f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
############################################################################### | ||
# # | ||
# This program is free software: you can redistribute it and/or modify # | ||
# it under the terms of the GNU General Public License as published by # | ||
# the Free Software Foundation, either version 3 of the License, or # | ||
# (at your option) any later version. # | ||
# # | ||
# This program is distributed in the hope that it will be useful, # | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of # | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # | ||
# GNU General Public License for more details. # | ||
# # | ||
# You should have received a copy of the GNU General Public License # | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. # | ||
# # | ||
############################################################################### | ||
|
||
__author__ = 'Donovan Parks' | ||
__copyright__ = 'Copyright 2014' | ||
__credits__ = ['Donovan Parks', 'Connor Skennerton'] | ||
__license__ = 'GPL3' | ||
__maintainer__ = 'Donovan Parks' | ||
__email__ = 'donovan.parks@gmail.com' | ||
|
||
import os | ||
import types | ||
import tempfile | ||
import argparse | ||
|
||
|
||
class ChangeTempAction(argparse.Action): | ||
"""Action for changing the directory used for temporary files. | ||
Example: | ||
<parse>.add_argument('--tmpdir', action=ChangeTempAction, default=tempfile.gettempdir(), help="specify alternative directory for temporary files") | ||
""" | ||
|
||
def __call__(self, parser, namespace, values, option_string=None): | ||
if os.path.isdir(values): | ||
tempfile.tempdir = values | ||
setattr(namespace, self.dest, values) | ||
else: | ||
raise argparse.ArgumentTypeError( | ||
'The value of %s must be a valid directory' % option_string) | ||
|
||
|
||
class CustomHelpFormatter(argparse.HelpFormatter): | ||
"""Provide a customized format for help output. | ||
http://stackoverflow.com/questions/9642692/argparse-help-without-duplicate-allcaps | ||
""" | ||
|
||
def _get_help_string(self, action): | ||
"""Place default value in help string.""" | ||
h = action.help | ||
if '%(default)' not in action.help: | ||
if action.default != '' and action.default != [] and action.default is not None and type(action.default) != types.BooleanType: | ||
if action.default is not argparse.SUPPRESS: | ||
defaulting_nargs = [ | ||
argparse.OPTIONAL, argparse.ZERO_OR_MORE] | ||
|
||
if action.option_strings or action.nargs in defaulting_nargs: | ||
if '\n' in h: | ||
lines = h.splitlines() | ||
lines[0] += ' (default: %(default)s)' | ||
h = '\n'.join(lines) | ||
else: | ||
h += ' (default: %(default)s)' | ||
return h | ||
|
||
def _format_action_invocation(self, action): | ||
"""Removes duplicate ALLCAPS with positional arguments.""" | ||
if not action.option_strings: | ||
default = self._get_default_metavar_for_positional(action) | ||
metavar, = self._metavar_formatter(action, default)(1) | ||
return metavar | ||
|
||
else: | ||
parts = [] | ||
|
||
# if the Optional doesn't take a value, format is: | ||
# -s, --long | ||
if action.nargs == 0: | ||
parts.extend(action.option_strings) | ||
|
||
# if the Optional takes a value, format is: | ||
# -s ARGS, --long ARGS | ||
else: | ||
default = self._get_default_metavar_for_optional(action) | ||
args_string = self._format_args(action, default) | ||
for option_string in action.option_strings: | ||
parts.append(option_string) | ||
|
||
return '%s %s' % (', '.join(parts), args_string) | ||
|
||
return ', '.join(parts) | ||
|
||
def _get_default_metavar_for_optional(self, action): | ||
return action.dest.upper() | ||
|
||
def _get_default_metavar_for_positional(self, action): | ||
return action.dest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.