seguid / seguid-tcl

SEGUID v2: Checksums for Linear, Circular, Single- and Double-Stranded Biological Sequences
0 stars 0 forks source link

Build 'seguid' script from multiple *.tcl scripts #7

Open HenrikBengtsson opened 3 months ago

HenrikBengtsson commented 3 months ago

In order to use this Tcl code in another script, it should be possible to do something like:

source seguid.tcl

such that one can do, for instance,

$ tclsh
% source seguid.tcl
% calculate_seguid "ACGT" "s" "long"
seguid=IQiZThf2zKn/I1KtqStlEdsHYDQ

If attempted to do that right now, with the existing seguid script, it "hangs", because it expects input as it was called from the command line. One approach is to split up the existing code into

  1. seguid.tcl: defines the Tcl procedures (the SEGUID API)
  2. seguid: the CLI interface (which uses source seguid.tcl internally)

Alternatively, it might be possible to modify the existing seguid script to detect whether it is source:ed or called from the command line.

HenrikBengtsson commented 3 months ago

@mwdavis2, my train of thought here is that you should be able to use this implementation in your ApE tool via either:

source seguid.tcl

or by injecting the content of seguid.tcl as-is into your Ape Tcl monoscript. If there's ever an update to seguid.tcl you should then be able to just repeat that to make sure you run the latest version.

HenrikBengtsson commented 3 months ago

Based on the discussions on incorporating external code into seguid, one approach would be to split up the source code into four standalone files:

  1. sha1.tcl
  2. base64.tcl
  3. seguid.tcl
  4. seguid-cli.tcl

and then create a simple build script that bundles them together into a single seguid Tcl script. This build script could be as simple as:

#! /usr/bin/env bash

cat sha1.tcl base64.tcl seguid.tcl seguid-cli.tcl > seguid

That would basically do what has already been done manually in the editor.

HenrikBengtsson commented 2 months ago

I have made this move in commit 862677d0. Here is the gist:

We now have four source files;

$ ls -1 src/*.tcl
src/base64.tcl
src/seguid-cli.tcl
src/seguid.tcl
src/sha1.tcl

The src/seguid-cli.tcl file contains:

$ head src/seguid-cli.tcl
#!/bin/sh
# the next line restarts using tclsh \
exec tclsh "$0" "$@"

set script_path [file dirname [info script]]
source [file join $script_path base64.tcl]
source [file join $script_path sha1.tcl]
source [file join $script_path seguid.tcl]

...

which means we can call it as:

$ tclsh src/seguid-cli.tcl <<< "ACGT"
seguid=IQiZThf2zKn/I1KtqStlEdsHYDQ

Next, calling make build, while generate a stand-alone, self-contained script seguid using src/seguid-cli.tcl as the template where source ... calls are replaced by the content of those files;

#!/bin/sh
# the next line restarts using tclsh \
exec tclsh "$0" "$@"

## DON'T EDIT: The source of this part is src/base64.tcl
##############
## base64 encoding from base64 package
##############
    namespace eval base64 {
    variable base64 {}
...

Thus, from now on we should not edit the seguid file, but the individual src/*.tcl files and then run make build.

HenrikBengtsson commented 2 months ago

@mwdavis2 , I see you've been working on several things today. Thanks for that. Please note that after making src/*.tcl the main source, from which ./seguid is automatically built, it's import to not manually edit ./seguid. If you're available now, I'm happy to explain/discuss this workflow on a Zoom/GoogleMeet call. Let me know, I'll email you details.

mwdavis2 commented 2 months ago

ok, thanks. I wasn't sure how your new system worked. I can just edit the src version and leave the ./seguid alone. Does it need to be reset?

On Mon, Apr 29, 2024 at 4:55 PM Henrik Bengtsson @.***> wrote:

@mwdavis2 https://github.com/mwdavis2 , I see you've been working on several things today. Thanks for that. Please note that after make src/*.tcl from which ./seguid is automatically built, it's import to not manually edit ./seguid. If you're available now, I'm happy to explain/discuss this workflow on a Zoom/GoogleMeet call. Let me know, I'll email you details.

— Reply to this email directly, view it on GitHub https://github.com/seguid/seguid-tcl/issues/7#issuecomment-2083823349, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABKEEE3HWUAUDWBLESCU5D3Y73FWFAVCNFSM6AAAAABFN336QKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOBTHAZDGMZUHE . You are receiving this because you were mentioned.Message ID: @.***>

-- Wayne Davis

School of Biological Sciences HHMI, University of Utah 257 South 1400 East Salt Lake City, UT 84112-0840 (801) 585-3692

HenrikBengtsson commented 1 month ago

ok, thanks. I wasn't sure how your new system worked. I can just edit the src version and leave the ./seguid alone. Does it need to be reset? On Mon, Apr 29, 2024 at 4:55 PM Henrik Bengtsson @.> wrote: @mwdavis2 https://github.com/mwdavis2 , I see you've been working on several things today. Thanks for that. Please note that after make src/.tcl from which ./seguid is automatically built, it's import to not manually edit ./seguid. If you're available now, I'm happy to explain/discuss this workflow on a Zoom/GoogleMeet call. Let me know, I'll email you details. — Reply to this email directly, view it on GitHub <#7 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABKEEE3HWUAUDWBLESCU5D3Y73FWFAVCNFSM6AAAAABFN336QKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOBTHAZDGMZUHE . You are receiving this because you were mentioned.Message ID: **@.***> -- Wayne Davis School of Biological Sciences HHMI, University of Utah 257 South 1400 East Salt Lake City, UT 84112-0840 (801) 585-3692

I've added build instructions to the README, cf. https://github.com/seguid/seguid-tcl#readme