Skip to content

Commit 738c231

Browse files
committed
find example scripts properly again
1 parent 70d64fc commit 738c231

16 files changed

+66
-59
lines changed

shortcut

shortcut-demo.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
from glob import glob
4545
from jinja2 import ChoiceLoader, FileSystemLoader
4646
from misaka import Markdown, HtmlRenderer
47-
from os import setsid, getpgid, killpg, makedirs, symlink, readlink
47+
from os import setsid, getpgid, killpg, makedirs, symlink, readlink, walk
4848
from os.path import exists, join, relpath, realpath, dirname, basename, splitext
4949
from pexpect import spawn, EOF
5050
from psutil import cpu_percent, virtual_memory
@@ -172,11 +172,18 @@ def blockcode(self, text, lang):
172172
# #print 'names:', names
173173
# return names
174174

175+
def find_cuts(dirpath):
176+
for root, dirs, files in walk(dirpath, followlinks=True):
177+
# see https://stackoverflow.com/a/19859907
178+
dirs[:] = [d for d in dirs if not d.startswith('.') and not basename(d) == 'tmpdir']
179+
for file in files:
180+
if file.endswith('.cut'):
181+
yield(join(root, file))
182+
175183
def load_codeblocks():
176184
# used to render the code examples
177185
codeblocks = {}
178-
# for path in glob(join(CONFIG['examples_dir'], '*.cut')) + glob(join(CONFIG['users_dir'], '*/*.cut')):
179-
for path in glob(join(CONFIG['users_dir'], '*/*.cut')) + glob(join(CONFIG['users_dir'], '*/*/*.cut')):
186+
for path in find_cuts(CONFIG['users_dir']):
180187
with open(path, 'r') as f:
181188
txt = '```\n%s\n```\n' % f.read()
182189
# name = basename(path)
@@ -190,7 +197,7 @@ def load_codeblocks():
190197
, 'content': MARKDOWN(txt)
191198
}
192199
# print codeblocks
193-
# print codeblocks.keys()
200+
LOGGER.info('loaded codeblocks: %s' % codeblocks.keys())
194201
return codeblocks
195202

196203
def load_tutorial_sections():
@@ -264,7 +271,7 @@ def create_user(username, password):
264271
def list_user_scripts(username):
265272
# load_code_blocks() # super hacky but reloads code blocks along with templates
266273
upath = join(CONFIG['users_dir'], username)
267-
paths = [relpath(p, upath) for p in glob(join(upath, '*.cut')) + glob(join(upath, '*/*.cut'))]
274+
paths = [relpath(p, upath) for p in find_cuts(upath)]
268275
# paths.sort()
269276
return paths
270277

templates/basics.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ or make an account to save your own privately.
4848
There are two types of interactive code blocks.
4949
Complete cut scripts with `Load` buttons like this:
5050

51-
{{ macros.load_cut(user, 'examples/scripts/load03.cut') }}
51+
{{ macros.load_cut(user, 'examples/cut-scripts/load03.cut') }}
5252

5353
... and examples of other commands you would type in the terminal.
5454
The `Run` button just types them for you.
5555
They can include loading scripts, but also anything else you might do live:
5656
redefine variables, look at depdencies, etc.
5757

58-
{{ macros.run_example([':load examples/scripts/load03.cut', 'sample 10 genes_of_interest', ':type']) }}
58+
{{ macros.run_example([':load examples/cut-scripts/load03.cut', 'sample 10 genes_of_interest', ':type']) }}
5959

6060

6161
# Using the command line program

templates/functions.md

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{% import "macros.jinja" as macros with context %}
22

3-
This page is a complete listing of available functions in ShortCut v0.9.1. The search box only filters by module. So for example if you search for "mmseqs", you'll get the MMSeqs module but also BlastHits and ListLike, because they can use MMSeqs results.
3+
This page is a complete listing of available functions in ShortCut v0.9.2. The search box only filters by module. So for example if you search for "mmseqs", you'll get the MMSeqs module but also BlastHits and ListLike, because they can use MMSeqs results.
44

