Skip to content

Commit

Permalink
Improvements in documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Old-Shatterhand committed Sep 21, 2024
1 parent 6d66bde commit 65c1d63
Show file tree
Hide file tree
Showing 6 changed files with 174 additions and 27 deletions.
7 changes: 7 additions & 0 deletions datasail/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ def parse_datasail_args(args) -> Dict[str, object]:
"clusters within the dataset.",
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
parser.add_argument(
"--cc",
default=False,
action='store_true',
dest=KW_CC,
help="List available clustering algorithms."
)
parser.add_argument(
"-o",
"--output",
Expand Down
22 changes: 19 additions & 3 deletions datasail/routine.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import time
from typing import Dict, Tuple
from typing import Dict, Tuple, Optional

from datasail.argparse_patch import remove_patch
from datasail.cluster.clustering import cluster
Expand All @@ -8,18 +8,34 @@
from datasail.report import report
from datasail.settings import LOGGER, KW_TECHNIQUES, KW_EPSILON, KW_RUNS, KW_SPLITS, KW_NAMES, \
KW_MAX_SEC, KW_MAX_SOL, KW_SOLVER, KW_LOGDIR, NOT_ASSIGNED, KW_OUTDIR, MODE_E, MODE_F, DIM_2, SRC_CL, KW_DELTA, \
KW_E_CLUSTERS, KW_F_CLUSTERS
KW_E_CLUSTERS, KW_F_CLUSTERS, KW_CC, CDHIT, INSTALLED, FOLDSEEK, TMALIGN, CDHIT_EST, DIAMOND, MMSEQS, MASH
from datasail.solver.solve import run_solver


def datasail_main(**kwargs) -> Tuple[Dict, Dict, Dict]:
def list_cluster_algos():
"""
List all available clustering algorithms.
"""

print("Available clustering algorithms:", "\tECFP", sep="\n")
for algo, name in [(CDHIT, "CD-HIT"), (CDHIT_EST, "CD-HIT-EST"), (DIAMOND, "DIAMOND"), (MMSEQS, "MMseqs, MMseqs2"),
(MASH, "MASH"), (FOLDSEEK, "FoldSeek"), (TMALIGN, "TMalign")]:
if INSTALLED[algo]:
print("\t", name, sep="")


def datasail_main(**kwargs) -> Optional[Tuple[Dict, Dict, Dict]]:
"""
Main routine of DataSAIL. Here the parsed input is aggregated into structures and then split and saved.
Args:
**kwargs: Parsed commandline arguments to DataSAIL.
"""
kwargs = remove_patch(**kwargs)
if kwargs[KW_CC]:
list_cluster_algos()
return None

start = time.time()
LOGGER.info("Read data")

Expand Down
1 change: 1 addition & 0 deletions datasail/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ def format2ending(fmt: str) -> str:

KW_CACHE = "cache"
KW_CACHE_DIR = "cache_dir"
KW_CC = "cc"
KW_CLI = "cli"
KW_DELTA = "delta"
KW_EPSILON = "epsilon"
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import sphinx_rtd_theme

sys.path.insert(0, os.path.abspath("./.."))
sys.path.insert(0, os.path.abspath("./."))

import datasail
from datasail.version import __version__
Expand All @@ -21,7 +22,7 @@
"sphinx.ext.githubpages",
"nbsphinx",
"nbsphinx_link",
"IPython.sphinxext.ipython_console_highlighting"
"IPython.sphinxext.ipython_console_highlighting",
]

autosummary_generate = True
Expand All @@ -45,7 +46,6 @@
intersphinx_mapping = {
"python": ("https://docs.python.org/", None),
"numpy": ("https://numpy.org/doc/stable/", None),
# "numpy": ("http://docs.scipy.org/doc/numpy", None),
}

