Hi Abhishek,
There isn’t currently a direct way to do this with command line arguments, but it would be possible to do with a groovy script. I’ve written up such a script which I think will do what you’re after.
To get a colour scheme to automatically apply go to Tools → Preferences and change settings in the Visual and Colours tab (and also the Overview tab). Click OK to save these preferences, which will then be used by default when any new files are opened. If you want to save your original settings, make a copy of ~/.jalview_properties
before making the changes and then move it back when you’ve finished.
For efficiency, it’s best to run through all the files in one instance of Jalview (otherwise the Java Virtual Machine will have to start every time which would take forever for hundreds of files!) so I’ve added that loop into the groovy script too.
For this to work:
- First of all put all your fasta files into a single folder, say
/home/user/fafolder
.
- Then save the following script as a text file, called (e.g.)
faToOverviewPNG.groovy
and change the path for faFolder
near the top of the script to the folder you put the fasta files into. Also change the value of extension
to match the extension you used for your fasta files (if you didn’t use “.fa
”).
import java.awt.image.BufferedImage
import javax.imageio.ImageIO
def faFolder = new File("/home/user/fafolder")
def extension = ".fa"
for(def file: faFolder.listFiles()) {
if (!file.getName().endsWith(extension))
continue
def loader = new jalview.io.FileLoader(false)
def af = loader.LoadFileWaitTillLoaded(file, jalview.io.DataSourceType.FILE, null)
def view = af.getCurrentView()
view.setShowText(false)
view.setShowAnnotation(false)
af.overviewMenuItem_actionPerformed(null)
def ov = af.alignPanel.getOverviewPanel()
ov.progressPanel.setVisible(false);
try {
Thread.sleep(50)
} catch(Exception e) {}
ov.od.setBoxPosition(-100,-100,0,0)
ov.repaint()
def img = new BufferedImage(ov.getWidth(), ov.getHeight(), BufferedImage.TYPE_INT_RGB)
ov.paint(img.getGraphics())
def filename = file.getAbsolutePath()
def pngFile = new File(filename.substring(0,filename.length() - extension.length())+".png")
ImageIO.write(img, "png", pngFile)
af.doDefaultCloseAction()
}
Jalview.quit();
- Then you can launch Jalview on the command line with
jalview -nowebservicediscovery -groovy fafolderOverviewPNG.groovy
which will still open the GUI but launch straight into the groovy script. If you want to save the Visual and Colour preferences you’ve set for another time, you can copy ~/.jalview_properties
to some other file and load that with -props some_other_file
in addition to the arguments above.
As an alternative to using the command line you could launch Jalview the normal way, then open Tools → Groovy Console… and paste the script into the console (you will probably want to delete the Jalview.quit()
line at the end!) and click on the Execute Groovy Script button to run it. This is good for debugging problems if you want to adjust the script too.
Let us know how you get on!
Ben
faToOverviewPNG.groovy.txt (1.1 KB)
PS The line view.setShowText(false)
isn’t needed for the overview window, but could be used to make a similar PNG directly from the alignment window.