55
Each module has (or will have soon!) an example script making use of all its functions.
66
If you don't find what you're looking for, leave Jeff a comment about it.
@@ -27,7 +27,7 @@ Functions:
2727
| `replace_each` | `<outputvar>`, `<inputvar>`, `<inputvars>` | `<output>.list` |
2828

2929
<br/>
30-
{{ macros.load_cut(user, 'examples/scripts/replace.cut') }}
30+
{{ macros.load_cut(user, 'examples/cut-scripts/replace.cut') }}
3131
</div>
3232
<div class="moduleblock">
3333
<h3>Repeat module</h3>
@@ -42,7 +42,7 @@ Functions:
4242
| `repeat` | `<outputvar>`, `<inputvar>`, `num` | `<output>.list` |
4343

4444
<br/>
45-
{{ macros.load_cut(user, 'examples/scripts/repeat.cut') }}
45+
{{ macros.load_cut(user, 'examples/cut-scripts/repeat.cut') }}
4646
</div>
4747
<div class="moduleblock">
4848
<h3>Math module</h3>
@@ -60,7 +60,7 @@ Functions:
6060
| `/` | `num`, `num` | `num` |
6161

6262
<br/>
63-
{{ macros.load_cut(user, 'examples/scripts/math.cut') }}
63+
{{ macros.load_cut(user, 'examples/cut-scripts/math.cut') }}
6464
</div>
6565
<div class="moduleblock">
6666
<h3>Load module</h3>
@@ -76,7 +76,7 @@ Functions:
7676
| `glob_files` | `str` | `str.list` |
7777

7878
<br/>
79-
{{ macros.load_cut(user, 'examples/scripts/load.cut') }}
79+
{{ macros.load_cut(user, 'examples/cut-scripts/load.cut') }}
8080
</div>
8181
<div class="moduleblock">
8282
<h3>Sets module</h3>
@@ -97,7 +97,7 @@ Functions:
9797
| `diff` | `X.list.list` | `X.list` |
9898

9999
<br/>
100-
{{ macros.load_cut(user, 'examples/scripts/sets.cut') }}
100+
{{ macros.load_cut(user, 'examples/cut-scripts/sets.cut') }}
101101
</div>
102102
<div class="moduleblock">
103103
<h3>SeqIO module</h3>
@@ -146,7 +146,7 @@ Functions:
146146
| `load_gbk_glob` | `str` | `gbk.list` |
147147

148148
<br/>
149-
{{ macros.load_cut(user, 'examples/scripts/seqio.cut') }}
149+
{{ macros.load_cut(user, 'examples/cut-scripts/seqio.cut') }}
150150
</div>
151151
<div class="moduleblock">
152152
<h3>BiomartR module</h3>
@@ -170,7 +170,7 @@ Functions:
170170
| `get_proteomes` | `str.list` | `faa.gz.list` |
171171

172172
<br/>
173-
{{ macros.load_cut(user, 'examples/scripts/biomartr.cut') }}
173+
{{ macros.load_cut(user, 'examples/cut-scripts/biomartr.cut') }}
174174
</div>
175175
<div class="moduleblock">
176176
<h3>BlastDB module</h3>
@@ -204,7 +204,7 @@ Functions:
204204
| `singletons` | `X.list` | `X.list.list` |
205205

206206
<br/>
207-
{{ macros.load_cut(user, 'examples/scripts/blastdb.cut') }}
207+
{{ macros.load_cut(user, 'examples/cut-scripts/blastdb.cut') }}
208208
</div>
209209
<div class="moduleblock">
210210
<h3>BLAST+ module</h3>
@@ -251,7 +251,7 @@ Functions:
251251
| `concat_bht_each` | `bht.list.list` | `bht.list` |
252252

