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

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

Open
HenrikBengtsson opened this issue Mar 29, 2024 · 6 comments
Open

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

HenrikBengtsson opened this issue Mar 29, 2024 · 6 comments

Comments

@HenrikBengtsson
Copy link
Contributor

HenrikBengtsson commented Mar 29, 2024

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
Copy link
Contributor Author

HenrikBengtsson commented Mar 29, 2024

@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
Copy link
Contributor Author

HenrikBengtsson commented Mar 30, 2024

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 HenrikBengtsson changed the title Split up into seguid.tcl and seguid? Build 'seguid' script from multiple *.tcl scripts Mar 30, 2024
@HenrikBengtsson
Copy link
Contributor Author

HenrikBengtsson commented Apr 28, 2024

I have made this move in commit 862677d. 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
Copy link
Contributor Author

HenrikBengtsson commented Apr 29, 2024

@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
Copy link
Contributor

mwdavis2 commented Apr 29, 2024 via email

@HenrikBengtsson
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants