Skip to content

Commit

Permalink
Update master branch to V 1.2b7
Browse files Browse the repository at this point in the history
  • Loading branch information
biologyguy committed Oct 19, 2016
2 parents a7eb9a6 + ba425fc commit a907e37
Show file tree
Hide file tree
Showing 30 changed files with 251 additions and 224 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ Each tool in the BuddySuite has been extensively documented in the [wiki](https:
All of the individual Buddy toolkits are located in the 'buddysuite' directory and the
['develop' branch](https://github.com/biologyguy/BuddySuite/tree/develop) is where all new features have been
implemented. If you're interested in contributing, please refer to the
[developer page](https://github.com/biologyguy/BuddySuite/wiki/Developers) for further information on dependencies
and instructions.
[developer page](https://github.com/biologyguy/BuddySuite/wiki/Developers) for further information.

## Citation
We are currently working on a [peer reviewed manuscript](https://github.com/biologyguy/BuddySuite/tree/develop/manuscript), but until then
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ branch <https://github.com/biologyguy/BuddySuite/tree/develop>`__ is
where all new features have been implemented. If you're interested in
contributing, please refer to the `developer
page <https://github.com/biologyguy/BuddySuite/wiki/Developers>`__ for
further information on dependencies and instructions.
further information.

Citation
--------
Expand Down
12 changes: 8 additions & 4 deletions buddysuite/AlignBuddy.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,15 @@

# BuddySuite specific
try:
from . import buddy_resources as br
from . import SeqBuddy as Sb
except SystemError:
import buddy_resources as br
import SeqBuddy as Sb
except ImportError:
try:
import buddysuite.buddy_resources as br
import buddysuite.SeqBuddy as Sb
except AttributeError:
from . import buddy_resources as br
from . import SeqBuddy as Sb

# Standard library
import sys
Expand Down Expand Up @@ -65,7 +69,7 @@

# ################################################ GLOBALS ###################################################### #
GAP_CHARS = ["-", ".", " "]
VERSION = br.Version("AlignBuddy", 1, "2b6", br.contributors, {"year": 2016, "month": 10, "day": 3})
VERSION = br.Version("AlignBuddy", 1, "2b7", br.contributors, {"year": 2016, "month": 10, "day": 19})


# #################################################### ALIGNBUDDY #################################################### #
Expand Down
13 changes: 11 additions & 2 deletions buddysuite/BuddySuite.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,21 @@
from configparser import ConfigParser, NoOptionError
import os
import re
import buddysuite
import buddysuite.buddy_resources as br
import shutil
import random
import string

try:
import buddysuite
import buddy_resources as br
except ImportError:
try:
import buddysuite
import buddysuite.buddy_resources as br
except AttributeError:
from . import buddysuite
from . import buddy_resources as br


def setup(): # ToDo: Check permissions?
print("\033[1mWelcome to BuddySuite!\033[m\nLet's configure your installation:\n")
Expand Down
9 changes: 6 additions & 3 deletions buddysuite/DatabaseBuddy.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@

# BuddySuite specific
try:
from . import buddy_resources as br
except SystemError:
import buddy_resources as br
except ImportError:
try:
import buddysuite.buddy_resources as br
except AttributeError:
from . import buddy_resources as br

# Standard library
import sys
Expand Down Expand Up @@ -77,7 +80,7 @@
"fastq-solexa", "fastq-illumina", "genbank", "gb", "imgt", "nexus", "phd", "phylip", "seqxml",
"stockholm", "tab", "qual"]
CONFIG = br.config_values()
VERSION = br.Version("DatabaseBuddy", 1, "2b6", br.contributors, {"year": 2016, "month": 10, "day": 3})
VERSION = br.Version("DatabaseBuddy", 1, "2b7", br.contributors, {"year": 2016, "month": 10, "day": 19})

GREY = "\033[90m"
RED = "\033[91m"
Expand Down
12 changes: 8 additions & 4 deletions buddysuite/PhyloBuddy.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,15 @@

# BuddySuite specific
try:
from . import buddy_resources as br
from . import AlignBuddy as Alb
except SystemError:
import buddy_resources as br
import AlignBuddy as Alb
except ImportError:
try:
import buddysuite.buddy_resources as br
import buddysuite.AlignBuddy as Alb
except AttributeError:
from . import buddy_resources as br
from . import AlignBuddy as Alb

# Standard library
import sys
Expand Down Expand Up @@ -143,7 +147,7 @@ def ascending_order(phylobuddy):

# ##################################################### GLOBALS ###################################################### #
CONFIG = br.config_values()
VERSION = br.Version("PhyloBuddy", 1, "2b6", br.contributors, {"year": 2016, "month": 10, "day": 3})
VERSION = br.Version("PhyloBuddy", 1, "2b7", br.contributors, {"year": 2016, "month": 10, "day": 19})
OUTPUT_FORMATS = ["newick", "nexus", "nexml"]
PHYLO_INFERENCE_TOOLS = ["raxml", "phyml", "fasttree"]

Expand Down
20 changes: 12 additions & 8 deletions buddysuite/SeqBuddy.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,15 @@

# BuddySuite specific
try:
from . import buddy_resources as br
from . import AlignBuddy as Alb
except SystemError:
import buddy_resources as br
import AlignBuddy as Alb
except ImportError:
try:
import buddysuite.buddy_resources as br
import buddysuite.AlignBuddy as Alb
except AttributeError:
from . import buddy_resources as br
from . import AlignBuddy as Alb

# Standard library
import sys
Expand Down Expand Up @@ -153,7 +157,7 @@ def incremental_rename(query, replace):
# - Try to speed things up by reading in all sequence data only when necessary

# ###################################################### GLOBALS ##################################################### #
VERSION = br.Version("SeqBuddy", 1, "2b6", br.contributors, {"year": 2016, "month": 10, "day": 3})
VERSION = br.Version("SeqBuddy", 1, "2b7", br.contributors, {"year": 2016, "month": 10, "day": 19})
OUTPUT_FORMATS = ["ids", "accessions", "summary", "full-summary", "clustal", "embl", "fasta", "fastq", "fastq-sanger",
"fastq-solexa", "fastq-illumina", "genbank", "gb", "imgt", "nexus", "phd", "phylip", "phylip-relaxed",
"phylipss", "phylipsr", "raw", "seqxml", "sff", "stockholm", "tab", "qual"]
Expand Down Expand Up @@ -1355,11 +1359,11 @@ def count_residues(seqbuddy):
neut = len(re.findall("[GAVLIPFYWSTNQM]", seq))
resid_count['% Uncharged'] = round(100 * neut / seq_len, 2)

hyrdophobic = len(re.findall("[AVLIPYFWMC]", seq))
resid_count['% Hyrdophobic'] = round(100 * hyrdophobic / seq_len, 2)
hydrophobic = len(re.findall("[AVLIPYFWMC]", seq))
resid_count['% Hydrophobic'] = round(100 * hydrophobic / seq_len, 2)

hyrdophilic = len(re.findall("[NQSTKRHDE]", seq))
resid_count['% Hyrdophilic'] = round(100 * hyrdophilic / seq_len, 2)
hydrophilic = len(re.findall("[NQSTKRHDE]", seq))
resid_count['% Hydrophilic'] = round(100 * hydrophilic / seq_len, 2)

for residue in ["A", "C", "D", "E", "F", "G", "H", "I", "K", "L", "M",
"N", "P", "Q", "R", "S", "T", "V", "W", "Y"]:
Expand Down
5 changes: 2 additions & 3 deletions buddysuite/buddy_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@
"""
from __future__ import print_function
import sys
if float("%s.%s" % (sys.version_info[0], sys.version_info[1])) < 3.5:
print("Error: Attempting to run BuddySuite with Python %s.%s. Python 3.5+ required." %
(sys.version_info[0], sys.version_info[1]))
if int(sys.version_info[0]) < 3:
print("Error: Attempting to run BuddySuite with Python %s. Python 3+ required." % sys.version_info[0])
sys.exit()
import argparse
import datetime
Expand Down
16 changes: 10 additions & 6 deletions buddysuite/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
# coding=utf-8
import os
import sys
from copy import deepcopy
from hashlib import md5
from collections import OrderedDict

from .. import AlignBuddy as Alb
from .. import SeqBuddy as Sb
from .. import PhyloBuddy as Pb
from .. import DatabaseBuddy as Db
DIRECTORY_SCRIPT = os.path.dirname(os.path.realpath(__file__))
sys.path.insert(0, "%s%s.." % (DIRECTORY_SCRIPT, os.sep))

import AlignBuddy as Alb
import SeqBuddy as Sb
import PhyloBuddy as Pb
import DatabaseBuddy as Db

# This file (conftest.py) must be in the same directory as unit_test_resources
RESOURCE_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'unit_test_resources') + os.path.sep
Expand All @@ -21,7 +25,7 @@ def __init__(self):
@staticmethod
def buddy2hash(buddy):
if type(buddy) not in [Sb.SeqBuddy, Alb.AlignBuddy, Pb.PhyloBuddy, Db.DbBuddy]:
raise AttributeError("Buddy object required")
raise AttributeError("Buddy object required, not %s" % type(buddy))
_hash = md5("{0}".format(str(buddy)).encode("utf-8")).hexdigest()
return _hash

Expand Down Expand Up @@ -320,7 +324,7 @@ def get_one(self, code, mode="objs"):
if len(code.split()) != 3:
raise AttributeError("Only explicit three-component codes are accepted")
output = self.get_list(code, mode)
return None if not output or len(output) > 1else output[0]
return None if not output or len(output) > 1 else output[0]


# ################################ - PhyloBuddy - ################################# #
Expand Down
54 changes: 27 additions & 27 deletions buddysuite/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ def sb_resources():
def sb_odd_resources():
# A dict of invalid file resources
resource_list = {file_format: name.format(path=RESOURCE_PATH) for file_format, name in [
('blank', '{path}/blank.fa'),
('figtree', '{path}/figtree.nexus'),
('unrecognizable', '{path}/unrecognizable.phy'),
('gibberish', '{path}/gibberish.fa'),
('phylipss_cols', '{path}/malformed_phylip_columns.physs'),
('duplicate', '{path}/Duplicate_seqs.fa'),
('ambiguous_dna', '{path}/ambiguous_dna.fa'),
('ambiguous_rna', '{path}/ambiguous_rna.fa'),
('blastn', '{path}/blast/Mnemiopsis_cds.n'),
('blastp', '{path}/blast/Mnemiopsis_pep.p'),
('dummy_feats', '{path}/Mnemiopsis_cds_dummy_features.gb'),
('cnidaria_pep', '{path}/Cnidaria_pep.nexus'),
('mixed', '{path}/mixed_alpha.fa')
('blank', '{path}blank.fa'),
('figtree', '{path}figtree.nexus'),
('unrecognizable', '{path}unrecognizable.phy'),
('gibberish', '{path}gibberish.fa'),
('phylipss_cols', '{path}malformed_phylip_columns.physs'),
('duplicate', '{path}Duplicate_seqs.fa'),
('ambiguous_dna', '{path}ambiguous_dna.fa'),
('ambiguous_rna', '{path}ambiguous_rna.fa'),
('blastn', '{path}blast/Mnemiopsis_cds.n'),
('blastp', '{path}blast/Mnemiopsis_pep.p'),
('dummy_feats', '{path}Mnemiopsis_cds_dummy_features.gb'),
('cnidaria_pep', '{path}Cnidaria_pep.nexus'),
('mixed', '{path}mixed_alpha.fa')
]}
return resource_list

Expand All @@ -66,16 +66,16 @@ def alb_odd_resources():
resource_list = {
'dna': {
'single': {file_format: name.format(path=RESOURCE_PATH) for file_format, name in [
('fasta', '{path}/gibberish.fa'),
('phylipss_recs', '{path}/malformed_phylip_records.physs'),
('phylipss_cols', '{path}/malformed_phylip_columns.physs'),
('ambiguous', '{path}/ambiguous_dna_alignment.fa')]}
('fasta', '{path}gibberish.fa'),
('phylipss_recs', '{path}malformed_phylip_records.physs'),
('phylipss_cols', '{path}malformed_phylip_columns.physs'),
('ambiguous', '{path}ambiguous_dna_alignment.fa')]}
},
'protein': {
'single': {file_format: name.format(path=RESOURCE_PATH) for file_format, name in [
('phylip', '{path}/unrecognizable.phy')]}
('phylip', '{path}unrecognizable.phy')]}
},
'blank': "%s/blank.fa" % RESOURCE_PATH
'blank': "%sblank.fa" % RESOURCE_PATH
}
return resource_list

Expand All @@ -94,13 +94,13 @@ def pb_resources():
def pb_odd_resources():
# A dict of invalid file resources
resource_list = {file_format: name.format(path=RESOURCE_PATH) for file_format, name in [
('blank', '{path}/blank.fa'),
('unrecognizable', '{path}/unrecognizable.phy'),
('figtree', '{path}/figtree.nexus'),
('compare', '{path}/compare_trees.newick'),
('node_lables', '{path}/tree_with_node_lables.nwk'),
('lengths', '{path}/Mnemiopsis_pep.newick'),
('bootstraps', '{path}/Mnemiopsis_pep_bootstraps.newick'),
('support', '{path}/Mnemiopsis_pep_support.newick')
('blank', '{path}blank.fa'),
('unrecognizable', '{path}unrecognizable.phy'),
('figtree', '{path}figtree.nexus'),
('compare', '{path}compare_trees.newick'),
('node_lables', '{path}tree_with_node_lables.nwk'),
('lengths', '{path}Mnemiopsis_pep.newick'),
('bootstraps', '{path}Mnemiopsis_pep_bootstraps.newick'),
('support', '{path}Mnemiopsis_pep_support.newick')
]}
return resource_list
16 changes: 5 additions & 11 deletions buddysuite/tests/test_alignbuddy/test_alb_3rd_party.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
from unittest import mock
from shutil import which
from subprocess import Popen, PIPE
from ... import AlignBuddy as Alb
from ... import SeqBuddy as Sb
from ... import buddy_resources as br
import AlignBuddy as Alb
import SeqBuddy as Sb
import buddy_resources as br


# ########################################### 'ga', '--generate_alignment' ########################################## #
Expand Down Expand Up @@ -237,17 +237,11 @@ def ask_true(*ask_args):
pass
return True

try:
monkeypatch.setattr("buddysuite.buddy_resources.ask", ask_false)
except ImportError:
monkeypatch.setattr("buddy_resources.ask", ask_false)
monkeypatch.setattr(br, "ask", ask_false)
with pytest.raises(SystemExit):
Alb.generate_msa(tester, clustalo_bin, keep_temp="%s%sga_temp_files" % (temp_dir.path, os.sep))

try:
monkeypatch.setattr("buddysuite.buddy_resources.ask", ask_true)
except ImportError:
monkeypatch.setattr("buddy_resources.ask", ask_true)
monkeypatch.setattr(br, "ask", ask_true)
Alb.generate_msa(tester, clustalo_bin, keep_temp="%s%sga_temp_files" % (temp_dir.path, os.sep))
assert os.path.isfile("{0}{1}ga_temp_files{1}result".format(temp_dir.path, os.sep))
assert os.path.isfile("{0}{1}ga_temp_files{1}tmp.fa".format(temp_dir.path, os.sep))
Expand Down
6 changes: 3 additions & 3 deletions buddysuite/tests/test_alignbuddy/test_alb_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
from Bio.SeqRecord import SeqRecord
from Bio.AlignIO import MultipleSeqAlignment
from Bio.Alphabet import IUPAC
from ... import AlignBuddy as Alb
from ... import SeqBuddy as Sb
from ... import buddy_resources as br
import AlignBuddy as Alb
import SeqBuddy as Sb
import buddy_resources as br
from .. import __init__
from collections import OrderedDict

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
from Bio.Alphabet import IUPAC
from Bio import AlignIO

from ... import buddy_resources as br
from ...AlignBuddy import AlignBuddy, guess_alphabet, guess_format, make_copy
from ...buddy_resources import GuessError, parse_format
import buddy_resources as br
from AlignBuddy import AlignBuddy, guess_alphabet, guess_format, make_copy
from buddy_resources import GuessError, parse_format


def mock_valueerror(*args, **kwargs):
Expand Down
6 changes: 3 additions & 3 deletions buddysuite/tests/test_alignbuddy/test_alb_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
import argparse
from copy import deepcopy

from ... import AlignBuddy as Alb
from ... import SeqBuddy as Sb
from ... import buddy_resources as br
import AlignBuddy as Alb
import SeqBuddy as Sb
import buddy_resources as br

TEMP_DIR = br.TempDir()
VERSION = Sb.VERSION
Expand Down
Loading

0 comments on commit a907e37

Please sign in to comment.