Skip to content

Commit

Permalink
fixed autometic version build
Browse files Browse the repository at this point in the history
  • Loading branch information
mazzalab committed Nov 19, 2024
1 parent d6c81e1 commit e5dd776
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 97 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
data/*
!data/sample_R1.fastq.gz
!data/sample_R2.fastq.gz
conda-recipe/record.txt

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
14 changes: 0 additions & 14 deletions conda-recipe/_conda_build_config.yaml

This file was deleted.

24 changes: 4 additions & 20 deletions conda-recipe/build.sh
Original file line number Diff line number Diff line change
@@ -1,24 +1,8 @@
#!/bin/sh

mkdir -p $PREFIX/lib/python$PY_VER/site-packages/tests/testdata
cp -r tests/testdata/* $PREFIX/lib/python$PY_VER/site-packages/tests/testdata/

# Read the "versions" file located one directory up
VERSION_FILE="../versions"

# Extract the version for "wipertools"
if [ -f "$VERSION_FILE" ]; then
WIPERTOOLS_VERSION=$(grep "^wipertools:" "$VERSION_FILE" | cut -d':' -f2 | tr -d '[:space:]')
export WIPERTOOLS_VERSION
else
echo "Error: versions file not found!"
exit 1
fi

WIPERTOOLS_VERSION=1.1.1
export WIPERTOOLS_VERSION

# # Print the version (optional, for debugging)
# echo "WIPERTOOLS_VERSION is set to $WIPERTOOLS_VERSION"
# mkdir -p $PREFIX/lib/python$PY_VER/site-packages/tests/testdata
# cp -r tests/testdata/* $PREFIX/lib/python$PY_VER/site-packages/tests/testdata/
mkdir -p $PREFIX/lib/python$PY_VER/site-packages/
cp versions.json $PREFIX/lib/python$PY_VER/site-packages/

$PYTHON setup.py install --single-version-externally-managed --record=$RECIPE_DIR/record.txt
12 changes: 4 additions & 8 deletions conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
{% set data = load_setup_py_data(setup_file="setup.py") %}
{% set version = data.get('version') %}

# https://docs.conda.io/projects/conda-build/en/latest/resources/define-metadata.html
# https://docs.conda.io/projects/conda-build/en/latest/resources/define-metadata.html#:~:text=%7B%7B%20version%20%7D%7D-,load_file_data,-%3A%20Parse%20JSON%2C%20TOML

{% set data = load_file_data('versions.json') %}
{% set version = data.get('wipertools') %}
{% set sha256 = "898812fc8d2ac86f22f4da9e24eb707383a681c8553aa6813a05b108c8e10582" %}

package:
Expand All @@ -23,16 +19,16 @@ build:
# number: { { environ.get('GITHUB_RUN_NUMBER', 0) } }
number: 0
noarch: python
# script: {{ PYTHON }} -m pip install . -vv --no-deps --no-build-isolation
run_exports:
- {{ pin_subpackage('wipertools', max_pin="x.x") }}
entry_points:
- wipertools = fastqwiper.wipertools:main
script_env:
- WIPERTOOLS_VERSION={{version}}

requirements:
host:
- python >=3.7
- pip
- setuptools
run:
- python >=3.7
Expand Down
25 changes: 0 additions & 25 deletions conda-recipe/record.txt

This file was deleted.

49 changes: 38 additions & 11 deletions fastqwiper/summary_gather.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class GatherSummaries(WiperTool):
def __init__(self):
super().__init__("summarygatherer")
super().__init__("summarygather")

# Inherited methods
def set_parser(self, parser: argparse.ArgumentParser):
Expand Down Expand Up @@ -55,40 +55,67 @@ def parse_summary_file(filepath):
if line.startswith(TOTAL_LINES):
right = line.split(':')[1]
m = re.match(INT_REGEX, right)
data[TOTAL_LINES] = int(m.group('var'))
if(m):
data[TOTAL_LINES] = int(m.group('var'))
else:
raise ValueError(f"TOT_LINES match failed for line: {right}")
elif line.startswith(WELLFORMED):
right = line.split(':')[1]
m = re.match(INT_PERCENT_REGEX, right)
data[WELLFORMED] = int(m.group('var'))
if m:
raise ValueError(f"WELLFORMED match failed for line: {right}")
else:
data[WELLFORMED] = 0
elif line.startswith(CLEAN):
right = line.split(':')[1]
m = re.match(INT_REGEX, right)
data[CLEAN] = int(m.group('var'))
if m:
data[CLEAN] = int(m.group('var'))
else:
raise ValueError(f"CLEAN match failed for line: {right}")
elif line.startswith(MISPLACED_HEADER):
right = line.split(':')[1]
m = re.match(INT_INT_REGEX, right)
data[MISPLACED_HEADER] = int(m.group('var'))
data[RECOVERED_HEADER] = int(m.group('var2'))
if m:
data[MISPLACED_HEADER] = int(m.group('var'))
data[RECOVERED_HEADER] = int(m.group('var2'))
else:
raise ValueError(f"MISPLACED_HEADER and RECOVERED_HEADER match failed for line: {right}")
elif line.startswith(BAD_SEQ):
right = line.split(':')[1]
m = re.match(INT_PERCENT_REGEX, right)
data[BAD_SEQ] = int(m.group('var'))
if m:
data[BAD_SEQ] = int(m.group('var'))
else:
raise ValueError(f"BAD_SEQ match failed for line: {right}")
elif line.startswith(BAD_PLUS):
right = line.split(':')[1]
m = re.match(INT_PERCENT_REGEX, right)
data[BAD_PLUS] = int(m.group('var'))
if m:
data[BAD_PLUS] = int(m.group('var'))
else:
raise ValueError(f"BAD_PLUS match failed for line: {right}")
elif line.startswith(BAD_QUAL):
right = line.split(':')[1]
m = re.match(INT_PERCENT_REGEX, right)
data[BAD_QUAL] = int(m.group('var'))
if m:
data[BAD_QUAL] = int(m.group('var'))
else:
raise ValueError(f"BAD_QUAL match failed for line: {right}")
elif line.startswith(LENGTH_SEQ_QUAL):
right = line.split(':')[1]
m = re.match(INT_REGEX, right)
data[LENGTH_SEQ_QUAL] = int(m.group('var'))
if m:
data[LENGTH_SEQ_QUAL] = int(m.group('var'))
else:
raise ValueError(f"LENGTH_SEQ_QUAL match failed for line: {right}")
elif line.startswith(BLANKS):
right = line.split(':')[1]
m = re.match(INT_PERCENT_REGEX, right)
data[BLANKS] = int(m.group('var'))
if m:
data[BLANKS] = int(m.group('var'))
else:
raise ValueError(f"BLANKS match failed for line: {right}")

return data

Expand Down
7 changes: 4 additions & 3 deletions fastqwiper/wipertool_abstract.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from abc import ABC, abstractmethod
from argparse import Namespace
import json
import os


Expand All @@ -10,9 +11,9 @@ class WiperTool(ABC):
def __init__(self, name):
self.name = name

versions_file_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'versions')
with open(versions_file_path, 'r') as file:
self.config = {line.split(':')[0]: line.split(':')[1].strip() for line in file if line.strip()}
versions_file_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'versions.json')
with open(versions_file_path) as f:
self.config = json.load(f)

def version(self):
return self.config.get(self.name, "")
Expand Down
11 changes: 10 additions & 1 deletion fastqwiper/wipertools.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys
import json
import os.path

sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
Expand All @@ -12,6 +13,8 @@

def main():
parser = argparse.ArgumentParser(description='FastqWiper program help')
parser.add_argument('-v', '--version', action='version', version=version(), help='It prints the version and exists')

subparsers = parser.add_subparsers(help='Choices', dest='selected_subparser')

# create the parser for the FastqWiper main program
Expand All @@ -30,7 +33,7 @@ def main():
fg.set_parser(fg_parser)

# create the parser for the gather_summaries program
sg_parser = subparsers.add_parser('summarygather', help='Gatherer of FastqWiper summary files')
sg_parser = subparsers.add_parser('summarygather', help='Summary gather program')
sg = GatherSummaries()
sg.set_parser(sg_parser)

Expand All @@ -49,5 +52,11 @@ def main():
parser.print_help()


def version():
versions_file_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'versions.json')
with open(versions_file_path) as f:
config = json.load(f)
return config.get("wipertools", "")

if __name__ == "__main__":
main()
13 changes: 3 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
import os
from setuptools import setup, find_packages

# version='0.0.1'
# if '--wipertools_version' in sys.argv:
# version_idx = sys.argv.index('--wipertools_version')
# version = sys.argv[version_idx + 1]
# sys.argv.remove('--wipertools_version')
# sys.argv.pop(version_idx)

version_string = os.environ.get("WIPERTOOLS_VERSION", "0.0.0.dev0")

setup(
name="wipertools",
version=version_string,
packages=find_packages(),
packages=find_packages(exclude=("tests",)),
# https://setuptools.pypa.io/en/latest/userguide/datafiles.html
# package_data={"": ["*.txt"], "mypkg1": ["data1.rst"]},
# include_package_data=True,
# exclude_package_data={"mypkg": [".gitattributes"]},
install_requires=["setuptools"],
# exclude_package_data={"tests": [""]},
install_requires=[],
entry_points={
"console_scripts": [
"wipertools=fastqwiper.wipertools:main"
Expand Down
Empty file removed version.json
Empty file.
5 changes: 0 additions & 5 deletions versions

This file was deleted.

7 changes: 7 additions & 0 deletions versions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"wipertools": "1.1.0",
"fastqwiper": "1.0.1",
"fastqscatter": "1.0.0",
"fastqgather": "1.0.0",
"summarygather": "1.0.0"
}

0 comments on commit e5dd776

Please sign in to comment.