Skip to content

Commit

Permalink
Merge pull request #24 from biowasm/v2
Browse files Browse the repository at this point in the history
Aioli v2
  • Loading branch information
robertaboukhalil authored Jul 22, 2021
2 parents f7ed43a + aff4cda commit e24214f
Show file tree
Hide file tree
Showing 18 changed files with 651 additions and 612 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.DS_Store
node_modules
dist
package-lock.json
121 changes: 63 additions & 58 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,41 @@

[![npm](https://img.shields.io/npm/v/@biowasm/aioli)](https://www.npmjs.com/package/@biowasm/aioli)

Aioli is a framework for building fast genomics web applications using [WebAssembly](https://developer.mozilla.org/en-US/docs/WebAssembly) and [WebWorkers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API).
Aioli is a library for running genomics command-line tools in the browser using WebAssembly. The WebAssembly modules are obtained from the [biowasm](https://github.com/biowasm/biowasm) CDN.

## Tools using Aioli

| Tool | URL | Repo |
|-|-|-|
| Ribbon | [genomeribbon.com](https://genomeribbon.com) | [MariaNattestad/Ribbon](https://github.com/MariaNattestad/Ribbon) |
| Alignment Sandbox | [alignment.sandbox.bio](https://alignment.sandbox.bio/) | [RobertAboukhalil/alignment-sandbox](https://github.com/robertaboukhalil/alignment-sandbox) |
| fastq.bio | [fastq.bio](http://www.fastq.bio/) | [RobertAboukhalil/fastq.bio](https://github.com/robertaboukhalil/fastq.bio) |
| bam.bio | [bam.bio](http://www.bam.bio/) | [RobertAboukhalil/bam.bio](https://github.com/robertaboukhalil/bam.bio) |

## Getting Started

As shown below, **you can obtain Aioli from our biowasm CDN**, or you can install it from npm: `npm install @biowasm/aioli` (use the `npm` option if you need to host the Aioli module locally).

### A simple example

Here's Aioli in action running the genomics tool `samtools` on a small `SAM` file:
Running the genomics tool `samtools` on a small file:

```html
<script src="https://cdn.biowasm.com/v2/aioli/latest/aioli.js"></script>
<script type="module">
// Note that we use `script type="module"` so we can use top-level await statements
const CLI = await new Aioli("samtools/1.10");
const output = await CLI.exec("samtools view -q 20 /samtools/examples/toy.sam");
console.log(output);
</script>
```

### Load multiple tools

Aioli supports running multiple bioinformatics tools at once:

```html
<script src="https://cdn.biowasm.com/aioli/latest/aioli.js"></script>
<script>
let samtools = new Aioli("samtools/1.10");
document.write("Loading...");
samtools
// Initialize samtools
.init()
// Run "samtools view" command with "-q 20" filter
.then(() => samtools.exec("view -q 20 /samtools/examples/toy.sam"))
// Output result
.then(d => document.write(`<pre>${d.stdout}\n${d.stderr}</pre>`));
<script src="https://cdn.biowasm.com/v2/aioli/latest/aioli.js"></script>
<script type="module">
const CLI = await new Aioli(["samtools/1.10", "seqtk/1.2"]);
// Run "samtools view"
let output = await CLI.exec("samtools view -q 20 /samtools/examples/toy.sam");
console.log(output);
// Run "seqtk" to get the help screen
output = await CLI.exec("seqtk");
console.log(output);
</script>
```

Expand All @@ -44,29 +47,24 @@ We can update the previous example to run `samtools` on a file provided by the u
```html
<input id="myfile" type="file" multiple>

<script src="https://cdn.biowasm.com/aioli/latest/aioli.js"></script>
<script>
let samtools = new Aioli("samtools/1.10");
// Initialize samtools and output the version
samtools
.init()
.then(() => samtools.exec("--version"))
.then(d => console.log(d.stdout));
// When a user selects a .sam file from their computer,
// run `samtools view -q20` on the file
function loadFile(event)
{
Aioli
// First mount the file
.mount(event.target.files[0])
// Once it's mounted, run samtools view
.then(f => samtools.exec(`view -q20 ${f.path}`))
// Capture output
.then(d => console.log(d.stdout));
<script src="https://cdn.biowasm.com/v2/aioli/latest/aioli.js"></script>
<script type="module">
const CLI = await new Aioli("samtools/1.10");
const output = await CLI.exec("samtools --version-only");
console.log(`Loaded ${output}`);
// Get the SAM file header when user selects a file from their computer
async function runSamtools(event) {
// First, mount the file(s) to a virtual file system
const files = event.target.files;
await CLI.mount(files);
// Retrieve SAM header on the first file the user selected
const output = await CLI.exec(`samtools view -H ${files[0].name}`);
console.log(output);
}
document.getElementById("myfile").addEventListener("change", loadFile, false);
document.getElementById("myfile").addEventListener("change", runSamtools, false);
</script>
```

Expand All @@ -80,23 +78,19 @@ document.getElementById("myfile").addEventListener("change", loadFile, false);
// Format: <module>/<version>
// -------------------------------------

// Retrieve specific version (recommended for stability)
new Aioli("seqtk/1.2");

// Retrieve latest version
new Aioli("seqtk/latest");

new Aioli("samtools/1.10");

// -------------------------------------
// Format: <module>/<program>/<version>
// -------------------------------------

// For most bioinformatics tools, <module> == <program>
new Aioli("seqtk/seqtk/1.2");
new Aioli("seqtk/seqtk/1.2"); // seqtk/1.2 == seqtk/seqtk/1.2

// But not always! Some tools have multiple sub-tools
new Aioli("seq-align/smith_waterman/1.2");
new Aioli("seq-align/needleman_wunsch/1.2");
new Aioli("seq-align/smith_waterman/2017.10.18");
new Aioli("seq-align/needleman_wunsch/2017.10.18");
```

### Advanced
Expand All @@ -105,14 +99,25 @@ By default, Aioli retrieves the `.wasm` modules and the Aioli WebWorker code fro

```javascript
new Aioli({
module: "seq-align",
program: "smith_waterman", // optional (defaults to $module)
version: "latest", // optional (defaults to latest)
urlModule: "./path/to/wasm/files/", // optional (defaults to biowasm CDN)
tool: "seq-align",
version: "2017.10.18",
program: "smith_waterman", // optional (defaults to "tool" name)
urlPrefix: "./path/to/wasm/files/", // optional (defaults to biowasm CDN)
}, {
urlAioli: "./path/to/aioli.worker.js", // optional (defaults to biowasm CDN)
});
```

## Tools using Aioli

| Tool | URL | Repo |
|-|-|-|
| Ribbon | [genomeribbon.com](https://genomeribbon.com) | [MariaNattestad/Ribbon](https://github.com/MariaNattestad/Ribbon) |
| Alignment Sandbox | [alignment.sandbox.bio](https://alignment.sandbox.bio/) | [RobertAboukhalil/alignment-sandbox](https://github.com/robertaboukhalil/alignment-sandbox) |
| fastq.bio | [fastq.bio](http://www.fastq.bio/) | [RobertAboukhalil/fastq.bio](https://github.com/robertaboukhalil/fastq.bio) |
| bam.bio | [bam.bio](http://www.bam.bio/) | [RobertAboukhalil/bam.bio](https://github.com/robertaboukhalil/bam.bio) |


## Background info

### What is WebAssembly?
Expand Down
Loading

0 comments on commit e24214f

Please sign in to comment.