Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

We are trying to generate the chromatogram for an ABI DNA sequencing file. Biojava (http://biojava.org) has a jar that will do this and many other things for DNA sequence files. Not sure how technical I need to be but a chromatogram is basically an image of the DNA detecting on the sequencing machine. I need to generate that image. I have attached the Jar and a sequencing file ("t1.ab1" as an example) and the Java code we are trying to get to work (with not a lot of success). We think we are close, but have a couple of errors. Anyone care to take a look and see if a fresh set of eyes will help? THANKS!!!

 

 

####Code below#####

 

import java.awt.image.BufferedImage;

import java.awt.Color;

import java.awt.Graphics2D;

import java.awt.Rectangle;

import java.awt.RenderingHints;

import java.io.IOException;

import java.io.File;

import java.io.FileNotFoundException;

import java.util.Iterator;

import javax.imageio.ImageIO;

import javax.imageio.ImageWriter;

import javax.imageio.stream.FileImageOutputStream;

import org.biojava.bio.chromatogram.Chromatogram;

import org.biojava.bio.chromatogram.ChromatogramFactory;

import org.biojava.bio.chromatogram.UnsupportedChromatogramFormatException;

import org.biojava.bio.chromatogram.graphic.ChromatogramGraphic;

import org.biojava.bio.program.abi.ABIFChromatogram

import org.biojava.bio.chromatogram.graphic.ChromatogramGraphic

import org.biojava.bio.chromatogram.*

import org.biojava.bio.chromatogram.graphic.*

import org.biojava.bio.program.abi.*;

import org.biojava.bio.*;

import org.biojava.bio.program.abi.*;

import org.biojava.bio.seq.*;

import org.biojava.bio.seq.impl.*;

import org.biojava.bio.seq.io.*;

import org.biojava.bio.symbol.*;

 

int OUT_HEIGHT = 240;

float OUT_HORIZ_SCALE = 2.0f;

 

File infile = new File('/Users/kessingb/Desktop/Chromatogram/t1.ab1');

//return infile

 

String name = infile.getName()

 

ABITrace trace = new ABITrace(infile)

//return trace.getSequenceLength()

return trace.getTraceLength()

 

Chromatogram c = ABIFChromatogram.create(infile)

//Chromatogram c = ChromatogramFactory.create(infile)

 

String outExt = "png";

Iterator writers = ImageIO.getImageWritersBySuffix(outExt);

ImageWriter iw = (ImageWriter) writers.next();

 

        /* build output stream */

        

File outfile = new File('/Users/kessingb/Desktop/Chromatogram/t1.jpg');

//FileImageOutputStream out = new FileImageOutputStream(outfile);

 

        

ChromatogramGraphic gfx = new ChromatogramGraphic(trace);

gfx.setHeight(OUT_HEIGHT);

gfx.setHorizontalScale(OUT_HORIZ_SCALE);

//set some options that affect the output

// turn off filled-in "callboxes"

gfx.setOption(ChromatogramGraphic.Option.DRAW_CALL_A, Boolean.FALSE);

gfx.setOption(ChromatogramGraphic.Option.DRAW_CALL_C, Boolean.FALSE);

gfx.setOption(ChromatogramGraphic.Option.DRAW_CALL_G, Boolean.FALSE);

gfx.setOption(ChromatogramGraphic.Option.DRAW_CALL_T, Boolean.FALSE);

gfx.setOption(ChromatogramGraphic.Option.DRAW_CALL_OTHER, Boolean.FALSE);

//this option controls whether each trace/callbox/etc is scaled/positioned

        // individually, or whether the scaling is done on all shapes at the level

        // of the graphics context

        // enabling this option is recommended for higher-quality output

gfx.setOption(ChromatogramGraphic.Option.USE_PER_SHAPE_TRANSFORM, Boolean.TRUE);

        

        /* create output image */

 

        BufferedImage bi = new BufferedImage(

                                   gfx.getWidth(), 

                                   gfx.getHeight(), 

                                   BufferedImage.TYPE_INT_RGB);

        Graphics2D g2 = bi.createGraphics();

        g2.setBackground(Color.white);

        g2.clearRect(0, 0, bi.getWidth(), bi.getHeight());

 

        /* draw chromatogram into image */

 

        // turn on AA for nicer output

        //g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

        // the main event

        gfx.drawTo(g2);

        // work-around an OS X bug where sometimes the last Shape drawn

        // doesn't show up in the output

        g2.draw(new java.awt.Rectangle(-10, -10, 5, 5));

 

        /* write image out */

 

        iw.setOutput(outfile);

biojava-1.7.1.jar

t1.ab1

Bailey

heres some code which works...
simplified where appropriate

<code>

import java.awt.image.BufferedImage
import java.awt.Color
import java.awt.Graphics2D
import java.awt.Rectangle
import java.awt.RenderingHints
import javax.imageio.ImageIO
import org.biojava.bio.chromatogram.Chromatogram
import org.biojava.bio.chromatogram.graphic.ChromatogramGraphic
import org.biojava.bio.program.abi.ABIFChromatogram
import org.biojava.bio.program.abi.ABITrace

OUT_HEIGHT = 240
OUT_HORIZ_SCALE = 2.0f

infile = new File('path/to/file')
//return infile

name = infile.getName()

trace = new ABITrace(infile)

c = ABIFChromatogram.create(infile)

    /* build output stream */
   
outfile = new File('/Users/whoever/documents/t1.jpg')
   
//ERROR in this line
gfx = new ChromatogramGraphic(c)
gfx.setHeight(OUT_HEIGHT)
gfx.setHorizontalScale(OUT_HORIZ_SCALE)
//set some options that affect the output
// turn off filled-in "callboxes"
gfx.setOption(ChromatogramGraphic.Option.DRAW_CALL_A, Boolean.FALSE)
gfx.setOption(ChromatogramGraphic.Option.DRAW_CALL_C, Boolean.FALSE)
gfx.setOption(ChromatogramGraphic.Option.DRAW_CALL_G, Boolean.FALSE)
gfx.setOption(ChromatogramGraphic.Option.DRAW_CALL_T, Boolean.FALSE)
gfx.setOption(ChromatogramGraphic.Option.DRAW_CALL_OTHER, Boolean.FALSE)
//this option controls whether each trace/callbox/etc is scaled/positioned
    // individually, or whether the scaling is done on all shapes at the level
    // of the graphics context
    // enabling this option is recommended for higher-quality output
gfx.setOption(ChromatogramGraphic.Option.USE_PER_SHAPE_TRANSFORM, Boolean.TRUE)
   
//return 888
    /* create output image */

bi = new BufferedImage( gfx.getWidth(), gfx.getHeight(), BufferedImage.TYPE_INT_RGB)
g2 = bi.createGraphics()
g2.setBackground(Color.white)
g2.clearRect(0, 0, bi.getWidth(), bi.getHeight())

    /* draw chromatogram into image */

    // turn on AA for nicer output
    //g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)
    // the main event
gfx.drawTo(g2)
    // work-around an OS X bug where sometimes the last Shape drawn
    // doesn't show up in the output
g2.draw(new java.awt.Rectangle(-10, -10, 5, 5))


    /* write image out */

try{
    ImageIO.write(bi, 'jpg', outfile)
} catch (e) {
    return e.getMessage()
}
return true
//OR return the image to a container
return bi

</code>

 

Edited by john renfrew

  • Author

Thanks so much!!! I will give it a try right away!!!

  • Author

OK John, I am still getting an error…let me see what I can ferret out…

Oh, here is the error I am getting: 

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:

Script1.groovy: 18: unexpected char: 0xA0 @ line 18, column 1.

      /* build output stream */

   ^

 

1 error

 

 

Parameters:

{}

0xA0 is an invalid character you sometimes get when posting code from online resources etc. Try using e.g. a text editor to do a search/replace on all occurrences, and then paste the code back into FileMaker.

  • Author

Ah, thanks. I should have thought of that!!! Will give it a try!!

the new forum does not have  proper code black like the older version which used to allow for copy without the extra characters...

It is the Unicode Character 'NO-BREAK SPACE' (U+00A0)

 

john

  • Author

Hey gang, thanks a lot for your hep!!! That was it. When I put in my text viewer it was giving the same looking code that a regular space was so I didn't notice it at first…should have, but hell, I am a scientist !! ;) Anyways, it is perfect now, thanks so much for all the help!!!

  • Author

If I wanted to read from a file that was stored in a container...

I am trying to use nfile = fmpro.getContainerStream("Demo::read container") but don't seem to have the syntax correct...

syntax is right

comment out the trace = new ABI trace line

I then get an EOF problem with the ab1 file though. This is >>Signals that an end of file or end of stream has been reached unexpectedly during input.

but from the Api >>Due to the non-single-pass design of the ABI format, this method will wrap the InputStream in an CachingInputStream. For this reason, create(File) should be preferred

  • Author

Yeah, that is what I am getting also. 

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.