253253
<br/>
254-
{{ macros.load_cut(user, 'examples/scripts/blast.cut') }}
254+
{{ macros.load_cut(user, 'examples/cut-scripts/blast.cut') }}
255255
</div>
256256
<div class="moduleblock">
257257
<h3>BlastHits module</h3>
@@ -284,7 +284,7 @@ Functions:
284284
| `best_hits_each` | `hittable.list` | `bht.list` |
285285

286286
<br/>
287-
{{ macros.load_cut(user, 'examples/scripts/blasthits.cut') }}
287+
{{ macros.load_cut(user, 'examples/cut-scripts/blasthits.cut') }}
288288
</div>
289289
<div class="moduleblock">
290290
<h3>ListLike module</h3>
@@ -308,7 +308,7 @@ Functions:
308308
| `length_each` | `listlike.list` | `num.list` |
309309

310310
<br/>
311-
{{ macros.load_cut(user, 'examples/scripts/listlike.cut') }}
311+
{{ macros.load_cut(user, 'examples/cut-scripts/listlike.cut') }}
312312
</div>
313313
<div class="moduleblock">
314314
<h3>PsiBLAST module</h3>
@@ -389,7 +389,7 @@ Functions:
389389
| `psiblast_train_pssms_db` | `num`, `faa.list`, `pdb` | `pssm.list` |
390390

391391
<br/>
392-
{{ macros.load_cut(user, 'examples/scripts/psiblast.cut') }}
392+
{{ macros.load_cut(user, 'examples/cut-scripts/psiblast.cut') }}
393393
</div>
394394
<div class="moduleblock">
395395
<h3>CRB-BLAST module</h3>
@@ -413,7 +413,7 @@ Functions:
413413
| `crb_blast_each` | `fna`, `fa.list` | `crb.list` |
414414

415415
<br/>
416-
{{ macros.load_cut(user, 'examples/scripts/crbblast.cut') }}
416+
{{ macros.load_cut(user, 'examples/cut-scripts/crbblast.cut') }}
417417
</div>
418418
<div class="moduleblock">
419419
<h3>HMMER module</h3>
@@ -441,7 +441,7 @@ Functions:
441441
| `extract_hmm_targets_each` | `hht.list` | `str.list.list` |
442442

443443
<br/>
444-
{{ macros.load_cut(user, 'examples/scripts/hmmer.cut') }}
444+
{{ macros.load_cut(user, 'examples/cut-scripts/hmmer.cut') }}
445445
</div>
446446
<div class="moduleblock">
447447
<h3>BlastRBH module</h3>
@@ -481,7 +481,7 @@ Functions:
481481
| `tblastx_rbh_each` | `num`, `fna`, `fna.list` | `bht.list` |
482482

483483
<br/>
484-
{{ macros.load_cut(user, 'examples/scripts/blastrbh.cut') }}
484+
{{ macros.load_cut(user, 'examples/cut-scripts/blastrbh.cut') }}
485485
</div>
486486
<div class="moduleblock">
487487
<h3>MUSCLE module</h3>
@@ -503,7 +503,7 @@ Functions:
503503
| `muscle_each` | `faa.list` | `aln.list` |
504504

505505
<br/>
506-
{{ macros.load_cut(user, 'examples/scripts/muscle.cut') }}
506+
{{ macros.load_cut(user, 'examples/cut-scripts/muscle.cut') }}
507507
</div>
508508
<div class="moduleblock">
509509
<h3>Sample module</h3>
@@ -522,7 +522,7 @@ Functions:
522522
| `sample` | `num`, `X.list` | `X.list` |
523523

524524
<br/>
525-
{{ macros.load_cut(user, 'examples/scripts/sample.cut') }}
525+
{{ macros.load_cut(user, 'examples/cut-scripts/sample.cut') }}
526526
</div>
527527
<div class="moduleblock">
528528
<h3>Permute module</h3>
@@ -537,7 +537,7 @@ Functions:
537537
| `leave_each_out` | `X.list` | `X.list.list` |
538538

