Skip to content

Commit

Permalink
Merge pull request #29 from dnanto/pypackage
Browse files Browse the repository at this point in the history
Pypackage
  • Loading branch information
dnanto authored Aug 17, 2024
2 parents afcd4da + e0a0c7b commit e2fb15d
Show file tree
Hide file tree
Showing 13 changed files with 525 additions and 260 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
paper/paper.html
paper/paper.log
paper/paper.pdf
/py/src/democapsid.egg-info
156 changes: 78 additions & 78 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -3,102 +3,37 @@

cff-version: 1.2.0
title: >-
democapsid
message: 'If you use this software, please cite it as below.'
democapsid
message: "If you use this software, please cite it as below."
type: software
authors:
- given-names: Daniel
family-names: Negrón
email: [email protected]
affiliation: George Mason University
orcid: 'https://orcid.org/0000-0002-6123-2441'
identifiers:
- type: doi
value: 10.1101/2020.12.02.408252
description: The bioRxiv preprint of the paper.
repository-code: 'https://github.com/dnanto/democapsid'
url: 'https://github.com/dnanto/democapsid/capsid.html'
abstract: >-
This work implements Caspar-Klug Theory to
generate high-quality, vectorized capsid cartoons
in the browser and is the first online tool that
provides comprehensive style customization,
geometry, and SVG export of icosahedra and nets
with different lattice structures.
keywords:
- virus
- capsid
- caspar-klug
- moody
- icosahedron
- prolate
- oblate
- elongated
- lattice
- 2D
- 3D
- svg
- biology
- graphics
- render
- projection
- perspective
- publication
- figure
- demoscene
license: MIT
preferred-citation:
type: article
authors:
- given-names: Daniel
family-names: Negrón
email: [email protected]
affiliation: George Mason University
orcid: 'https://orcid.org/0000-0002-6123-2441'
doi: 10.1101/2020.12.02.408252
journal: bioRxiv
abstract: >-
orcid: "https://orcid.org/0000-0002-6123-2441"
identifiers:
- type: doi
value: 10.1101/2020.12.02.408252
description: The bioRxiv preprint of the paper.
repository-code: "https://github.com/dnanto/democapsid"
url: "https://github.com/dnanto/democapsid/capsid.html"
abstract: >-
This work implements Caspar-Klug Theory to
generate high-quality, vectorized capsid cartoons
in the browser and is the first online tool that
provides comprehensive style customization,
geometry, and SVG export of icosahedra and nets
with different lattice structures.
Motivation Few online services exist for rendering
high-quality viral capsid figures compatible with
common productivity software to develop effective
infographics in the field of virology.
Results The capsid.js library renders class I viral
capsids within an online application that
parameterizes style options, perspectives, and
lattice patterns with SVG export.
Availability This project is actively developed on
GitHub (https://github.com/dnanto/capsid),
distributed under the MIT License, hosted on GitHub
Pages, and runs on modern browsers
(https://dnanto.github.io/capsid/capsid.html).
Supplementary information Supplementary data are
available on GitHub.
month: 12
title: >-
Vectorized Capsid Rendering in the Browser with
Capsid.js
year: 2021
keywords:
keywords:
- virus
- capsid
- caspar-klug
- moody
- icosahedron
- prolate
- oblate
- elongated
- elongated
- lattice
- 2D
- 3D
Expand All @@ -110,4 +45,69 @@ preferred-citation:
- perspective
- publication
- figure
- demoscene
- demoscene
license: MIT
preferred-citation:
type: article
authors:
- given-names: Daniel
family-names: Negrón
email: [email protected]
affiliation: George Mason University
orcid: "https://orcid.org/0000-0002-6123-2441"
doi: 10.1101/2020.12.02.408252
journal: bioRxiv
abstract: >-
This work implements Caspar-Klug Theory to
generate high-quality, vectorized capsid cartoons
in the browser and is the first online tool that
provides comprehensive style customization,
geometry, and SVG export of icosahedra and nets
with different lattice structures.
Motivation Few online services exist for rendering
high-quality viral capsid figures compatible with
common productivity software to develop effective
infographics in the field of virology.
Results The capsid.js library renders class I viral
capsids within an online application that
parameterizes style options, perspectives, and
lattice patterns with SVG export.
Availability This project is actively developed on
GitHub (https://github.com/dnanto/capsid),
distributed under the MIT License, hosted on GitHub
Pages, and runs on modern browsers
(https://dnanto.github.io/capsid/capsid.html).
Supplementary information Supplementary data are
available on GitHub.
month: 12
title: >-
Vectorized Capsid Rendering in the Browser with
Capsid.js
year: 2021
keywords:
- 2D
- 3D
- biology
- capsid
- caspar-klug
- demoscene
- elongated
- figure
- graphics
- icosahedron
- lattice
- oblate
- perspective
- projection
- prolate
- publication
- render
- svg
- virology
- virus
4 changes: 4 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- [ ] comments/documentation
- [ ] python package
- [ ] R package
- [ ] Blender addo
3 changes: 0 additions & 3 deletions democapsid/README.md

This file was deleted.

1 change: 0 additions & 1 deletion democapsid/src/__init__.py

This file was deleted.

6 changes: 0 additions & 6 deletions env.yml

This file was deleted.

21 changes: 21 additions & 0 deletions py/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 - 2024, Daniel Antonio Negrón (dnanto/remaindeer)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
6 changes: 6 additions & 0 deletions py/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
==========
democapsid
==========


Calculate meshes for icosahedral virus capsids.
2 changes: 1 addition & 1 deletion democapsid/pyproject.toml → py/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ authors = [
maintainers = [
{ name="Daniel Antonio Negrón", email="[email protected]" },
]
description = "This package includes methods to calculate the coordinates of viral capsids."
description = "Calculate meshes for icosahedral virus capsids."
readme = "README.md"
license = {text = "MIT License"}
requires-python = ">=3.9.11"
Expand Down
7 changes: 7 additions & 0 deletions py/src/democapsid/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env python3

"""Top-level package for democapsid."""

__author__ = """Daniel Antonio Negrón"""
__email__ = '[email protected]'
__version__ = '0.0.1'
24 changes: 24 additions & 0 deletions py/src/democapsid/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env python3

import sys

from .cli import parse_args
from .democapsid import calc_ckm, calc_ckv, calc_ico, calc_lattice, cylinderize

args = parse_args(sys.argv[1:])
h, k, H, K, a, R, t, s, m = (getattr(args, key) for key in "h,k,H,K,a,R,t,s,m".split(","))
iter, tol = args.iter, args.tol

ckp = (h, k, H, K)
lat = calc_lattice(t, R)

if m == "ico":
meshes = calc_ico(ckp, lat, a=a, s=s, iter=iter, tol=tol)
elif m == "tri":
meshes = calc_ckm(ckp, lat)

print("x", "y", "z", "face", "polygon", "point", sep="\t")
for i, mesh in enumerate(meshes[1:], start=1):
for j, polygon in enumerate(mesh, start=1):
for k, point in enumerate(polygon[0], start=1):
print(*point, i, j, k, sep="\t")
23 changes: 23 additions & 0 deletions py/src/democapsid/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env python3

def parse_args(argv):
from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser
parser = ArgumentParser(
prog="democapsid",
formatter_class=ArgumentDefaultsHelpFormatter,
description="Calculate meshes for icosahedral virus capsids."
)
for ele in "hkHK":
parser.add_argument(ele, default=1, type=int, help=f"the {ele} Caspar-Klug parameter")
choices = (5, 3, 2)
parser.add_argument("-a", "-axis", default=choices[0], choices=choices, type=int, help=f"the axial symmetry: {choices}")
parser.add_argument("-R", "-radius", default=1, type=int, help="the hexagonal lattice unit circumradius")
choices = ("hex", "trihex", "snubhex", "rhombitrihex")
choices = (*choices, *("dual" + ele for ele in choices))
parser.add_argument("-t", "-tile", default=choices[0], choices=choices, help="the hexagonal lattice unit tile")
parser.add_argument("-s", "-sphericity", default=0, type=float, help="the sphericity value")
choices = ("ico", "tri")
parser.add_argument("-m", "-mode", default=choices[0], choices=choices, help="the render mode")
parser.add_argument("-iter", default=100, type=int, help="the number of iterations for numerical methods")
parser.add_argument("-tol", default=1E-15, type=float, help="the machine epsilon")
return parser.parse_args(argv)
Loading

0 comments on commit e2fb15d

Please sign in to comment.