Skip to content
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

Remove Global Tauri Invoke/open #15

Merged
merged 5 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions observablehq.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@ export default {
],

// Some additional configuration options and their defaults:
theme: "default", // try "light", "dark", "slate", etc.
// theme: "default", // try "light", "dark", "slate", etc.
// header: "", // what to show in the header (HTML)
// head: ({
// path,
// }) => `<link rel="canonical" href="${path.replace(/\/index$/, "/")}">
// <link rel="apple-touch-icon" href="/logo.png">
// <link rel="icon" type="image/png" href="/logo.png" sizes="32x32">`,
head: '<link rel="icon" href="icon.png" type="image/png" sizes="32x32">',

// footer: "Built with Observable.", // what to show in the footer (HTML)
toc: true, // whether to show the table of contents
// pager: true, // whether to show previous & next links in the footer
// output: "dist", // path to the output root for build
dynamicPaths: ["./icon.png"],
};
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
"tauri": "tauri"
},
"dependencies": {
"@observablehq/framework": "latest",
"@observablehq/framework": "^1.12.0",
"@tauri-apps/api": "latest",
"@tauri-apps/plugin-dialog": "^2.0.0",
"@tauri-apps/plugin-shell": "^2.0.0",
"@tauri-apps/plugin-dialog": "latest",
"@tauri-apps/plugin-shell": "latest",
"d3-dsv": "^3.0.1",
"d3-time-format": "^4.1.0",
"ideogram": "^1.47",
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"security": {
"csp": null
},
"withGlobalTauri": true,
"withGlobalTauri": false,
"windows": [
{
"fullscreen": false,
Expand Down
39 changes: 39 additions & 0 deletions src/components/fasta_processing.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { open } from "@tauri-apps/plugin-dialog";
import { invoke } from "npm:@tauri-apps/api/core";
import { html } from "npm:htl";

function choosefasta() {
const selected = open({
multiple: false,
filters: [
{
name: "Fasta",
extensions: ["fa", "fasta", "fna"],
},
],
});
return selected;
}

function choosefastq() {
const selected = open({
multiple: false,
filters: [
{
name: "Fastq",
extensions: ["fq", "fastq"],
},
],
});
return selected;
}

export async function getFastaStats() {
const fasta = await choosefasta();
const stats = await invoke("get_stats", { filename: fasta });
return html`<div>
<h3>Fasta Statistics</h3>
<p>Record Count: ${stats.recordcount}</p>
<p>Maximum Length: ${stats.maxlength}</p>
</div>`;
}
3 changes: 1 addition & 2 deletions src/dna/restriction_enzyme_analysis.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


```js
let invoke = window.__TAURI__.core.invoke;
import { invoke } from "npm:@tauri-apps/api/core";
let text = view(Inputs.textarea({label: "DNA For Searching", placeholder: "DNA Goes here", submit: true}));
// let re_sites = (text == "") ? []: invoke("check_restriction_sites", {sequence: text})
text
Expand All @@ -23,4 +23,3 @@ if (text != "") {
// display( re_sites)

```

4 changes: 2 additions & 2 deletions src/dna/translation.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Simple DNA->Protiein Translation using the [protein_translate](https://docs.rs/p


```js
let invoke = window.__TAURI__.core.invoke;
import { invoke } from "npm:@tauri-apps/api/core";
let dna_text = view(Inputs.textarea({label: "DNA For Translation", placeholder: "DNA Here", submit: true}));
let dna_text_realized;

Expand All @@ -28,4 +28,4 @@ display(dna_text)
>NC_000913.3:1728347-1728994 rnt [organism=Escherichia coli str. K-12 substr. MG1655] [GeneID=946159] [chromosome=]
ATGTCCGATAACGCTCAACTTACCGGTCTGTGCGACCGTTTTCGTGGTTTTTATCCTGTTGTGATCGATGTTGAAACAGCCGGATTTAACGCCAAAACCGATGCGCTGCTTGAGATTGCCGCCATCACCCTGAAAATGGATGAACAAGGCTGGCTGATGCCGGACACCACATTACATTTCCACGTCGAACCATTTGTCGGCGCAAATTTGCAACCAGAAGCCCTCGCCTTCAACGGCATTGACCCGAACGATCCCGATCGCGGCGCGGTCAGCGAATACGAGGCGCTGCACGAAATTTTTAAAGTTGTACGTAAAGGTATTAAAGCGAGCGGCTGTAACCGCGCCATTATGGTGGCGCACAATGCCAATTTTGATCACAGCTTTATGATGGCCGCCGCAGAACGCGCCTCACTGAAACGTAACCCGTTCCACCCTTTCGCCACTTTTGACACTGCTGCACTGGCCGGGCTGGCACTCGGACAAACCGTATTGTCAAAGGCTTGCCAGACCGCTGGCATGGACTTCGACAGCACCCAGGCGCACTCCGCGCTGTACGACACCGAACGCACTGCTGTGCTGTTTTGTGAAATCGTCAACCGCTGGAAACGTCTGGGAGGCTGGCCGCTATCTGCCGCCGAAGAGGTGTAA

```
```
48 changes: 9 additions & 39 deletions src/fastx/fasta_simple.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,51 +4,21 @@ title: "Simple Fasta"

Simplest example. uses Noodles to loop throught a fasta file and return the record count and maximul length in the file

```js
let open = window.__TAURI__.dialog.open;
let invoke = window.__TAURI__.core.invoke;

// use the tauri open to get absolute file paths
async function choosefasta(){
const selected = open({
multiple: false,
filters: [{
name: 'Fasta',
extensions: ['fa', 'fasta', 'fna']}]
});
return selected
};

async function choosefastq(){
const selected = open({
multiple: false,
filters: [{
name: 'Fastq',
extensions: ['fq', 'fastq']}]
});
return selected
};

```

```js
import {getFastaStats} from "../components/fasta_processing.js";

const fasta_stats = view(
Inputs.button("Get Fasta Stats", {
value: null,
reduce: () => choosefasta().then((fname) => {
console.log('Selected file:', fname);
return invoke("get_stats", { filename: fname });
})
}),
);

let fasta_stats_realized =
fasta_stats == null ? "Click Above to Get Fasta Statistics" : fasta_stats;
Inputs.button("Get Fasta Stats: Part 2 ", {
value: null,
reduce: () => getFastaStats()
}));

```


```js
display(fasta_stats_realized)
if (fasta_stats != null) {
display(fasta_stats)
}

```
14 changes: 5 additions & 9 deletions src/fastx/fastq_to_fasta.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@ This function will take a fasq file and convert it to a fasta file.


```js
let open = window.__TAURI__.dialog.open;
let invoke = window.__TAURI__.core.invoke;
```


```js
import { open } from "@tauri-apps/plugin-dialog";
import { invoke } from "npm:@tauri-apps/api/core";

async function choosefastq(){
const selected = open({
Expand All @@ -24,9 +20,9 @@ async function choosefastq(){
};

const convert_stats = view(Inputs.button(
"Convert FastQ to Fasta",
{
value: null,
"Convert FastQ to Fasta",
{
value: null,
reduce: () => choosefastq()
.then( function (fqname) {
// console.log(fqname);
Expand Down
5 changes: 3 additions & 2 deletions src/fastx/fastx_stats.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ title: "Fastx stats"


```js
let open = window.__TAURI__.dialog.open;
let invoke = window.__TAURI__.core.invoke;
import { open } from "@tauri-apps/plugin-dialog";
import { invoke } from "npm:@tauri-apps/api/core";


// use the tauri open to get absolute file paths
async function choosefasta(){
Expand Down
14 changes: 7 additions & 7 deletions src/rna/rna_rnapkin_viz.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

```js
import {svg, html} from "npm:htl";
let invoke = window.__TAURI__.core.invoke;
import { invoke } from "npm:@tauri-apps/api/core";


function unsafe_html() {
const span = document.createElement("span");
Expand Down Expand Up @@ -60,13 +61,12 @@ if (rnapkin_params.rna != "") {
// retunrs text. I need a propr DOM element
rna_text_realized = await invoke("rnapkin_fn", {
sequence: rnapkin_params.rna,
height: rnapkin_params.height,
height: rnapkin_params.height,
color_theme: rnapkin_params.color_theme,
mirror_x: rnapkin_params.mirror_x,
mirror_y: rnapkin_params.mirror_y,
rotation_angle:rnapkin_params.angle,
bubble_radius: rnapkin_params.bubble_radius});
mirror_x: rnapkin_params.mirror_x,
mirror_y: rnapkin_params.mirror_y,
rotation_angle:rnapkin_params.angle,
bubble_radius: rnapkin_params.bubble_radius});
console.log(rna_text_realized);
display(unsafe_html`${rna_text_realized}`);
}

Loading