-
Notifications
You must be signed in to change notification settings - Fork 4
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 #70 from remiolsen/dev
Merge dev
- Loading branch information
Showing
16 changed files
with
605 additions
and
72 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-dockerfile | ||
{ | ||
"name": "Anglerfish", | ||
"build": { | ||
// Sets the run context to one level up instead of the .devcontainer folder. | ||
"context": "..", | ||
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename. | ||
"dockerfile": "../Dockerfile", | ||
// Use devcontainer target | ||
"target": "devcontainer", | ||
}, | ||
"initializeCommand": "echo 'Workaround, see github https://github.com/microsoft/vscode-remote-release/issues/9302#issuecomment-1854476541'", | ||
"features": {}, | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"esbenp.prettier-vscode", | ||
"wholroyd.jinja", | ||
"ms-python.python", | ||
"[email protected]", | ||
"ms-azuretools.vscode-docker", | ||
], | ||
}, | ||
}, | ||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [], | ||
// "postCreateCommand": "pip3 install -e .", | ||
// Configure tool-specific properties. | ||
// "customizations": {}, | ||
// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root. | ||
// "remoteUser": "devcontainer" | ||
} |
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
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,16 +1,59 @@ | ||
FROM mambaorg/micromamba | ||
FROM mambaorg/micromamba as base | ||
|
||
LABEL author="Remi-Andre Olsen" \ | ||
description="Anglerfish development version" \ | ||
maintainer="[email protected]" | ||
|
||
USER root | ||
|
||
# Check for arm64 architecture to install minimap2 | ||
ARG TARGETARCH | ||
ENV MINIMAP_VERSION=2.26 | ||
RUN if [ "$TARGETARCH" = "arm64" ]; then \ | ||
# Install compliation tools for minimap2 | ||
apt-get update;\ | ||
apt-get install -y curl build-essential libz-dev;\ | ||
# Download minimap2 | ||
curl -L https://github.com/lh3/minimap2/archive/refs/tags/v${MINIMAP_VERSION}.tar.gz | tar -zxvf - ;\ | ||
# Compile minimap2 | ||
cd minimap2-${MINIMAP_VERSION};\ | ||
make arm_neon=1 aarch64=1; \ | ||
# Add to path | ||
mv minimap2 /usr/local/bin/;\ | ||
fi | ||
|
||
COPY --chown=$MAMBA_USER:$MAMBA_USER environment.yml / | ||
RUN micromamba env create -n anglerfish && micromamba install -y -n anglerfish -f /environment.yml && micromamba clean --all --yes | ||
ENV PATH /opt/conda/envs/anglerfish/bin:$PATH | ||
COPY --chown=$MAMBA_USER:$MAMBA_USER requirements.txt / | ||
|
||
# Remove minimap2 from environment.yml for arm64 | ||
RUN if [ "$TARGETARCH" = "arm64" ]; then \ | ||
grep -v 'minimap2' /environment.yml > /environment.tmp.yml ;\ | ||
else \ | ||
cp /environment.yml /environment.tmp.yml ;\ | ||
fi ;\ | ||
chown $MAMBA_USER:$MAMBA_USER /environment.tmp.yml | ||
|
||
# Add source files to the container | ||
ADD . /usr/src/anglerfish | ||
WORKDIR /usr/src/anglerfish | ||
RUN eval "$(micromamba shell hook --shell bash)" && micromamba activate anglerfish && python -m pip install .[dev] | ||
|
||
# Activate the environment | ||
ARG MAMBA_DOCKERFILE_ACTIVATE=1 | ||
RUN micromamba install -y -n base -f /environment.tmp.yml && micromamba clean --all --yes | ||
|
||
##### | ||
# Devcontainer | ||
##### | ||
FROM base as devcontainer | ||
|
||
# Useful tools for devcontainer | ||
RUN apt-get update;\ | ||
apt-get install -y git vim | ||
RUN eval "$(micromamba shell hook --shell bash)" && python -m pip install -e .[dev] | ||
|
||
##### | ||
# Main | ||
##### | ||
FROM base as main | ||
USER $MAMBA_USER | ||
RUN eval "$(micromamba shell hook --shell bash)" && python -m pip install .[dev] |
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 |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import importlib | ||
import os | ||
|
||
import yaml | ||
|
||
|
||
class Adaptor: | ||
def __init__(self, adaptors, delim, adaptor, i7_index=None, i5_index=None): | ||
self.i7 = AdaptorPart(adaptors[adaptor]["i7"], adaptor, delim, i7_index) | ||
self.i5 = AdaptorPart(adaptors[adaptor]["i5"], adaptor, delim, i5_index) | ||
self.name = f"{adaptor}" | ||
self.delim = delim | ||
|
||
def get_i7_mask(self, insert_Ns=True): | ||
return self.i7.get_mask(insert_Ns) | ||
|
||
def get_i5_mask(self, insert_Ns=True): | ||
return self.i5.get_mask(insert_Ns) | ||
|
||
def get_fastastring(self, insert_Ns=True): | ||
fasta_i5 = f">{self.name}_i5\n{self.get_i5_mask(insert_Ns)}\n" | ||
fasta_i7 = f">{self.name}_i7\n{self.get_i7_mask(insert_Ns)}\n" | ||
return fasta_i5 + fasta_i7 | ||
|
||
|
||
class AdaptorPart: | ||
def __init__(self, sequence, name, delim, index): | ||
self.sequence = sequence | ||
self.name = name | ||
self.delim = delim | ||
self.index = index | ||
|
||
def has_index(self): | ||
return self.sequence.find(self.delim) > -1 | ||
|
||
def len_before_index(self): | ||
return self.sequence.find(self.delim) | ||
|
||
def len_after_index(self): | ||
return len(self.sequence) - self.sequence.find(self.delim) - len(self.delim) | ||
|
||
def get_mask(self, insert_Ns): | ||
if self.has_index(): | ||
if not insert_Ns: | ||
return self.sequence.replace(self.delim, "") | ||
else: | ||
return self.sequence.replace(self.delim, "N" * len(self.index)) | ||
else: | ||
return self.sequence | ||
|
||
|
||
# Fetch all adaptors | ||
def load_adaptors(raw=False): | ||
p = importlib.resources.files("anglerfish.config").joinpath("adaptors.yaml") | ||
assert isinstance(p, os.PathLike) | ||
|
||
adaptors_raw = [] | ||
with open(p) as f: | ||
adaptors_raw = yaml.safe_load(f) | ||
|
||
if raw: | ||
return adaptors_raw | ||
adaptors = [] | ||
for adaptor in adaptors_raw: | ||
adaptors.append( | ||
Adaptor(adaptors_raw, "-NNN-", adaptor, i7_index=None, i5_index=None) | ||
) | ||
|
||
return adaptors |
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
Oops, something went wrong.