5
$\begingroup$

I have an external program called CHomP.

I am trying to send a command to CHomP via RunThrough, and read the output string.

It is meant to give the Betti numbers of a simplicial complex defined as $d$-tuples in a text file.

I have

RunThrough["/Users/alex/CHomP/build/bin/chomp-simplicial", "/Users/alex/CHomP/examples/new6.cub"]

which is meant to run

/Users/alex/CHomP/build/bin/chomp-simplicial /Users/alex/CHomP/examples/new6.cub

in the terminal. But I get a syntax error. What is wrong here? The output to the terminal is

Betti Numbers: 1 1 0 0

If you need it, the text file new6.cub is a list of simplices defined as tuples of vertex names...

109         
189         
182         
109 182     
142         
142 189     
32          
32  182     
32  109 182 
32  109     
49          
49  142     
49  109     
168         
32  168     
32  168 182 
32  109 168 182
32  109 168 
168 182     
109 168 182 
109 168     
115         
32  115     
32  115 182 
32  109 115 182
32  109 115 
115 182     
109 115 182 
115 189     
109 115     
2           
2   49      
2   49  142 
2   142     
2   142 189 
2   189     
$\endgroup$
2
$\begingroup$

One can use OpenRead with ! at the beginning to indicate the string is a command for the terminal.

        ToExpression@StringSplit[(*convert output to list of integers*)
            Read[OpenRead[
     "! /Users/alex/CHomP/build/bin/chomp-simplicial   
        /Users/alex/CHomP/examples/new6.cub"], String]][[3 ;; 6]]

which gives

{1, 1, 0, 0}

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.