From 63accca47feebdfaa4498d907cd08d2148c02180 Mon Sep 17 00:00:00 2001 From: Kai Zhang Date: Wed, 2 Oct 2024 08:34:24 +0800 Subject: [PATCH] add more workflows --- .github/workflows/nightly.yml | 68 +++++++++++++ .github/workflows/test_python.yml | 6 +- .github/workflows/wheels.yml | 68 +++++++++++++ python/src/utils.rs | 2 +- seqspec_templates/10x_atac.yaml | 152 ++++++++++++++++++++++++++++++ 5 files changed, 294 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/nightly.yml create mode 100644 .github/workflows/wheels.yml create mode 100644 seqspec_templates/10x_atac.yaml diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml new file mode 100644 index 0000000..7398eb6 --- /dev/null +++ b/.github/workflows/nightly.yml @@ -0,0 +1,68 @@ +name: nightly-run + +on: + schedule: + - cron: '0 0 * * *' # Runs every day at midnight + +jobs: + check-for-new-commits: + runs-on: ubuntu-latest + outputs: + NEW_COMMITS: ${{ steps.check-commits.outputs.NEW_COMMITS }} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Get latest commit SHA + id: get-latest-commit-sha + run: echo "LATEST_COMMIT_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV + + - name: Check last run + id: check-commits + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + latest_run_commit_sha=$(curl --silent --header "Authorization: token $GITHUB_TOKEN" \ + "https://api.github.com/repos/$GITHUB_REPOSITORY/actions/workflows/nightly.yml/runs?status=success&&per_page=1" \ + | jq -r '.workflow_runs | first | .head_sha') + echo "Latest completed run was on commit: $latest_run_commit_sha" + echo "Current commit is: $LATEST_COMMIT_SHA" + if [ "$latest_run_commit_sha" != "$LATEST_COMMIT_SHA" ]; then + echo "NEW_COMMITS=true" >> "$GITHUB_OUTPUT" + else + echo "NEW_COMMITS=false" >> "$GITHUB_OUTPUT" + fi + + build-wheel: + needs: check-for-new-commits + if : ${{ needs.check-for-new-commits.outputs.NEW_COMMITS == 'true' }} + uses: kaizhang/SnapATAC2/.github/workflows/wheels.yml@main + + publish: + needs: build-wheel + runs-on: ubuntu-latest + steps: + - name: Download wheel files + uses: actions/download-artifact@v4 + with: + path: dist + pattern: precellar-* + merge-multiple: true + + - name: Delete Release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + if gh release view nightly > /dev/null 2>&1; then + gh release delete nightly -y --cleanup-tag + fi + + - name: Create nightly release + uses: ncipollo/release-action@v1 + with: + allowUpdates: true + tag: nightly + name: Nightly Release + prerelease: true + removeArtifacts: true + artifacts: "dist/*.whl,dist/*.tar.gz" \ No newline at end of file diff --git a/.github/workflows/test_python.yml b/.github/workflows/test_python.yml index 56ed41e..f9a3ee1 100644 --- a/.github/workflows/test_python.yml +++ b/.github/workflows/test_python.yml @@ -46,4 +46,8 @@ jobs: uses: actions/upload-artifact@v4 with: name: wheel-files - path: ./wheel_files/precellar*.whl \ No newline at end of file + path: ./wheel_files/precellar*.whl + + build-wheel: + needs: build-and-test + uses: kaizhang/SnapATAC2/.github/workflows/wheels.yml@main \ No newline at end of file diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml new file mode 100644 index 0000000..8fb5152 --- /dev/null +++ b/.github/workflows/wheels.yml @@ -0,0 +1,68 @@ +name: build-wheels +on: + workflow_call + +jobs: + build_wheels: + name: Wheel on ${{ matrix.os }} for ${{ matrix.python_version }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-13, macos-14] + python_version: ["cp39-*", "cp310-*", "cp311-*", "cp312-*"] + env: + CIBW_BUILD_VERBOSITY: 1 + CIBW_BEFORE_ALL_LINUX: > + curl https://sh.rustup.rs -sSf | sh -s -- -y && yum install -y openssl-devel zlib-devel + + CIBW_ARCHS_LINUX: "auto64" + CIBW_ENVIRONMENT: 'PATH="$PATH:$HOME/.cargo/bin"' + CIBW_SKIP: "pp* *-win32 *-musllinux*" + CIBW_BUILD: ${{ matrix.python_version }} + #CIBW_TEST_REQUIRES: pytest hypothesis==6.72.4 + #CIBW_TEST_COMMAND: "pytest {project}/snapatac2-python/tests" + + steps: + - name: Checkout code + uses: nschloe/action-cached-lfs-checkout@v1 + + - uses: ./.github/actions/setup-rust + + # Used to host cibuildwheel + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Install cibuildwheel + run: python -m pip install cibuildwheel==2.20.0 + + - name: Build wheels + run: python -m cibuildwheel --output-dir wheelhouse python + + - uses: actions/upload-artifact@v4 + with: + name: precellar-${{ matrix.os }}-${{ strategy.job-index }} + path: ./wheelhouse/*.whl + + make_sdist: + name: Build source distribution + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v4 + name: Install Python + with: + python-version: '3.10' + + - name: Install maturin + run: pip install maturin + + - name: Build sdist + run: maturin sdist + working-directory: python + + - uses: actions/upload-artifact@v4 + with: + name: precellar-sdist + path: python/target/wheels/*.tar.gz \ No newline at end of file diff --git a/python/src/utils.rs b/python/src/utils.rs index b52c000..2162003 100644 --- a/python/src/utils.rs +++ b/python/src/utils.rs @@ -21,7 +21,7 @@ use regex::Regex; /// Extract barcodes from read names of BAM records using regular expressions. /// Reguler expressions should contain exactly one capturing group /// (Parentheses group the regex between them) that matches -/// the barcodes. For example, `barcode_regex="(..:..:..:..):\\\\w+$"` +/// the barcodes. For example, `barcode_regex="(..:..:..:..):\\w+$"` /// extracts `bd:69:Y6:10` from /// `A01535:24:HW2MMDSX2:2:1359:8513:3458:bd:69:Y6:10:TGATAGGTTG`. /// You can test your regex on this website: https://regex101.com/. diff --git a/seqspec_templates/10x_atac.yaml b/seqspec_templates/10x_atac.yaml new file mode 100644 index 0000000..c983b82 --- /dev/null +++ b/seqspec_templates/10x_atac.yaml @@ -0,0 +1,152 @@ +!Assay +seqspec_version: 0.3.0 +assay_id: 10xATAC +name: 10x-ATAC +doi: https://www.10xgenomics.com/blog/demonstrated-protocol-for-nuclei-isolation-for-single-cell-atac-solution +date: 19 October 2018 +description: Single Cell ATAC +modalities: +- atac +lib_struct: https://teichlab.github.io/scg_lib_structs/methods_html/10xChromium_scATAC.html +library_protocol: Custom +library_kit: Custom +sequence_protocol: Illumina +sequence_kit: Custom +sequence_spec: +- !Read + read_id: R1 + name: Read 1 + modality: atac + primer_id: nextera_read1 + min_len: 1 + max_len: 98 + strand: pos +- !Read + read_id: I1 + name: Index 1 (i7 index) + modality: atac + primer_id: nextera_read2 + min_len: 8 + max_len: 8 + strand: pos +- !Read + read_id: I2 + name: Index 2 (i5 index) + modality: atac + primer_id: nextera_read1 + min_len: 16 + max_len: 16 + strand: neg +- !Read + read_id: R2 + name: Read 2 + modality: atac + primer_id: nextera_read2 + min_len: 1 + max_len: 98 + strand: neg +library_spec: +- !Region + region_id: atac + region_type: atac + name: atac + sequence_type: joined + sequence: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXNNNNNNNNNNNNNNNNTCGTCGGCAGCGTCAGATGTGTATAAGAGACAGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXCTGTCTCTTATACACATCTCCGAGCCCACGAGACNNNNNNNNATCTCGTATGCCGTCTTCTGCTTG + min_len: 145 + max_len: 1144 + onlist: null + regions: + - !Region + region_id: illumina_p5 + region_type: illumina_p5 + name: Illumina P5 + sequence_type: random + sequence: XXXXXXXXXXXXXXXXXXXXXXXXXXXXX + min_len: 29 + max_len: 29 + onlist: null + regions: null + parent_id: atac + - !Region + region_id: cell_bc + region_type: barcode + name: Cell Barcode + sequence_type: onlist + sequence: NNNNNNNNNNNNNNNN + min_len: 16 + max_len: 16 + onlist: !Onlist + file_id: 737K-cratac-v1.txt.gz + filename: 737K-cratac-v1.txt.gz + filetype: txt + filesize: 0 + url: https://teichlab.github.io/scg_lib_structs/data/10X-Genomics/737K-cratac-v1.txt.gz + urltype: https + md5: null + location: remote + regions: null + parent_id: atac + - !Region + region_id: nextera_read1 + region_type: nextera_read1 + name: nextera_read1 + sequence_type: fixed + sequence: TCGTCGGCAGCGTCAGATGTGTATAAGAGACAG + min_len: 33 + max_len: 33 + onlist: null + regions: null + parent_id: atac + - !Region + region_id: gdna + region_type: gdna + name: gdna + sequence_type: random + sequence: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + min_len: 1 + max_len: 1000 + onlist: null + regions: null + parent_id: atac + - !Region + region_id: nextera_read2 + region_type: nextera_read2 + name: nextera_read2 + sequence_type: fixed + sequence: CTGTCTCTTATACACATCTCCGAGCCCACGAGAC + min_len: 34 + max_len: 34 + onlist: null + regions: null + parent_id: atac + - !Region + region_id: index7 + region_type: index7 + name: index7 + sequence_type: onlist + sequence: NNNNNNNN + min_len: 8 + max_len: 8 + onlist: !Onlist + file_id: index7_onlist.txt + filename: index7_onlist.txt + filetype: '' + filesize: 0 + url: '' + urltype: local + md5: null + location: local + regions: null + parent_id: atac + - !Region + region_id: illumina_p7 + region_type: illumina_p7 + name: Illumina P7 + sequence_type: fixed + sequence: ATCTCGTATGCCGTCTTCTGCTTG + min_len: 24 + max_len: 24 + onlist: null + regions: null + parent_id: atac + parent_id: null \ No newline at end of file