Skip to content

Commit 0fd4c8b

Browse files
Merge pull request #9 from prameshsharma25/docs
Implement Automatic CLI Documentation with MkDocs
2 parents af7009a + d5c0afe commit 0fd4c8b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+4905
-1323
lines changed

Makefile

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
format:
2-
black --line-length 79 .
2+
black .
33

44
lint:
55
flake8 .
@@ -20,4 +20,13 @@ twine-upload:
2020
twine upload dist/*
2121

2222
remove-dist:
23-
rm -rf dist/*
23+
rm -rf dist/*
24+
25+
generate-cli-docs:
26+
python3 scripts/generate_docs.py
27+
28+
serve-docs: generate-cli-docs
29+
mkdocs serve
30+
31+
install-docs:
32+
pip install '.[docs]'

SSDraw.ipynb

Lines changed: 0 additions & 1303 deletions
This file was deleted.

docs/commands/multi.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# SSDraw multi Command
2+
3+
This section documents the `ssdraw multi` command.
4+
5+
```bash
6+
usage: generate_docs.py multi [-h] -i INPUT -o OUTPUT
7+
8+
options:
9+
-h, --help show this help message and exit
10+
-i, --input INPUT Name of input script
11+
-o, --output OUTPUT Name of output directory
12+
```

docs/commands/single.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# SSDraw single Command
2+
3+
This section documents the `ssdraw single` command.
4+
5+
```bash
6+
usage: generate_docs.py single [-h] [-f FASTA] [-p PDB] [-n NAME] [-o OUTPUT] [--SS SS] [--chain_id CHAIN_ID] [--color_map [COLOR_MAP ...]]
7+
[--scoring_file SCORING_FILE] [--color COLOR] [-conservation_score] [--output_file_type OUTPUT_FILE_TYPE] [-bfactor]
8+
[-mview] [--dpi DPI] [--ticks TICKS] [--start START] [--end END] [--dssp_exe DSSP_EXE] [--consurf CONSURF]
9+
[--fontsize FONTSIZE] [--fontcolor FONTCOLOR]
10+
11+
options:
12+
-h, --help show this help message and exit
13+
-f, --fasta FASTA (required) sequence/alignment file in fasta format
14+
-p, --pdb PDB (required) pdb file
15+
-n, --name NAME (required) id of the protein in the alignment file
16+
-o, --output OUTPUT (required) name for output file
17+
--SS SS secondary structure annotation in DSSP or .horiz format. If this option is not provided, SSDraw will compute secondary structure
18+
from the given PDB file with DSSP.
19+
--chain_id CHAIN_ID chain id to use in pdb. Defaults to chain A.
20+
--color_map [COLOR_MAP ...]
21+
color map to use for heat map
22+
--scoring_file SCORING_FILE
23+
custom scoring file for alignment
24+
--color COLOR color for the image. Can be a color name (eg. white, black, green), or a hex code
25+
-conservation_score score alignment by conservation score
26+
--output_file_type OUTPUT_FILE_TYPE
27+
output file type. Options: png, ps, eps, tif, svg
28+
-bfactor score by B-factor
29+
-mview color by mview color map
30+
--dpi DPI dpi to use for final plot
31+
--ticks TICKS set ticks at every nth position
32+
--start START
33+
--end END
34+
--dssp_exe DSSP_EXE The path to your dssp executable. Default: mkdssp
35+
--consurf CONSURF consurf or rate4site file to color image with. If rate4site file is given, SSDraw will convert raw scores to grades.
36+
--fontsize FONTSIZE font size for residue numbers
37+
--fontcolor FONTCOLOR
38+
font color for residue numbers
39+
```

docs/getting-started.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
## Installation
2+
3+
The easiest way to install SSDraw is via pip:
4+
5+
```bash
6+
pip install SSDraw
7+
```
8+
9+
You can find the package on PyPi [here](https://pypi.org/project/SSDraw/).

docs/index.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# SSDraw
2+
SSDraw is a program that generates publication-quality protein secondary structure diagrams from three-dimensional protein structures. To depict relationships between secondary structure and other protein features, diagrams can be colored by conservation score, B-factor, or custom scoring.
3+
4+
SSDraw also has a **colab notebook** available (only usable for Chrome). The notebook can be accessed [here](https://colab.research.google.com/github/ethanchen1301/SSDraw/blob/main/SSDraw.ipynb).

docs/troubleshooting.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Troubleshooting & Common Issues
2+
3+
This section addresses frequently encountered problems and provides solutions.
4+
5+
***
6+
7+
## Issue: Amino Acid Sequence Overlap/Jumbling
8+
9+
### Problem
10+
When the secondary structure diagram is **quite long** (i.e., for large proteins), the residue numbering and/or **amino acid sequence often overlaps or becomes jumbled** together, making it unreadable.
11+
12+
### Solution
13+
You can adjust the size of the residue numbers and sequence labels by changing the default font size. Use the **`--fontsize`** flag followed by a numerical value. The default size is **12**, which may be too large for high-density diagrams. Try reducing it (e.g., `--fontsize 8`) until the text is clearly separated.
14+
15+
* **Example:** `ssdraw single ... --fontsize 8`
16+
17+
***
18+
19+
## Issue: Saving Secondary Structure to a Specific File Format
20+
21+
### Problem
22+
I need to save the generated secondary structure diagram in a **high-quality vector format** (like SVG or EPS) or a specific raster format (like TIFF) instead of the default PNG.
23+
24+
### Solution
25+
You can specify the desired output file type using the **`--output_file_type`** flag. This is particularly useful for generating **publication-quality figures**.
26+
27+
The supported output file types are: **`png`**, **`ps`**, **`eps`**, **`tif`**, and **`svg`**.
28+
29+
* **To save as a vector graphic:** `ssdraw single ... --output_file_type svg`
30+
* **To save as a high-resolution image:** `ssdraw single ... --output_file_type tif`
31+
32+
***

mkdocs.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
site_name: SSDraw
2+
3+
nav:
4+
- Home: 'index.md'
5+
- Getting Started: 'getting-started.md'
6+
- Modules:
7+
- single: 'commands/single.md'
8+
- multi: 'commands/multi.md'
9+
- Troubleshooting: 'troubleshooting.md'
10+
11+
theme: readthedocs

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ dependencies = [
2323
]
2424

2525
[project.optional-dependencies]
26-
tests = [
27-
"pytest"
26+
docs = [
27+
"mkdocs",
2828
]
2929

3030
[project.scripts]

scripts/generate_docs.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import io
2+
3+
from contextlib import redirect_stdout
4+
from SSDraw.cli import get_args
5+
6+
7+
def generate_help(command, filename):
8+
f = io.StringIO()
9+
with redirect_stdout(f):
10+
try:
11+
get_args(argv=[command, "--help"])
12+
except SystemExit:
13+
pass
14+
15+
help_output = f.getvalue()
16+
17+
with open(f"docs/commands/{filename}.md", "w") as doc_file:
18+
doc_file.write(f"# SSDraw {command} Command\n\n")
19+
doc_file.write(f"This section documents the `ssdraw {command}` command.\n\n")
20+
doc_file.write("```bash\n")
21+
doc_file.write(help_output)
22+
doc_file.write("```\n")
23+
24+
25+
if __name__ == "__main__":
26+
generate_help("single", "single")
27+
generate_help("multi", "multi")
28+
29+
print("CLI documentation updated in docs/commands/")

0 commit comments

Comments
 (0)