Skip to content

Commit

Permalink
v2.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
PollyTikhonova committed Jan 8, 2024
1 parent 342a345 commit 1ff5f85
Show file tree
Hide file tree
Showing 43 changed files with 2,203 additions and 14,902 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Created by .ignore support plugin (hsz.mobi)
### Python template
# Custom
proc/*
.DS_Store

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Phigaro v2.3.0
# Phigaro v2.4.0
[![PyPI version](https://badge.fury.io/py/phigaro.svg)](https://badge.fury.io/py/phigaro)
![Conda installation](https://anaconda.org/bioconda/phigaro/badges/installer/conda.svg)
![Actions Status](https://github.com/bobeobibo/phigaro/workflows/Phigaro%20Tests/badge.svg)
![Conda installation](https://anaconda.org/bioconda/phigaro/badges/version.svg)
![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

Expand Down
28 changes: 28 additions & 0 deletions deployment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
conda activate main
pip install --upgrade twine
echo "Did you change git action and updated the package?"
read
git status
read
git pull
read
rm dist/*
python setup_version.py
python setup.py sdist bdist_wheel
read
git add --all
git status
read
read -p commit_name="Please, make up the commit name:"
tag=`cat tag_name`
git commit -m $commit_name
read
git tag $tag
read
git push
read
git push --tags
read
twine upload --repository phigaro dist/*
read
Binary file removed dist/phigaro-2.3.0-py2.py3-none-any.whl
Binary file not shown.
Binary file removed dist/phigaro-2.3.0.tar.gz
Binary file not shown.
Binary file added dist/phigaro-2.4.0-py2.py3-none-any.whl
Binary file not shown.
Binary file added dist/phigaro-2.4.0.tar.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: phigaro_env
dependencies:
- python=3.7
- python<=3.12.1
- pip
- bioconda::prodigal
- bioconda::hmmer
Expand Down
2 changes: 1 addition & 1 deletion phigaro/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Version information."""

# The following line *must* be the last in the module, exactly as formatted:
__version__ ="2.3.0"
__version__ ="2.4.0"
4 changes: 1 addition & 3 deletions phigaro/batch/task/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ class AbstractTask(object):

def __init__(self):
if self.task_name is None:
raise Exception(
"{}.task_name must by set".format(self.__class__.__name__)
)
raise Exception("{}.task_name must by set".format(self.__class__.__name__))

self.directory()
self.context = Context.instance()
Expand Down
4 changes: 2 additions & 2 deletions phigaro/batch/task/dummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@


class DummyTask(AbstractTask):
task_name = 'dummy'
task_name = "dummy"

def __init__(self, output, old_task_name):
super().__init__()
self._output = output
self.task_name = '{}-dummy'.format(old_task_name)
self.task_name = "{}-dummy".format(old_task_name)

def run(self):
pass
Expand Down
11 changes: 6 additions & 5 deletions phigaro/batch/task/gene_mark.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,20 @@


class GeneMarkTask(AbstractTask):
task_name = 'gene_mark'
task_name = "gene_mark"

def __init__(self, input):
super().__init__()

self.input = input
self._lst_file = input + '.lst'
self.gene_mark = sh.Command(self.config['genemark']['bin']).bake(
m=self.config['genemark']['mod_path'], A=self.output(),
self._lst_file = input + ".lst"
self.gene_mark = sh.Command(self.config["genemark"]["bin"]).bake(
m=self.config["genemark"]["mod_path"],
A=self.output(),
)

def output(self):
return self.file('{}.faa'.format(self.sample))
return self.file("{}.faa".format(self.sample))

def run(self):
self.gene_mark(self.input)
Expand Down
14 changes: 7 additions & 7 deletions phigaro/batch/task/hmmer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


class HmmerTask(AbstractTask):
task_name = 'hmmer'
task_name = "hmmer"

def __init__(self, prodigal_task):
"""
Expand All @@ -18,18 +18,18 @@ def __init__(self, prodigal_task):
self.prodigal = prodigal_task

def _prepare(self):
self.hmmer = sh.Command(self.config['hmmer']['bin'])
self.hmmer = sh.Command(self.config["hmmer"]["bin"])

def output(self):
return self.file('{}.hmmer_out'.format(self.sample))
return self.file("{}.hmmer_out".format(self.sample))

def run(self):
self.hmmer(
'--cpu',
"--cpu",
self.context.threads,
'--notextw',
'--tblout',
"--notextw",
"--tblout",
self.output(),
self.config['hmmer']['pvog_path'],
self.config["hmmer"]["pvog_path"],
self.prodigal.output(),
)
28 changes: 12 additions & 16 deletions phigaro/batch/task/parse_hmmer.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

logger = logging.getLogger(__name__)

INFINITY = float('inf')
INFINITY = float("inf")


class ParseHmmerTask(AbstractTask):
task_name = 'parse_hmmer'
task_name = "parse_hmmer"

def __init__(self, hmmer_task, gene_mark_task):
"""
Expand All @@ -27,27 +27,27 @@ def __init__(self, hmmer_task, gene_mark_task):
self.genemark_task = gene_mark_task

def output(self):
return self.file('{}.npn'.format(self.sample))
return self.file("{}.npn".format(self.sample))

def run(self):
self._parse_hmmer_output()

@staticmethod
def parse_line(line):
tokens = re.split(r'\s+', line)
scaffold = '>' + line.split('>')[1]
tokens = re.split(r"\s+", line)
scaffold = ">" + line.split(">")[1]
name = tokens[0]
evalue = float(tokens[4])
return scaffold, name, evalue

def _parse_hmmer_output(self):
max_evalue = self.config['hmmer']['e_value_threshold']
max_evalue = self.config["hmmer"]["e_value_threshold"]

with open(self.hmmer_task.output()) as f:
lines_it = (
self.parse_line(line.strip())
for line in f
if not line.startswith('#') and line.strip()
if not line.startswith("#") and line.strip()
)

hmm_res = {}
Expand All @@ -63,12 +63,10 @@ def _parse_hmmer_output(self):
hmm_res[scaffold][gene_name] = evalue

with open(self.genemark_task.output()) as f:
with open(self.output(), 'w') as of:
writer = csv.writer(of, delimiter='\t')
with open(self.output(), "w") as of:
writer = csv.writer(of, delimiter="\t")
lines_it = (
line.strip().split('\t')
for line in f
if line.startswith('>')
line.strip().split("\t") for line in f if line.startswith(">")
)

for scaffold, group in groupby(lines_it, key=lambda t: t[1]):
Expand All @@ -81,7 +79,5 @@ def _parse_hmmer_output(self):
for gene_name, _ in group
)

is_phage_it = (
'P' if is_phage else 'N' for is_phage in is_phage_it
)
writer.writerow((scaffold, ''.join(is_phage_it)))
is_phage_it = ("P" if is_phage else "N" for is_phage in is_phage_it)
writer.writerow((scaffold, "".join(is_phage_it)))
6 changes: 3 additions & 3 deletions phigaro/batch/task/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

def sample_name(sample_path):
sample_path = basename(sample_path)
tokens = sample_path.split('.')
tokens = sample_path.split(".")
if len(tokens) == 1:
return sample_path
else:
return '.'.join(tokens[:-1])
return ".".join(tokens[:-1])


def path(*items):
items = ('proc',) + items
items = ("proc",) + items
return join(*items)


Expand Down
16 changes: 8 additions & 8 deletions phigaro/batch/task/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


class PreprocessTask(AbstractTask):
task_name = 'input_file'
task_name = "input_file"

def __init__(self, input):
super().__init__()
Expand All @@ -15,8 +15,8 @@ def __init__(self, input):

def check_fastafile(self):
def get_users_answer(question):
yes = ['yes', 'y']
no = ['no', 'n']
yes = ["yes", "y"]
no = ["no", "n"]
try:
input_ = raw_input
except NameError:
Expand All @@ -40,20 +40,20 @@ def get_users_answer(question):
SeqIO.write(records_to_save, self.output(), "fasta")
del records_to_save

if not self.config['phigaro']['delete_shorts']:
if not self.config["phigaro"]["delete_shorts"]:
if len(sequences_to_delete) > 0:
print(
'Error! Your fasta file contains at least one sequence length < 20000. The short sequences are: '
"Error! Your fasta file contains at least one sequence length < 20000. The short sequences are: "
)
print('\n'.join(sequences_to_delete))
print("\n".join(sequences_to_delete))
if not get_users_answer(
'Do you want to start Phigaro without these sequences?'
"Do you want to start Phigaro without these sequences?"
):
self.clean()
exit(1)

def output(self):
return self.file('{}.fasta'.format(self.sample))
return self.file("{}.fasta".format(self.sample))

def run(self):
self.check_fastafile()
6 changes: 3 additions & 3 deletions phigaro/batch/task/prodigal.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@


class ProdigalTask(AbstractTask):
task_name = 'prodigal'
task_name = "prodigal"

def __init__(self, preprocess_task):
super().__init__()

self.preprocess_task = preprocess_task
self.prodigal = sh.Command(self.config['prodigal']['bin']).bake(
self.prodigal = sh.Command(self.config["prodigal"]["bin"]).bake(
i=self.preprocess_task.output(), a=self.output()
)

def output(self):
return self.file('{}.faa'.format(self.sample))
return self.file("{}.faa".format(self.sample))

def run(self):
self.prodigal()
Loading

0 comments on commit 1ff5f85

Please sign in to comment.