View Javadoc

1   //--------------------------------------
2   //
3   // SAMViewer.java
4   // Since: Nov 26, 2009
5   //
6   //--------------------------------------
7   package org.utgenome.gwt.utgb.server.app;
8   
9   import java.io.File;
10  import java.io.IOException;
11  
12  import javax.servlet.ServletException;
13  import javax.servlet.http.HttpServletRequest;
14  import javax.servlet.http.HttpServletResponse;
15  
16  import net.sf.samtools.SAMFileReader;
17  import net.sf.samtools.SAMRecord;
18  import net.sf.samtools.util.CloseableIterator;
19  
20  import org.utgenome.gwt.utgb.server.WebTrackBase;
21  import org.xerial.util.log.Logger;
22  
23  /**
24   * Web action: SAMViewer
25   * 
26   */
27  public class SAMViewer extends WebTrackBase {
28  	private static final long serialVersionUID = 1L;
29  	private static Logger _logger = Logger.getLogger(SAMViewer.class);
30  
31  	/**
32  	 * Describe web action parameters here. Public fields defined in this web action class will be set using the web
33  	 * request query parameters.
34  	 */
35  
36  	/**
37  	 * Predefined coordinate parameters for GenomeTrack. Uncomment the following lines if you want to receive these
38  	 * parameter values described in the request URL
39  	 */
40  	public String species; /* human, mouse, etc. */
41  	public String revision; /* hg19, mm9 ... */
42  	public String name; /* chr1, chr2, ... */
43  	public int start; /* start position on the genome */
44  	public int end; /* end position on the genome (inclusive) */
45  	public int width; /* track pixel width */
46  
47  	public SAMViewer() {
48  	}
49  
50  	public void handle(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
51  
52  		// swap
53  		if (start < end) {
54  			int tmp = start;
55  			start = end;
56  			end = tmp;
57  		}
58  
59  		SAMFileReader reader = new SAMFileReader(new File(""));
60  		CloseableIterator<SAMRecord> queryOverlapping = reader.queryOverlapping(name, start, end);
61  
62  		for (; queryOverlapping.hasNext();) {
63  			SAMRecord read = queryOverlapping.next();
64  
65  		}
66  
67  	}
68  
69  }