html_theme_options = {
Expand Down
39 changes: 17 additions & 22 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,30 @@ datasets. However, its versatility extends beyond biology, making it applicable
utilized through its command line interface or integrated as a Python package, DataSAIL stands out for its
user-friendly design and adaptability. Licensed under the MIT license, it is open source and conveniently accessible on
`GitHub <https://github.com/kalininalab/datasail>`_. Installation is made simple through
`conda <https://anaconda.org/kalininalab/datasail>`_, utilizing
`mamba <https://mamba.readthedocs.io/en/latest/installation.html#existing-conda-install>`_.
`conda <https://anaconda.org/kalininalab/datasail>`_.

Quick Start
###########

DataSAIL is available for all modern versions of Pytion (v3.8 or newer). Other than described on the conda-website,
the command to install DataSAIL within your just created environment is

.. code-block:: shell
Install
#######

mamba install -c kalininalab -c conda-forge -c bioconda datasail
pip install grakel
DataSAIL is available for all modern versions of Pytion (v3.8 or newer).

The second command is necessary to run WLK clustering as the grakel library is not available on conda for python 3.10
or newer. Alternatively, one can install :code:`DataSAIL-lite` from conda as
.. note::
It is recommended to use `mamba <https://mamba.readthedocs.io/en/latest/installation.html#existing-conda-install>`_
for the installation because conda might not be able to resolve the dependencies of DataSAIL successfully.

.. code-block:: shell
.. raw:: html
:file: install.html

mamba install -c kalininalab -c conda-forge -c bioconda datasail-lite
pip install grakel
DataSAIL vs. DataSAIL-lite
--------------------------

.. note::
It is important to use mamba for the installation because conda might not be able to resolve the dependencies of
DataSAIL successfully.
The difference between :code:`DataSAIL` and :code:`DataSAIL-lite` is that the latter does not include most of the
clustering algorithms as they are not provide on conda for all OSs. Therefore, the user is required to the user to
install them manually as needed. DataSAIL will work even if not all clustering are installed. For the installation, is
it necessary to be able to call them. You can test which are available by running :code:`datasail --cc`.

The difference between :code:`DataSAIL` and :code:`DataSAIL-lite` is that the latter does not include the clustering
algorithms and requires the user to install them manually as needed. The reason for this is that the clustering
algorithms are not available for all OS and we want to make DataSAIL available for all OS.
Quick Start
###########

Regardless of which installation command was used, DataSAIL can be executed by running

Expand Down
128 changes: 128 additions & 0 deletions docs/install.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
<style>
.quick-start {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
margin-bottom: 20px;
}

.title-column {
flex-grow: 0;
}

.content-column {
flex-grow: 1;
}

.row {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
}

.title-column div, .row div {
white-space: nowrap;
}

.title-column div {
padding: 14px 10px 12px 0;
font-weight: 700;
}

.row div {
flex-grow: 1;
text-align: center;
margin: 2px;
padding: 12px 0 10px 0;
background: #e3e3e3;
cursor: pointer;
}

.row div.selected {
background: rgba(59,155,239,0.7);
color: #ffffff;
}

#command {
margin: 2px;
padding: 12px 10px 10px 10px;
}

#command pre {
padding: 0;
margin: 0;
white-space: pre-wrap;
}
</style>

<div class="quick-start">
<div class="title-column">
<div>OS</div>
<div>Package</div>
<div>Run:</div>
</div>
<div class="content-column">
<div class="row" id="os">
<div id="linux">Linux</div>
<div id="osx">OSX</div>
<div id="arm">OSX-ARM</div>
<div id="win">Windows</div>
</div>
<div class="row" id="package">
<div id="conda">Conda</div>
<div id="pip">Pip</div>
</div>
<div class="row" id="command">
<pre id="commandText">Command</pre>
</div>
</div>
</div>

<script type="text/javascript">
function updateCommand() {
// Get the attributes from the #command element
var commandElement = document.getElementById("command");
var os = commandElement.getAttribute("os");
var package = commandElement.getAttribute("package");

// Get the <pre> element inside the #command element
var preElement = commandElement.querySelector("pre");

// Update the text based on the conditions
if (package === "pip") {
preElement.textContent = '# datasail is not yet available on pip';
}
else if (os === "linux" || os === "osx") {
preElement.textContent = 'mamba install -c conda-force -c bioconda -c kalininalab datasail # or datasail-lite\n\npip install grakel<0.1.10';
}
else {
preElement.textContent = `mamba install -c conda-force -c bioconda -c kalininalab datasail-lite\n\npip install grakel<0.1.10`;
}
}

document.querySelectorAll(".quick-start .content-column .row div").forEach(function(element) {
element.addEventListener("click", function() {
// Remove the 'selected' class from all siblings
let siblings = this.parentNode.querySelectorAll('div');
siblings.forEach(function(sibling) {
sibling.classList.remove('selected');
});

// Add the 'selected' class to the clicked element
this.classList.add('selected');

// Get the parent row's id and the clicked element's id
let parentId = this.parentNode.id;
let elementId = this.id;

// Set the corresponding attribute on the #command element
document.getElementById("command").setAttribute(parentId, elementId);

// Call the updateCommand function
updateCommand();
});
});

document.getElementById("os").children[0].click();
document.getElementById("package").children[0].click();
</script>

0 comments on commit 65c1d63

Please sign in to comment.