openmolecules.org

 
Home » DataWarrior » Functionality » Opening SDF file with Datawarrior from command line
Opening SDF file with Datawarrior from command line [message #409] Tue, 30 October 2018 17:26 Go to next message
abc123 is currently offline  abc123
Messages: 7
Registered: October 2018
Junior Member
I often have to open Datawarrior with an SDF file buried deep inside folders. It would be nice to have Datawarrior operate from the command line with an SDF file argument.
Re: Opening SDF file with Datawarrior from command line [message #411 is a reply to message #409] Tue, 30 October 2018 22:23 Go to previous messageGo to next message
thomas is currently offline  thomas
Messages: 715
Registered: June 2014
Senior Member
This you can do. I just tried on Linux:
/opt/datawarrior/datawarrior some_path/some_file.sdf

On Windows I didn't try, but it should work the same way.
On the Mac it is different. The command line argument is evidently not passed to the jar file. As a workaround you may launch the jar the classical way: java -cp datawarrior.jar:lib1.jar:lib2.jar...libn.jar pathAndFile.sdf (in the jar list you include all jar files from the /Applications/DataWarrior.App/DataWarrior/Contents/Java folder)

The same way you may pass a macro file instead of an sd-file. The macro may contain tasks to load an sd-file, to do some other processing and to finally end DataWarrior itself. This way you could add some more stuff in a bash script.

Thomas
Re: Opening SDF file with Datawarrior from command line [message #414 is a reply to message #411] Wed, 31 October 2018 00:32 Go to previous messageGo to next message
abc123 is currently offline  abc123
Messages: 7
Registered: October 2018
Junior Member
I use a mac, is there some way to simplify this long command.

Even if we could have the File->Open dialog show the folder where DataWarrior was launched from, that would work too.
Re: Opening SDF file with Datawarrior from command line [message #418 is a reply to message #414] Sun, 04 November 2018 00:33 Go to previous messageGo to next message
thomas is currently offline  thomas
Messages: 715
Registered: June 2014
Senior Member
I have another suggestion. You may add directories, which contain frequently used dwar-, txt- or sd-files, to DataWarrior's file menu. On the Macintosh you achieve that by adding one additional text line to the 'Info.plist':
- In a Finder window move to the Application folder
- On 'DataWarrior' make a right mouse click (or Ctrl-mouse) and select 'Show Package Contents'
- Open the file 'Info.plist' from the 'Contents' folder with TextEdit
- Scroll down almost to the end of the file
- You notice some lines starting with '<string>-D'
- Add to these lines the following line and adapt the paths according to your needs.
<string> -Ddatapath=/Users/thomas/Documents/data/datawarrior:/Users/t homas/Documents/data/sdf </string>
- The next time you start DataWarrior after this change you will have two additional items in the file menu
that let you directly open any file in one of the two directories from the menu.
Of course, you may define more directories within the text line, if you separate them with a colon.

Hope this helps, Thopmas
Re: Opening SDF file with Datawarrior from command line [message #577 is a reply to message #418] Thu, 20 June 2019 12:46 Go to previous message
nbehrnd is currently offline  nbehrnd
Messages: 224
Registered: June 2019
Senior Member
Facing a similar situation to call DataWarrior either from the terminal
of Linux, or within a Python script within a loop, I created an alias
for the bash.

There are at least two options to provide the necessary information to
the operating system. Either a) create / edit file '.bashrc' in your
home directory which typically includes many more instructions how bash
shall work. If however this file contains a block

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

then you may b) create and edit file '.bash_aliases' in your home directory
which then is only about these user-defined shorthands. In either case,
add

alias datawarrior="/opt/datawarrior/datawarrior"


as new instruction. Omit the "%F" you may see in the program launcher.
More importantly though, do not use spaces prior, nor after the equal
sign. Save the edit and restart the terminal. Now all you have to enter
is 'datawarrior' as keyword. This is working fine on an installation of
Xubuntu LTS 18.04.2.

[Updated on: Thu, 20 June 2019 12:50]

Report message to a moderator

Previous Topic: Datawarrior Protonates the Oxygen in a Phosphorous Oxygen Double Bond.
Next Topic: network file export (cytoscape)
Goto Forum:
  


Current Time: Sat Nov 23 13:53:20 CET 2024

Total time taken to generate the page: 0.03985 seconds