-
Notifications
You must be signed in to change notification settings - Fork 1
Feat: sym_redock_exlude_motifs feat added #49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
aimura09
wants to merge
2
commits into
main
Choose a base branch
from
dev_am
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -16,10 +16,11 @@ def get_sym_frames(symid, opt, cenvec): | |
| frames, _ = get_nneigh(allframes, min(len(allframes), opt.max_nsub)) | ||
| return allframes, frames | ||
|
|
||
| def sym_redock(xyz, Lasu, frames, opt, **_): | ||
| def sym_redock(xyz, Lasu, frames, opt, mask=None, **_): | ||
| # resolve clashes in placed subunits | ||
| # could probably use this to optimize the radius as well | ||
| def clash_error_comp(R0, T0, xyz, fit_tscale): | ||
| # mask: 1d th.Tensor or list | ||
| def clash_error_comp(R0, T0, xyz, fit_tscale, mask=None): | ||
| xyz0 = xyz[:Lasu] | ||
| xyz0_corr = xyz0.reshape(-1, 3) @ R0.T | ||
| xyz0_corr = xyz0_corr.reshape(xyz0.shape) + fit_tscale*T0 | ||
|
|
@@ -35,9 +36,18 @@ def clash_error_comp(R0, T0, xyz, fit_tscale): | |
| Xsymmall = Xsymmall[:, 0, :] | ||
| dsymm = th.cdist(Xsymmall, Xsymmall, p=2) | ||
| dsymm_2 = dsymm.clone() | ||
| if mask is not None: | ||
| mask0 = mask[:Lasu.item()] if isinstance(Lasu, th.Tensor) else th.tensor(mask[:Lasu]) | ||
|
||
| mask_dsymm = ~(mask0[None, :].expand(Lasu, Lasu)) | ||
| mask_dsymm = mask_dsymm | mask_dsymm.T | ||
| # dsymm_2 = dsymm.clone().fill_diagonal_(9999) # avoid in-place operation | ||
| for i in range(0, len(Xsymmall), Lasu): | ||
| dsymm_2[i:i + Lasu, i:i + Lasu] = 9999 | ||
| for i in range(0, len(Xsymmall), Lasu): # loop over rows | ||
| dsymm_2[i:i + Lasu, i:i + Lasu] = 9999 # masking intra-contact | ||
| if mask is not None: | ||
| for j in range(0, len(Xsymmall), Lasu): # loop over cols | ||
| if j == i: continue | ||
| # masking inter-contacts involving masked residues | ||
| dsymm_2[i:i + Lasu, j:j + Lasu][mask_dsymm] = 9999 | ||
| clash = th.clamp(opt.fit_wclash - dsymm_2, min=0) | ||
| loss = th.sum(clash) / Lasu | ||
| return loss | ||
|
|
@@ -54,7 +64,7 @@ def Q2R(Q): | |
|
|
||
| def closure(): | ||
| lbfgs.zero_grad() | ||
| loss = clash_error_comp(Q2R(Q0), T0, xyz, opt.fit_tscale) | ||
| loss = clash_error_comp(Q2R(Q0), T0, xyz, opt.fit_tscale, mask=mask) | ||
| loss.backward() #retain_graph=True) | ||
| return loss | ||
|
|
||
|
|
||
This file contains hidden or 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,17 @@ | ||
| BasedOnStyle: LLVM | ||
| Standard: Cpp11 | ||
| IndentWidth: 4 | ||
| TabWidth: 4 | ||
| UseTab: Never | ||
| ColumnLimit: 90 | ||
| AllowShortIfStatementsOnASingleLine: true | ||
| AllowShortCaseLabelsOnASingleLine: true | ||
| AlignConsecutiveShortCaseStatements: | ||
| Enabled: true | ||
| AcrossEmptyLines: true | ||
| AcrossComments: true | ||
| AllowShortBlocksOnASingleLine: true | ||
| AllowShortEnumsOnASingleLine: true | ||
| AllowShortFunctionsOnASingleLine: true | ||
| AllowShortLambdasOnASingleLine: true | ||
| AllowShortLoopsOnASingleLine: true |
This file contains hidden or 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,64 @@ | ||
| ## 🚀 Summary | ||
|
|
||
| <!-- | ||
| Explain what this PR does and why it matters. | ||
| Keep it short and focused. | ||
| --> | ||
|
|
||
| Closes #... | ||
|
|
||
| --- | ||
|
|
||
| ## 🔧 Type of change | ||
|
|
||
| <!-- Check the relevant boxes and update your PR title to follow Conventional Commits --> | ||
|
|
||
| - [ ] **feat**: A new feature | ||
| - [ ] **fix**: A bug fix | ||
| - [ ] **docs**: Documentation only changes | ||
| - [ ] **style**: Formatting, missing semi colons, etc | ||
| - [ ] **refactor**: Refactoring (no functional changes) | ||
| - [ ] **perf**: A code change that improves performance | ||
| - [ ] **test**: Adding or fixing tests | ||
| - [ ] **chore**: Maintenance and tooling | ||
| - [ ] **ci**: Changes to CI/CD configuration | ||
|
|
||
| --- | ||
|
|
||
| ## ✅ Checklist | ||
|
|
||
| - [ ] PR title uses [Conventional Commits](https://www.conventionalcommits.org/) | ||
| - [ ] Tests added or updated (if applicable) | ||
| - [ ] Documentation updated (if applicable) | ||
| - [ ] I have verified this builds and works as intended | ||
| - [ ] I’m ready for review! | ||
|
|
||
| --- | ||
|
|
||
| ## 🧪 Testing | ||
|
|
||
| <!-- | ||
| Explain how you tested your changes. | ||
| List commands, CI results, or screenshots if helpful. | ||
| --> | ||
|
|
||
| --- | ||
|
|
||
| ## 📦 Release impact | ||
|
|
||
| > semantic-release will determine version bump automatically. | ||
|
|
||
| - [ ] BREAKING CHANGE (explain in footer below) | ||
| - [ ] This should trigger a **patch** release | ||
| - [ ] This should trigger a **minor** release | ||
| - [ ] This is internal only — no release needed | ||
|
|
||
| If this is a breaking change, explain why below. | ||
|
|
||
| --- | ||
|
|
||
| ## 📓 Notes for reviewer | ||
|
|
||
| <!-- | ||
| Optional: anything you'd like the reviewer to focus on, be aware of, or follow up later. | ||
| --> |
This file contains hidden or 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,102 @@ | ||
| name: Build and upload to PyPI | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| pull_request: | ||
| push: | ||
| # branches: | ||
| # - main | ||
| release: | ||
| types: | ||
| - published | ||
|
|
||
| jobs: | ||
| build_wheels: | ||
| name: Build wheels for ${{ matrix.os }} | ||
| runs-on: ${{ matrix.runs-on }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| os: [ linux-intel, linux-arm, macOS-intel, macOS-arm ] | ||
| # os: [ linux-intel, linux-arm, windows, macOS-intel, macOS-arm ] | ||
| include: | ||
| - archs: auto | ||
| platform: auto | ||
| - os: linux-intel | ||
| runs-on: ubuntu-latest | ||
| - os: linux-arm | ||
| runs-on: ubuntu-24.04-arm | ||
| # - os: windows | ||
| # runs-on: windows-latest | ||
| - os: macos-intel | ||
| # macos-13 was the last x86_64 runner | ||
| runs-on: macos-13 | ||
| - os: macos-arm | ||
| # macos-14+ (including latest) are ARM64 runners | ||
| runs-on: macos-latest | ||
| archs: auto,universal2 | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Build wheels | ||
| uses: pypa/cibuildwheel@v2.23.1 | ||
| env: | ||
| CIBW_PLATFORM: ${{ matrix.platform }} | ||
| CIBW_ARCHS: ${{ matrix.archs }} | ||
| # Can also be configured directly, using `with:` | ||
| # with: | ||
| # package-dir: . | ||
| # output-dir: wheelhouse | ||
| # config-file: "{package}/pyproject.toml" | ||
|
|
||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@v5 | ||
| with: | ||
| version: "0.6.8" | ||
| enable-cache: true | ||
|
|
||
| - name: Test wheels | ||
| run: | | ||
| echo "Testing wheels with nox" | ||
| uv run --extra dev nox | ||
|
|
||
| - uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} | ||
| path: ./wheelhouse/*.whl | ||
|
|
||
| build_sdist: | ||
| name: Build source distribution | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Build sdist | ||
| run: pipx run build --sdist | ||
|
|
||
| - uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: cibw-sdist | ||
| path: dist/*.tar.gz | ||
|
|
||
| upload_pypi: | ||
| needs: [build_wheels, build_sdist] | ||
| runs-on: ubuntu-latest | ||
| environment: pypi | ||
| permissions: | ||
| id-token: write | ||
| # if: github.event_name == 'release' && github.event.action == 'published' | ||
| # or, alternatively, upload to PyPI on every tag starting with 'v' (remove on: release above to use this) | ||
| # if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | ||
| steps: | ||
| - uses: actions/download-artifact@v4 | ||
| with: | ||
| # unpacks all CIBW artifacts into dist/ | ||
| pattern: cibw-* | ||
| path: dist | ||
| merge-multiple: true | ||
|
|
||
| - uses: pypa/gh-action-pypi-publish@release/v1 | ||
| # with: | ||
| # To test: repository-url: https://test.pypi.org/legacy/ |
This file contains hidden or 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,30 @@ | ||
| name: codecov | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ main ] | ||
| pull_request: | ||
| branches: [ main ] | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: '3.13' | ||
|
|
||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@v5 | ||
|
|
||
| - name: Run tests with coverage | ||
| run: | | ||
| uv run --extra all pytest --cov --cov-branch --cov-report=xml | ||
|
|
||
| - name: Upload coverage reports to Codecov | ||
| uses: codecov/codecov-action@v5 | ||
| with: | ||
| token: ${{ secrets.CODECOV_TOKEN }} |
This file contains hidden or 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,31 @@ | ||
| # .github/workflows/semantic-release.yaml | ||
|
|
||
| name: Semantic Release | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
|
|
||
| jobs: | ||
| release: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write # for tag, changelog commit, release | ||
| issues: write # optional if you want to use release notes | ||
| pull-requests: write # optional | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Lint commit messages | ||
| uses: wagoid/commitlint-github-action@v5 | ||
|
|
||
| - name: Semantic Release | ||
| uses: cycjimmy/semantic-release-action@v4 | ||
| with: | ||
| extra_plugins: | | ||
| @semantic-release/changelog | ||
| @semantic-release/git | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains hidden or 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,47 @@ | ||
| sublime_build.log* | ||
| wheelhouse | ||
| __pycache__ | ||
| *.egg-info | ||
| *.egg | ||
| *.pyc | ||
| evn/_build | ||
| __pycache__ | ||
| # Prerequisites | ||
| *.d | ||
|
|
||
| # Compiled Object files | ||
| *.slo | ||
| *.lo | ||
| *.o | ||
| *.obj | ||
|
|
||
| # Precompiled Headers | ||
| *.gch | ||
| *.pch | ||
|
|
||
| # Compiled Dynamic libraries | ||
| *.so | ||
| *.dylib | ||
| *.dll | ||
|
|
||
| # Fortran module files | ||
| *.mod | ||
| *.smod | ||
|
|
||
| # Compiled Static libraries | ||
| *.lai | ||
| *.la | ||
| *.a | ||
| *.lib | ||
|
|
||
| # Executables | ||
| *.exe | ||
| *.out | ||
| *.app | ||
|
|
||
| .doit.* | ||
| _build | ||
| *.sublime-workspace | ||
| /test-logs | ||
| .test* | ||
| *.orig |
This file contains hidden or 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,50 @@ | ||
| # .pre-commit-config.yaml | ||
| repos: | ||
| # ✅ Ruff: linter, formatter, isort | ||
| - repo: https://github.com/astral-sh/ruff-pre-commit | ||
| rev: v0.3.3 | ||
| hooks: | ||
| - id: ruff | ||
| args: [--fix, evn] | ||
|
|
||
| # ✅ Validate pyproject.toml metadata and structure | ||
| - repo: https://github.com/abravalheri/validate-pyproject | ||
| rev: v0.24.1 | ||
| hooks: | ||
| - id: validate-pyproject | ||
| # Optional extra validations from SchemaStore: | ||
| additional_dependencies: ["validate-pyproject-schema-store[all]"] | ||
|
|
||
| # ✅ Check for trailing whitespace, tabs, EOFs | ||
| - repo: https://github.com/pre-commit/pre-commit-hooks | ||
| rev: v4.5.0 | ||
| hooks: | ||
| - id: trailing-whitespace | ||
| - id: end-of-file-fixer | ||
| - id: check-yaml | ||
| - id: check-added-large-files | ||
|
|
||
| # ✅ Detect merge conflict markers | ||
| - repo: https://github.com/pre-commit/pre-commit-hooks | ||
| rev: v4.5.0 | ||
| hooks: | ||
| - id: check-merge-conflict | ||
|
|
||
| # ✅ Commitizen: Conventional Commit linter (Python-native) | ||
| - repo: https://github.com/commitizen-tools/commitizen | ||
| rev: v3.21.0 | ||
| hooks: | ||
| - id: commitizen | ||
| stages: [commit-msg] | ||
| language_version: python3.12 | ||
|
|
||
| - repo: https://github.com/christophmeissner/pytest-pre-commit | ||
| rev: 1.0.0 | ||
| hooks: | ||
| - id: pytest | ||
| args: [--ignore,evn/format,--ignore,evn/tests/format] | ||
| additional_dependencies: ['assertpy', 'click', 'icecream', 'multipledispatch', | ||
| 'PrettyPrintTree', 'pyyaml', 'rapidfuzz', 'rich', 'ruff', | ||
| 'typing_extensions; python_version < "3.10"', 'wrapt','hypothesis', 'ninja_import', 'tomli'] | ||
| pass_filenames: false | ||
| always_run: true |
This file contains hidden or 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 @@ | ||
| 3.13 |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a detailed docstring for the 'mask' parameter in sym_redock (and in clash_error_comp) that specifies the expected type (1D th.Tensor or list), shape, and intended behavior, to improve clarity and maintainability.