mev-4.0.01/source/org/tigr/microarray/mev/cgh/CGHGuiObj/GuiUtil/GenomeBrowserLauncher.java

Code
Comments
Other
Rev Date Author Line
2 26 Feb 07 jari 1 /*
2 26 Feb 07 jari 2  * GenomeBrowserLauncher.java
2 26 Feb 07 jari 3  *
2 26 Feb 07 jari 4  * Created on July 10, 2003, 2:20 AM
2 26 Feb 07 jari 5  */
2 26 Feb 07 jari 6
2 26 Feb 07 jari 7 package org.tigr.microarray.mev.cgh.CGHGuiObj.GuiUtil;
2 26 Feb 07 jari 8
2 26 Feb 07 jari 9 import java.io.IOException;
2 26 Feb 07 jari 10
2 26 Feb 07 jari 11 import org.tigr.microarray.mev.TMEV;
2 26 Feb 07 jari 12 import org.tigr.microarray.mev.cgh.CGHDataObj.ICGHDataRegion;
2 26 Feb 07 jari 13
2 26 Feb 07 jari 14 import edu.stanford.ejalbert.BrowserLauncher;
2 26 Feb 07 jari 15
2 26 Feb 07 jari 16 /**
2 26 Feb 07 jari 17  *
2 26 Feb 07 jari 18  * @author  Adam Margolin
2 26 Feb 07 jari 19  * @author Raktim Sinha
2 26 Feb 07 jari 20  */
2 26 Feb 07 jari 21
2 26 Feb 07 jari 22 public class GenomeBrowserLauncher {
2 26 Feb 07 jari 23
2 26 Feb 07 jari 24   private static final int ENSEMBLE = 1;
2 26 Feb 07 jari 25   private static final int UCSC = 2;
2 26 Feb 07 jari 26   private static final int NCBI = 3;
2 26 Feb 07 jari 27
2 26 Feb 07 jari 28     /** Creates a new instance of GenomeBrowserLauncher */
2 26 Feb 07 jari 29     public GenomeBrowserLauncher() {
2 26 Feb 07 jari 30     }
2 26 Feb 07 jari 31
2 26 Feb 07 jari 32     /** Lanches a browser to dislpay Ensembl
2 26 Feb 07 jari 33      * @param dataRegion the data region to display
2 26 Feb 07 jari 34      */
2 26 Feb 07 jari 35     public static void launchEnsembl(ICGHDataRegion dataRegion, int species){
2 26 Feb 07 jari 36         String chromosome = getChromosomeName(dataRegion.getChromosomeIndex() + 1, species);
2 26 Feb 07 jari 37         String sp = getSpeciesName(ENSEMBLE, species);
2 26 Feb 07 jari 38         int start = dataRegion.getStart();
2 26 Feb 07 jari 39         int stop = dataRegion.getStop();
2 26 Feb 07 jari 40         String url = "http://www.ensembl.org/"+sp+"/contigview?chr="+chromosome+"&vc_start="+start+"&vc_end"
2 26 Feb 07 jari 41         +stop+"&x=15&y=8";
2 26 Feb 07 jari 42
2 26 Feb 07 jari 43         try{
2 26 Feb 07 jari 44             BrowserLauncher.openURL(url);
2 26 Feb 07 jari 45         }catch (IOException ioe){
2 26 Feb 07 jari 46             ioe.printStackTrace();
2 26 Feb 07 jari 47         }
2 26 Feb 07 jari 48     }
2 26 Feb 07 jari 49
2 26 Feb 07 jari 50     /** Lanches a browser to dislpay UCSC's Golden Path
2 26 Feb 07 jari 51      * @param dataRegion
2 26 Feb 07 jari 52      */
2 26 Feb 07 jari 53     public static void launchGoldenPath(ICGHDataRegion dataRegion, int species){
2 26 Feb 07 jari 54         String chromosome = getChromosomeName(dataRegion.getChromosomeIndex() + 1, species);
2 26 Feb 07 jari 55         String sp = getSpeciesName(UCSC, species);
2 26 Feb 07 jari 56         int start = dataRegion.getStart();
2 26 Feb 07 jari 57         int stop = dataRegion.getStop();
2 26 Feb 07 jari 58         String url = "http://genome.ucsc.edu/cgi-bin/hgTracks?db="+sp+"&position=chr"+chromosome+":"+start+"-"+stop;
2 26 Feb 07 jari 59
2 26 Feb 07 jari 60         try{
2 26 Feb 07 jari 61             BrowserLauncher.openURL(url);
2 26 Feb 07 jari 62         }catch (IOException ioe){
2 26 Feb 07 jari 63             ioe.printStackTrace();
2 26 Feb 07 jari 64         }
2 26 Feb 07 jari 65     }
2 26 Feb 07 jari 66
2 26 Feb 07 jari 67     /** Lanches a browser to dislpay NCBI's map viewer
2 26 Feb 07 jari 68      * @param dataRegion
2 26 Feb 07 jari 69      */
2 26 Feb 07 jari 70     public static void launchNCBIMapViewer(ICGHDataRegion dataRegion, int species){
2 26 Feb 07 jari 71         String chromosome = getChromosomeName(dataRegion.getChromosomeIndex() + 1, species);
2 26 Feb 07 jari 72         String sp = getSpeciesName(NCBI, species);
2 26 Feb 07 jari 73         int start = dataRegion.getStart();
2 26 Feb 07 jari 74         int stop = dataRegion.getStop();
2 26 Feb 07 jari 75         String url = "http://www.ncbi.nlm.nih.gov/mapview/maps.cgi?org="+sp+"&chr="+chromosome+"&BEG="+start+"&END="+stop;
2 26 Feb 07 jari 76         try{
2 26 Feb 07 jari 77             BrowserLauncher.openURL(url);
2 26 Feb 07 jari 78         }catch (IOException ioe){
2 26 Feb 07 jari 79             ioe.printStackTrace();
2 26 Feb 07 jari 80         }
2 26 Feb 07 jari 81     }
2 26 Feb 07 jari 82
2 26 Feb 07 jari 83     /** Lanches a browser to dislpay NCBI's map viewer
2 26 Feb 07 jari 84      * @param dataRegion
2 26 Feb 07 jari 85      */
2 26 Feb 07 jari 86     public static void launchNCBIMapViewer(ICGHDataRegion[] dataRegions, int species){
2 26 Feb 07 jari 87         String chromosome = getChromosomeName(dataRegions[0].getChromosomeIndex() + 1, species);
2 26 Feb 07 jari 88         String sp = getSpeciesName(NCBI, species);
2 26 Feb 07 jari 89         int start = dataRegions[0].getStart();
2 26 Feb 07 jari 90         int stop = dataRegions[dataRegions.length-1].getStop();
2 26 Feb 07 jari 91         String url = "http://www.ncbi.nlm.nih.gov/mapview/maps.cgi?org="+sp+"&chr="+chromosome+"&BEG="+start+"&END="+stop;
2 26 Feb 07 jari 92         try{
2 26 Feb 07 jari 93             BrowserLauncher.openURL(url);
2 26 Feb 07 jari 94         }catch (IOException ioe){
2 26 Feb 07 jari 95             ioe.printStackTrace();
2 26 Feb 07 jari 96         }
2 26 Feb 07 jari 97     }
2 26 Feb 07 jari 98
2 26 Feb 07 jari 99     private static String getChromosomeName(int chr, int species){
2 26 Feb 07 jari 100         String chromosome = chr + "";
2 26 Feb 07 jari 101         if("20".equals(chromosome) && (species == TMEV.CGH_SPECIES_MM)){
2 26 Feb 07 jari 102           chromosome = "X";
2 26 Feb 07 jari 103         }else if("21".equals(chromosome) && (species == TMEV.CGH_SPECIES_MM)){
2 26 Feb 07 jari 104             chromosome = "Y";
2 26 Feb 07 jari 105         }else if("23".equals(chromosome) && (species == TMEV.CGH_SPECIES_HS)){
2 26 Feb 07 jari 106             chromosome = "X";
2 26 Feb 07 jari 107         }else if("24".equals(chromosome) && (species == TMEV.CGH_SPECIES_HS)){
2 26 Feb 07 jari 108             chromosome = "Y";
2 26 Feb 07 jari 109         }
2 26 Feb 07 jari 110         return chromosome;
2 26 Feb 07 jari 111     }
2 26 Feb 07 jari 112
2 26 Feb 07 jari 113     private static String getSpeciesName(int browserSource, int sp){
2 26 Feb 07 jari 114       String species = "";
2 26 Feb 07 jari 115       switch (sp) {
2 26 Feb 07 jari 116         case TMEV.CGH_SPECIES_HS:
2 26 Feb 07 jari 117           switch(browserSource){
2 26 Feb 07 jari 118             case ENSEMBLE: species = "Homo_sapiens"; break;
2 26 Feb 07 jari 119             case UCSC: species = "hg17"; break;
2 26 Feb 07 jari 120             case NCBI: species = "human"; break;
2 26 Feb 07 jari 121           }
2 26 Feb 07 jari 122           break;
2 26 Feb 07 jari 123         case TMEV.CGH_SPECIES_MM:
2 26 Feb 07 jari 124           switch(browserSource){
2 26 Feb 07 jari 125             case ENSEMBLE: species = "Mus_musculus"; break;
2 26 Feb 07 jari 126             case UCSC: species = "mm6"; break;
2 26 Feb 07 jari 127             case NCBI: species = "mouse"; break;
2 26 Feb 07 jari 128         }
2 26 Feb 07 jari 129         break;
2 26 Feb 07 jari 130       }
2 26 Feb 07 jari 131       return species;
2 26 Feb 07 jari 132     }
2 26 Feb 07 jari 133 }