Skip to content

Commit

Permalink
Merge pull request #2 from cfe-lab/PutMethodsInModule
Browse files Browse the repository at this point in the history
The align_it and align_it_aa methods now belong to the module "Gotoh".
  • Loading branch information
va7eex authored Nov 22, 2024
2 parents 68b257b + 577f3a2 commit d435a50
Show file tree
Hide file tree
Showing 25 changed files with 2,033 additions and 172 deletions.
31 changes: 31 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
ARG UBUNTU_VERSION=20.04

FROM ubuntu:${UBUNTU_VERSION} AS base

LABEL org.opencontainers.image.source=https://github.com/cfe-lab/gotoh
LABEL org.opencontainers.image.description="Gotoh dev container for development and testing"

ARG DEBIAN_FRONTEND=noninteractive

ENV TZ=America/Vancouver \
RUBY_VERSION=2.2.2 \
BUNDLER_VERSION=1.17.3

RUN apt-get -y update &&\
apt-get -y upgrade &&\
apt-get install -y curl gpg

RUN echo "deb http://security.ubuntu.com/ubuntu/ bionic-security main" >> /etc/apt/sources.list &&\
echo "deb http://security.ubuntu.com/ubuntu/ bionic main" >> /etc/apt/sources.list &&\
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32 &&\
apt update &&\
apt install -y \
gawk=1:4.1.4+dfsg-1build1

RUN curl -sSL https://rvm.io/mpapis.asc | gpg --import - && \
curl -sSL https://rvm.io/pkuczynski.asc | gpg --import - && \
curl -sSL https://get.rvm.io | bash -s stable && \
usermod -a -G rvm root

RUN /bin/bash -l -c "source /etc/profile.d/rvm.sh && rvm pkg install openssl"
RUN /bin/bash -l -c "source /etc/profile.d/rvm.sh && rvm requirements && rvm install ${RUBY_VERSION} --with-openssl-dir=/usr/local/rvm/usr && rvm --default use ${RUBY_VERSION}"
15 changes: 15 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu
{
"name": "CfE Ubuntu Ruby",

"build": {
"dockerfile": "Dockerfile"
},

"updateContentCommand": "cd /workspaces/gotoh/ruby && bundle install",

"features": {
"ghcr.io/devcontainers/features/git:1": {}
}
}
49 changes: 49 additions & 0 deletions .github/workflows/build_and_publish_gem.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Build and publish the Ruby package

on:
release:
types: [published]

jobs:
build_gem:
runs-on: ubuntu-latest

env:
CFE_GOTOH_VERSION: ${{ github.ref_name }}
BUILD_PATH: ${{ github.workspace }}/ruby
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

steps:
- name: Checkout code from repo
uses: actions/checkout@v4