539539
<br/>
540-
{{ macros.load_cut(user, 'examples/scripts/permute.cut') }}
540+
{{ macros.load_cut(user, 'examples/cut-scripts/permute.cut') }}
541541
</div>
542542
<div class="moduleblock">
543543
<h3>Summarize module</h3>
@@ -547,7 +547,7 @@ Collapse a list of results into a single summary.
547547

548548

549549
<br/>
550-
{{ macros.load_cut(user, 'examples/scripts/summarize.cut') }}
550+
{{ macros.load_cut(user, 'examples/cut-scripts/summarize.cut') }}
551551
</div>
552552
<div class="moduleblock">
553553
<h3>Scores module</h3>
@@ -564,7 +564,7 @@ Functions:
564564
| `extract_scored` | `X.scores` | `X.list` |
565565

566566
<br/>
567-
{{ macros.load_cut(user, 'examples/scripts/scores.cut') }}
567+
{{ macros.load_cut(user, 'examples/cut-scripts/scores.cut') }}
568568
</div>
569569
<div class="moduleblock">
570570
<h3>Plots module</h3>
@@ -587,7 +587,7 @@ Functions:
587587
| `venndiagram` | `X.list.list` | `png` |
588588

589589
<br/>
590-
{{ macros.load_cut(user, 'examples/scripts/plots.cut') }}
590+
{{ macros.load_cut(user, 'examples/cut-scripts/plots.cut') }}
591591
</div>
592592
<div class="moduleblock">
593593
<h3>OrthoFinder module</h3>
@@ -608,7 +608,7 @@ Functions:
608608
| `orthofinder` | `faa.list` | `ofr` |
609609

610610
<br/>
611-
{{ macros.load_cut(user, 'examples/scripts/orthofinder.cut') }}
611+
{{ macros.load_cut(user, 'examples/cut-scripts/orthofinder.cut') }}
612612
</div>
613613
<div class="moduleblock">
614614
<h3>Diamond module</h3>
@@ -674,7 +674,7 @@ Functions:
674674
| `diamond_blastx_db_more_sensitive_each` | `num`, `fna`, `dmnd.list` | `bht.list` |
675675

676676
<br/>
677-
{{ macros.load_cut(user, 'examples/scripts/diamond.cut') }}
677+
{{ macros.load_cut(user, 'examples/cut-scripts/diamond.cut') }}
678678
</div>
679679
<div class="moduleblock">
680680
<h3>MMSeqs module</h3>
@@ -700,7 +700,7 @@ Functions:
700700
| `mmseqs_search` | `num`, `fa`, `fa` | `bht` |
701701

702702
<br/>
703-
{{ macros.load_cut(user, 'examples/scripts/mmseqs.cut') }}
703+
{{ macros.load_cut(user, 'examples/cut-scripts/mmseqs.cut') }}
704704
</div>
705705
<div class="moduleblock">
706706
<h3>SonicParanoid module</h3>
@@ -722,7 +722,7 @@ Functions:
722722
| `sonicparanoid` | `faa.list` | `spr` |
723723

724724
<br/>
725-
{{ macros.load_cut(user, 'examples/scripts/sonicparanoid.cut') }}
725+
{{ macros.load_cut(user, 'examples/cut-scripts/sonicparanoid.cut') }}
726726
</div>
727727
<div class="moduleblock">
728728
<h3>OrthoGroups module</h3>
@@ -755,7 +755,7 @@ Functions:
755755
| `ortholog_in_max_str` | `num`, `str.list.list`, `str.list.list` | `str.list.list` |
756756

757757
<br/>
758-
{{ macros.load_cut(user, 'examples/scripts/orthogroups.cut') }}
758+
{{ macros.load_cut(user, 'examples/cut-scripts/orthogroups.cut') }}
759759
</div>
760760
<div class="moduleblock">
761761
<h3>Busco module</h3>
@@ -789,7 +789,7 @@ Functions:
789789
| `concat_bst` | `bst.list` | `bst` |
790790

