How do you run a standalone ijs j file on Linux? - j

I have been using j for a few weeks now and loving it. However, all of my work has been in the ijconsole. Does j provide a way to run .ijs files without using load? Similar to how you can simply run $python my_file.py?
I know for windows there exists jconsole.exe, but for Linux and OSx there doesn't seem to be the same option?

You should be able to run bin/jconsole with the .ijs file as the first command line argument.
Here's an example session, copied out of my terminal:
~/j64-807$ cat ex.ijs
d =: 1+1
~/j64-807$ ./bin/jconsole ex.ijs
d
2

I figured out how to get my desired behavior from
https://www.jsoftware.com/help/user/hashbang.htm
The basic idea is to create a "unix script" that points to jconsole by using
#!/home/fred/j64-807/bin/jconsole
at the top of the .ijs file.
Then, you can echo any output you wish or use ARGV to read input.
Finally, call chmod +x your_script.ijs and run using ./your_script.ijs
You can copy the j interpreter files to new projects on servers etc and call them using bash.
So, a final example would be
#!/home/fred/j64-807/bin/jconsole
echo +/*:0".>,.2}.ARGV
exit''
Which computes the sum of squares of digits from command line arguments

Related

os.system(cmd) call fails with redirection operator

My Python 3.7.1 script generates a fasta file called
pRNA.sites.fasta
Within the same script, I call following system command:
cmd = "weblogo -A DNA < pRNA.sites.fasta > OUT.eps"
os.system(cmd)
print(cmd) #for debugging
I am getting the following error message and debugging message on the command line.
Error: Please provide a multiple sequence alignment
weblogo -A DNA < pRNA.sites.fasta > OUT.eps
"OUT.eps" file is generated but it's emtpy. On the other hand, if I run the following 'weblogo' command from the command line, It works just find. I get proper OUT.eps file.
$ weblogo -A DNA<pRNA.sites.fasta>OUT.eps
I am guessing my syntax for os.system call is wrong. Can you tell me what is wrong with it? Thanks.
Never mind. It turned out to be that I was not closing my file, "pRNA.sites.fasta" before I make system call that uses this file.

abyss-pe: variables to assemble multiple genomes with one command

How do I rewrite the following to properly replace the variable with my genomeID? (I have it working with this method in Spades and Masurca assemblers, so it's something about Abyss that doesnt like this approach and I need a work-around)
I am trying to run abyss on a cluster server but am running into trouble with how abyss-pe is reading my variable input:
my submit file loads a script for each genome listed in a .txt file
my script writes in the genome name throughout the script
the abyss assembly fumbles the variable replacement
Input.sub:
queue genomeID from genomelisttest.txt
Input.sh:
#!/bin/bash
genomeID=$1
cp /mnt/gluster/harrow2/trim_output/${genomeID}_trim.tar.gz ./
tar -xzf ${genomeID}_trim.tar.gz
rm ${genomeID}_trim.tar.gz
for k in `seq 86 10 126`; do
mkdir k$k
abyss-pe -C k$k name=${genomeID} k=$k lib='pe1 pe2' pe1='../${genomeID}_trim/${genomeID}_L1_1.fq.gz ../${genomeID}_trim/${genomeID}_L1_2.fq.gz' pe2='../${genomeID}_trim/${genomeID}_L2_1.fq.gz ../${genomeID}_trim/${genomeID}_L2_2.fq.gz'
done
Error that I get:
`../enome_trim/enome_L1_1.fq.gz': No such file or directory
This is where "enome" is supposed to replace with a five digit genomeID, which happens properly in the earlier part of the script up to this point, where abyss comes in.
pe1='../'"$genomeID"'_trim/'"$genomeID"'_L1_1.fq.gz ...'
I added a single quote before and after the variable

Linux command line open any directory

I'm currently using the Linux command line and was just wondering whether there is a quick command you can enter into the console to open any of a given directory.
I'll give you an example of what I mean.
say in a directory ligands/
we have:
ligand_1993324
ligand_1993444
ligand 1993255
shoe_lace
water_bottle
Lets just say there are 100000 of these very similar directories. Because I'm lazy I just want to pick any random one of these, but it has to begin with ligand_199 for example.
Please not I'm trawled through the manual and can't find anything, I've also looked at other stacks, any help would be great!
There are a couple of versions of a program called variously "randomline" or "randline" about. This version shows its age (it's in Perl).
#!/usr/bin/perl
while(<>)
{
push #lines, $_;
}
$randline = $#lines;
$randline = rand($randline);
print $lines[$randline];
Given this in a file ~/bin/randomline, then your task reduces to the following, assuming that you want to open the file with vim:
vim $(ls ligands/ligand_199* | ~/bin/randomline)
You can use following:
files=(/my/dir/*)
file=`printf "%s\n" "${files[RANDOM % ${#files[#]}]}"`
cat file
Maybe something like
number=$(((RANDOM%10000)+1)) && emacs -nw "ligand_199$number" ?

How can I perform some commands on Intersystem cache from shellscript?

I want to perform some commands on Intersystem cache from shell script. One solution which I know is through making a config file but the problem is I dont know how to use config file through shell script. Is there any other solution for this...
for example what I have to run on cache is
csession instancename
zn "area"
area>D ^%RI
Device:some/device/path
Next: It should take enter
This can be accomplished from a Linux shell, simply keep a log of the commands you need to perform and then put them into a script. Here's an example of logging into Cache and writing "Hello world" -- note that this also assumes you need to authenticate.
echo -e "username\npassword\nW \"Hello world\"\nH\n" | csession instance
Note that every command you would have run manually is in there and separated by "\n", this is the character that represents the "Enter" key.
It is possible (for some operating systems) to run the Cache terminal in batch mode. For example:
echo: off
wait for:Username
send: SYS<CR>
wait for:Password
send: XXX<CR>
echo: on
logfile: Somepath\myFile.log
send: ZN "AREA"
wait for:AREA>
send: D ^%RI
wait for:Device:
send: some/device/path
wait for:Next:
send: <CR>
This is documented in the Intersystems cache terminal documentation, especially the using terminal in batch mode section and the terminal scripts section.
This is a very old question .. as I came across the same thing and so with a little R&D I found a work around to this problem. Which is very cool and simple.
Let's say I have this file (can be with any extension with each command in separate line)
myScript.scr
zn "%SYS"
for e="a","b","c" { w e,! }
So passing it to cache terminal in case of UNIX is using csession with linux PIPE (|) operator
cat myScript.scr | csession {instance_name}
Eg.
cat myScript.scr | csession CACHE
output
a
b
c
Note:
• Don't separate a command in multiple lines else `csession` will through <SYNTAX> error. (See how I wrote the *for* loop)
• Extra knowledge - Intersystem Ensemble supports *Cache Terminal Batch Mode* in Windows case... While in linux there is no cterm to take the scripts..
• But linux gives you a work around to do this ;).
Hope this helps you guys!! cheers :D

MATLAB executing command line scripts for starting C++ programs? (without MEX)

I am running MATLAB 2011a under Ubuntu, and I have some C++ functions I execute from the command line such as `./community sample_networks/karate.bin -l -1 -q 0.01 > sample_networks/karateout.txt' These C++ functions produce a text file which I would like to pick up from MATLAB
I have not written these C++ functions and would like to simply have MATLAB pass a string to the command line to be executed so that the text file result can be picked up from MATLAB. I would like to avoid using MEX for the time being.
EDIT (using the system command does not work):
pwd
ans = /home/alex/Documents/MATLAB/MATLABsvnWorkingDir/Bloom/graphAnalysis/analysisAttempt2/functionsDownloaded/BlondelLouvainCPP/Community_BGLL_CPPLinux
system('./community sample_networks/karate.bin -l -1 -q 0.01 > sample_networks/karateout.txt > sample_networks/karateout.txt')
./community: /home/alex/matlab2011a/sys/os/glnx86/libstdc++.so.6: version `GLIBCXX_3.4.11' not found (required by ./community)
ans = 1
Looks like you just need to use the system function. This function will launch another executable, and wait until its finished.

Resources