- name: Log into GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build devcontainer and build the package
uses: devcontainers/[email protected]
with:
imageName: ghcr.io/cfe-lab/gotoh_devcontainer
cacheFrom: ghcr.io/cfe-lab/gotoh_devcontainer
runCmd: cd /workspaces/gotoh/ruby && bash build_gem.bash
env: |
CFE_GOTOH_VERSION
- name: Publish gem to Github Packages
run: |
mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
chmod 0600 $HOME/.gem/credentials
printf -- "---\n:github: Bearer ${GH_TOKEN}\n" > $HOME/.gem/credentials
gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} ${BUILD_PATH}/*.gem
env:
OWNER: ${{ github.repository_owner }}

- name: Add gem as a release asset
run: gh release upload $CFE_GOTOH_VERSION ${BUILD_PATH}/*.gem
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37 changes: 37 additions & 0 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Automated Tests

on: ["push"]

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code from repo
uses: actions/checkout@v4

- name: Log into GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build devcontainer and run tests
uses: devcontainers/[email protected]
with:
imageName: ghcr.io/cfe-lab/gotoh_devcontainer
cacheFrom: ghcr.io/cfe-lab/gotoh_devcontainer
runCmd: cd /workspaces/gotoh/ruby && rake test
env: |
CI_COMMIT_REF=${{ github.ref_name }}
CI_COMMIT_SHA=${{ github.sha }}
CI_PIPELINE_ID=${{ github.run_id }}
CI_COMMIT_BRANCH=${{ github.ref_name }}
CI_PROJECT=${{ github.repository }}
- name: Upload coverage reports to Codecov with GitHub Action
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
root_dir: ${{ github.workspace }}
files: ${{ github.workspace }}/ruby/coverage/coverage.xml
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
env/
__pycache__/
.pytest_cache/
.DS_Store
28 changes: 25 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Gotoh, Osamu. "Optimal alignment between groups of sequences and its application
CABIOS 9.3 (1993): 361-370.
```

# Launching the Docker container
# Launching the webserver Docker container

To build the Docker container, use the included Makefile in the root directory.
This is currently tested with `make build-base`. This builds the Docker image.
Expand Down Expand Up @@ -56,6 +56,10 @@ to your `requirements.txt` file or similar method.

# Ruby Bindings

The `/ruby` directory contains the directory structure required to build a
gem containing Gotoh's Ruby bindings. This gem, named `gotoh`, contains
a module called `Gotoh` that holds the `align_it` and `align_it_aa` functions.

To build Gotoh's Ruby bindings (which are called "alignment" instead of "gotoh"
for arbitrary historical reasons), you'll need to have the following installed:

Expand All @@ -65,8 +69,26 @@ for arbitrary historical reasons), you'll need to have the following installed:
[RVM](https://rvm.io/) on Linux)
- A C++ compiler

With these installed, you should be able to build the extension module with
The "canonical" environment for testing and building this package is the
dev container defined in the `.devcontainer` directory. This system is based
on the `cfe_ubuntu` Ruby image based on Ubuntu 20.04 (this old version is
required to run Ruby 2.2.2), and stripped down to only the parts necessary
for Ruby. This environment is also used by the CI/CD pipeline for testing
and building.

In this environment (or another suitable environment), you should be able to
build the extension module using the `build_gem.bash` script. By default this
will make a gem with the version number `0.1.0.pre`; set the environment variable
`CFE_GOTOH_VERSION` before building to assign a proper version number.

## Manually building the Ruby bindings

If you want to manually build the bindings, e.g. for testing/debugging/development,
copy `/ruby/ext/gotoh/extconf.rb` to the `/alignment/gotoh/` directory and
change the `create_makefile('gotoh/gotoh')` line to `create_makefile('gotoh')`;
then run
```
ruby extconf.rb
ruby extconf.rb # generates a Makefile and other supporting files
make
```
which will build `gotoh.so`, which can be `require`d from Ruby.
5 changes: 5 additions & 0 deletions alignment/gotoh/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Makefile
*.so
*.o
extconf.h
build/*
161 changes: 0 additions & 161 deletions alignment/gotoh/Makefile

This file was deleted.

4 changes: 0 additions & 4 deletions alignment/gotoh/extconf.rb

This file was deleted.

8 changes: 4 additions & 4 deletions alignment/gotoh/gotoh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -852,11 +852,11 @@ void widen_gaps(string* seq)
return ret;
}


extern "C" void Init_alignment()
extern "C" void Init_cfe_gotoh()
{
rb_define_global_function("align_it", (VALUE(*)(...))align_it, 4);
rb_define_global_function("align_it_aa", (VALUE(*)(...))align_it_aa, 4);
VALUE gotoh = rb_define_module("CfeGotoh");
rb_define_module_function(gotoh, "align_it", (VALUE(*)(...))align_it, 4);
rb_define_module_function(gotoh, "align_it_aa", (VALUE(*)(...))align_it_aa, 4);
}

#endif
3 changes: 3 additions & 0 deletions ruby/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.gem
coverage/*
.DS_Store
9 changes: 9 additions & 0 deletions ruby/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
source 'https://rubygems.org'
ruby '2.2.2'

# To install all these gems, run "gem install bundler", then "bundle install".

gem 'minitest', '5.15.0'
gem 'minitest-reporters', '1.7.1'
gem 'simplecov', '0.17.1'
gem 'simplecov-cobertura', '1.4.2'
Loading

0 comments on commit d435a50

Please sign in to comment.