Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.0.3
current_version = 1.0.4
commit = True
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>[a-z0-9+]+)
Expand Down
64 changes: 32 additions & 32 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,35 +73,35 @@ jobs:
--token "${{ secrets.ANACONDA_TOKEN }}" \
conda/bactabolize/

build_and_publish_on_dockerhub:
runs-on: ubuntu-latest
needs:
- get_version
- build_and_publish_on_conda
# Only push on push to stable, which implicitly should be only version bumps
if: github.ref == 'refs/heads/stable'
defaults:
run:
shell: bash -l {0}
env:
DOCKERHUB_REPO: "docker.io/scwatts/bactabolize"
VERSION: ${{ needs.get_version.outputs.version }}
steps:
- name: Checkout code
id: git_checkout
uses: actions/checkout@v3
- name: Build Docker image
run: |
docker build \
--tag "${DOCKERHUB_REPO}:${VERSION}" \
--file docker/Dockerfile \
./
- name: DockerHub auth
run: |
echo "${{ secrets.DOCKERHUB_TOKEN }}" | \
docker login \
--username "${{ secrets.DOCKERHUB_USERNAME }}" \
--password-stdin
- name: DockerHub push
run: |
docker push "${DOCKERHUB_REPO}:${VERSION}"
# build_and_publish_on_dockerhub:
# runs-on: ubuntu-latest
# needs:
# - get_version
# - build_and_publish_on_conda
# # Only push on push to stable, which implicitly should be only version bumps
# if: github.ref == 'refs/heads/stable'
# defaults:
# run:
# shell: bash -l {0}
# env:
# DOCKERHUB_REPO: "docker.io/scwatts/bactabolize"
# VERSION: ${{ needs.get_version.outputs.version }}
# steps:
# - name: Checkout code
# id: git_checkout
# uses: actions/checkout@v3
# - name: Build Docker image
# run: |
# docker build \
# --tag "${DOCKERHUB_REPO}:${VERSION}" \
# --file docker/Dockerfile \
# ./
# - name: DockerHub auth
# run: |
# echo "${{ secrets.DOCKERHUB_TOKEN }}" | \
# docker login \
# --username "${{ secrets.DOCKERHUB_USERNAME }}" \
# --password-stdin
# - name: DockerHub push
# run: |
# docker push "${DOCKERHUB_REPO}:${VERSION}"
2 changes: 1 addition & 1 deletion bactabolize/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__program_name__ = 'bactabolize'
__version__ = '1.0.3'
__version__ = '1.0.4'
36 changes: 27 additions & 9 deletions bactabolize/annotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,22 @@ def match_existing_orfs_updated_annotations(new_fp, existing_fp, overlap_min=0.8
# Find overlaps
positions = contig_positions_new[contig] + contig_positions_existing[contig]
features_matched = discover_overlaps(positions, overlap_min)
# Discover those not matched
features_matched_flat = set()
for features in features_matched:
features_matched_flat.update(features)
new_unmatched = set(features_new[contig]).difference(features_matched_flat)
existing_unmatched = set(features_existing[contig]).difference(features_matched_flat)

# Discover those not matched using location comparison
features_matched_new = [f[0] for f in features_matched]
features_matched_existing = [f[1] for f in features_matched]

# Find unmatched features by comparing locations
new_unmatched = []
for feature in features_new[contig]:
if not any(f.location == feature.location for f in features_matched_new):
new_unmatched.append(feature)

existing_unmatched = []
for feature in features_existing[contig]:
if not any(f.location == feature.location for f in features_matched_existing):
existing_unmatched.append(feature)

# For each matched update bounds update locus tag, product, gene (if present) to match existing
quals = ('locus_tag', 'product', 'gene')
features_updated = list()
Expand All @@ -141,6 +151,7 @@ def match_existing_orfs_updated_annotations(new_fp, existing_fp, overlap_min=0.8
continue
feature_new.qualifiers[qual] = feature_existing.qualifiers[qual]
features_updated.append(feature_new)

# Add existing ORFs that had no match
features_updated.extend(new_unmatched)
features_updated.extend(existing_unmatched)
Expand All @@ -152,6 +163,7 @@ def match_existing_orfs_updated_annotations(new_fp, existing_fp, overlap_min=0.8
print(f'\t{len(existing_unmatched)} existing features unmatched')
print(f'\t{len(new_unmatched)} re-annotated features unmatched')
print(f'\t{len(features_updated)} total features')

# Update new genbank with new feature set
update_genbank_annotations(new_fp, contig_features_updated)

Expand Down Expand Up @@ -179,7 +191,8 @@ def discover_overlaps(positions, overlap_min):
# pylint: disable=too-many-branches
in_new = list()
in_existing = list()
features_matched = set()
# Change from set to list to store matches
features_matched = []
for position in sorted(positions, key=lambda k: k['position']):
# Add features we're entering and remove those we're exiting
if position['type'] == 'start':
Expand All @@ -199,7 +212,12 @@ def discover_overlaps(positions, overlap_min):
for feature_existing in in_existing:
if feature_new.strand != feature_existing.strand:
continue
if (feature_new, feature_existing) in features_matched:
# Check if this pair is already matched by comparing locations
already_matched = any(
fn.location == feature_new.location and fe.location == feature_existing.location
for fn, fe in features_matched
)
if already_matched:
continue
# Get overlap
start = max(feature_new.location.start, feature_existing.location.start)
Expand All @@ -212,7 +230,7 @@ def discover_overlaps(positions, overlap_min):
# Update note to include overlap information
[note_new] = feature_new.qualifiers['note']
feature_new.qualifiers['note'][0] = f'{note_new};overlap:{overlap_new:.2f}'
features_matched.add((feature_new, feature_existing))
features_matched.append((feature_new, feature_existing))
return features_matched


Expand Down
8 changes: 7 additions & 1 deletion conda/bactabolize/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ requirements:
run:
- python ==3.9
- biopython ==1.79
- glpk ==5.0
- swiglpk ==5.0.10
- urllib3 ==2.2.2
- cchardet ==2.1.7
- tabulator ==1.25.1
- goodtables ==2.5.4
- openpyxl ==2.4.11
- blast ==2.12.0
- cobra ==0.21.0
- prodigal ==2.6.3
Expand All @@ -28,7 +35,6 @@ requirements:
- cookiecutter
- depinfo ==1.7.0
- gitpython
- goodtables ~=2.0
- importlib_resources ==5.12.0
- jinja2
- numpydoc
Expand Down
2 changes: 1 addition & 1 deletion data/media_definitions/tsa_sheep_blood_media.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "TSA_sheep_blood",
"exchanges":
"exchanges": {
"EX_14glucan_e": -1000,
"EX_1Dgali_e": -1000,
"EX_ala__L_e": -1000,
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM mambaorg/micromamba:0.24.0

RUN \
micromamba install -y -n base -c scwatts -c bioconda -c conda-forge -c defaults \
'bactabolize==1.0.3' && \
'bactabolize==1.0.4' && \
micromamba clean --all --yes

ENV PATH="/opt/conda/bin:/opt/conda/condabin:${PATH}"
7 changes: 7 additions & 0 deletions requirements-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ dependencies:
- pylint >=2.5,<=2.14 # NOTE(SW): upper bound on version to avoid installing broken package
# Dependencies
- biopython ==1.79
- glpk ==5.0
- swiglpk ==5.0.10
- urllib3 ==2.2.2
- cchardet ==2.1.7
- tabulator ==1.25.1
- goodtables ==2.5.4
- openpyxl ==2.4.11
- blast ==2.12.0
- cobra ==0.21.0
- prodigal ==2.6.3
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
description='Bactabolize python package',
author='Stephen Watts',
license='GPLv3',
url='https://github.com/scwatts/bactabolize',
url='https://github.com/kelwyres/bactabolize',
test_suite='tests',
packages=setuptools.find_packages(),
package_data={'bactabolize': ['data/**']},
Expand Down
Loading