791791
<br/>
792-
{{ macros.load_cut(user, 'examples/scripts/busco.cut') }}
792+
{{ macros.load_cut(user, 'examples/cut-scripts/busco.cut') }}
793793
</div>
794794
<div class="moduleblock">
795795
<h3>Range module</h3>
@@ -813,7 +813,7 @@ Functions:
813813
| `range_multiply` | `num`, `num`, `num` | `num.list` |
814814

815815
<br/>
816-
{{ macros.load_cut(user, 'examples/scripts/range.cut') }}
816+
{{ macros.load_cut(user, 'examples/cut-scripts/range.cut') }}
817817
</div>
818818
<div class="moduleblock">
819819
<h3>SetsTable module</h3>
@@ -833,7 +833,7 @@ Functions:
833833
| `sets_table` | `lit.list.list` | `tsv` |
834834

835835
<br/>
836-
{{ macros.load_cut(user, 'examples/scripts/setstable.cut') }}
836+
{{ macros.load_cut(user, 'examples/cut-scripts/setstable.cut') }}
837837
</div>
838838
<div class="moduleblock">
839839
<h3>All-Vs-All module</h3>
@@ -848,7 +848,7 @@ Types:
848848

849849

850850
<br/>
851-
{{ macros.load_cut(user, 'examples/scripts/allvsall.cut') }}
851+
{{ macros.load_cut(user, 'examples/cut-scripts/allvsall.cut') }}
852852
</div>
853853
<div class="moduleblock">
854854
<h3>GreenCut module</h3>
@@ -868,5 +868,5 @@ Functions:
868868
| `greencut2_families` | `bht`, `bht` | `gcr` |
869869

870870
<br/>
871-
{{ macros.load_cut(user, 'examples/scripts/greencut.cut') }}
871+
{{ macros.load_cut(user, 'examples/cut-scripts/greencut.cut') }}
872872
</div>

templates/greencut.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
Now you know everything you need to make an actual, useful cut.
44
Like, the kind you could publish!
55

6-
{{ macros.load_cut(user, 'examples/scripts/green.cut') }}
6+
{{ macros.load_cut(user, 'examples/cut-scripts/green.cut') }}
77

8-
{{ macros.load_cut(user, 'examples/scripts/green-ids.cut') }}
8+
{{ macros.load_cut(user, 'examples/cut-scripts/green-ids.cut') }}

templates/scripts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{% import "macros.jinja" as macros with context %}
22

3-
Here are a bunch of example scripts, including everything from the rest of the site.
3+
Here are a bunch of example scripts, including everything from the rest of the (public) site.
44

55
If you don't find an example similar to what you're trying to do, request that it be added (bottom right).
66
Or if you figure it out yourself, consider adding your script to the collection!

templates/tutorial_01_variables.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Let's start at the beginning.
44
This is probably the simplest script you could write:
55

6-
{{ macros.load_cut(user, 'examples/scripts/variables01.cut') }}
6+
{{ macros.load_cut(user, 'examples/cut-scripts/variables01.cut') }}
77

88
<!-- TODO include example scripts in the main repo? either that or rewrite this: -->
99
<!-- idea: :help <varname> should expand to help on its type -->
@@ -15,7 +15,7 @@ You'll spend most of your time editing it in the interpreter,
1515
defining and evaluating individual variables.
1616
Here is a script with several of them.
1717

18-
{{ macros.load_cut(user, 'examples/scripts/variables02.cut') }}
18+
{{ macros.load_cut(user, 'examples/cut-scripts/variables02.cut') }}
1919

2020
ShortCut keeps track of dependencies between variables, like this:
2121

templates/tutorial_02_math.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ operations.
66

77
A few examples:
88

9-
{{ macros.load_cut(user, 'examples/scripts/math01.cut') }}
9+
{{ macros.load_cut(user, 'examples/cut-scripts/math01.cut') }}
1010

1111
You can enter numbers in decimal or scientific notation. There's only one type
1212
of number instead of the several different ones like doubles and floats you

0 commit comments

Comments
 (0)