AI Agent -Driven Biochemical Optimization
3 hours ago
I find that I generally do NOT want org mode to execute source code
blocks as a side effect of exporting, which is the default behavior.
Rather, I prefer to explicitly execute the code either interactively
block by block (such as when I'm developing an analysis), or using
org-babel-execute-(buffer|subtree) commands. So, I typically set
`org-export-babel-evaluate` to nil on a buffer basis with the
following as 1st line in buffer:
# -*- org-export-babel-evaluate: nil; -*-
-- NAME: IGVGoTo.scpt
-- PURPOSE: Applescript to cause IGV (http://www.broad.mit.edu/igv/) to 'goto' the locus appearing in the Excel's active cell.
-- AUTHOR: malcolm_cook@stowers.org
-- REQUIRES:
-- * installing XNet as obtained from http://lestang.org/spip.php?article20
-- * the XOSL.Framework gets installed into Users//Library/Frameworks
-- * configuring IGV > View > Preferences > advanced > Enable Port
-- it must be checked ON and set to 60151 (the default)
-- INSTALLATION:
-- * Save this script as Users//Documents/Microsoft User Data/Excel Script Menu Items/IGVGoTo.scpt
-- * OPTIONAL: assign a keyboard shortcut:
-- * Open the System Preferences, click on "Keyboard & Mouse" and select the "Keyboard Shortcuts" tab.
-- * Click on the plus sign beneath the list view. In the dialog sheet that pops up, select Microsoft Excel from the Application menu (install it if needed - I had to)
-- * type "IGVGoTo" into the "Menu Title" field, tab to the Keyboard Shortcut field, and type in the shortcut you would like to use (I prefer Command-Option-I) and click the Add button
-- RUNNING IT:
-- * IGVGoTo will appear in Microsoft Excels's script menu (rightmost menu)
-- * navigate to a cell whose value is locus for the currently displayed IGV genome and run the script.
-- The active cells value will be used as the `locus` target of a `goto` command
-- * c.f. http://www.broadinstitute.org/igv/PortCommands for valid targets
-- TODO
-- * bring IGV to the front (optionally?)
-- * dispatch on the frontmost appliction - get the locus appropriate to the application - implement for
-- MSWord and FileMakerPro
-- * trap errors and provide diagnostics (i.e. XNet not installed, port not openable, IGV not running, bad response from IGV, etc)
tell application "Microsoft Excel"
my IGVGoTo("localhost", 60151, value of active cell as string) end tell
on IGVGoTo(theHost, thePort, theLocus)
tell application "XNet"
launch
set s to make new socket with properties {host:theHost, port:thePort}
socket open s
socket write s data "goto " & theLocus
delete s
end tell
end IGVGoTo
Public Sub IGV_Goto()
'PURPOSE: Excel Macro to cause IGV (http://www.broad.mit.edu/igv/) to 'goto' the locus appearing in the Excel's active cell.
' AUTHOR: malcolm_cook@stowers.org
' REQUIRES:
' * configuring IGV > View > Preferences > advanced > Enable Port
' it must be checked ON and set to 60151 (the default)
' * installing a free winsock implementation from "http://www.ostrosoft.com/oswinsck/oswinsck_vba.asp"
' INSTALLATION:
' * create a new VBA Macro out of this script in the desired Excel workbook - like this:
' alt-F11 to open VBA
' click on 'This workbook'
' paste in this script
' create a reference to the winsock library, by checking "OstroSoft Winsock Component" under "Tools > references".
' quit VBA with alt-q
' Alt-F8 (back in Excel) will list your macros - click option button to assign to a key (I use Ctrl-Shift-I)
On Error GoTo Err
Dim cmd As String
Dim locus As String
Dim r As Excel.Range
Set r = Excel.ActiveCell.EntireRow '.CurrentArray.RowDifferences..Rows
locus = Excel.ActiveCell.Value
cmd = "goto " & locus
Dim wso As New OSWINSCK.TCP ' free winsock implementation from "http://www.ostrosoft.com/oswinsck/oswinsck_vba.asp"
wso.Connect "localhost", 60151
wso.SendData cmd & vbCr
wso.Disconnect
ok:
Exit Sub
Err:
MsgBox Err.Description
End Sub