gt:              SNP input = new SNP(null);
context: /*GESPA  Copyright (C) 2013  Jay Khurana
   * See GESPA License for additional information.
   */
  
  package DNAFinderMain;
  
  /**
   *
   * @author Jay Khurana
   */
  import java.util.*;
  import java.text.SimpleDateFormat;
  import java.util.logging.Level;
  import java.util.logging.Logger;
  import javax.swing.table.*;
  import javax.swing.*;
  import java.net.URI;
  import com.gargoylesoftware.htmlunit.BrowserVersion;
  import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
  import com.gargoylesoftware.htmlunit.Page;
  import com.gargoylesoftware.htmlunit.RefreshHandler;
  import com.gargoylesoftware.htmlunit.WebClient;
  import com.gargoylesoftware.htmlunit.html.*;
  import com.gargoylesoftware.htmlunit.IncorrectnessListener; 
  import java.io.IOException;
  import java.net.URISyntaxException;
  import java.awt.Rectangle;
  import org.w3c.dom.*;
  import org.biojava.bio.BioException;
  import java.net.SocketTimeoutException;
  import java.io.*;
  import java.sql.*;
  public class Framework implements Runnable{
            
      /**
       * Creates a new instance of <code>Framework</code>.
       */
      private URLReader urlReader1;
      private String gene;
      private String geneSearchURL;
      private String geneURL;
      private JTable table;
      private GenePanel panel;
      private int threadNum;
      private int numHomologs;//or number of orthologs
      private int numParalogs;
      private String nFasta; 
      private String pFasta;
      private String nFasta2;
      private String pFasta2;
      private String tempDNA;
      private String aFasta;
      private String report;
      private String[] reports;
      private int reportCounter;
      private SNP[] allSNPs;
      private SNP[] tempSNPs;
      private DefaultTableModel model;
      private Framework f;    
      private Gene gene1;
      private Gene geneTemp;
      private BatchManager b;
      private String[] rowURL;
      private String[] geneProperties;
      private int numClinicalSNPs;
      private boolean existingSNPs;
      private boolean noExistingSNPs=false;
      private boolean batchComplete=false;
      private boolean activeBatch=false;
      private boolean saveDataToCloud=true;
      private boolean SQLError = false;
      private boolean geneInSQL;
      private boolean repeatCheck=false;
      private boolean sqlTimeCheck=true;
      private Connection con;    
      private List<String> SNPs;
      private List<String> PSICScore;
      private List<String> toleratedSubst;
      
      public static int exception=0;
     
      //Initializes some instance variables
      public Framework(){
          this.existingSNPs = true;
          geneSearchURL=nFasta=pFasta=nFasta2=pFasta2=tempDNA=aFasta=report="";
          reports=new String[5000];
          rowURL=new String[5000];
          geneProperties=new String[9];
          for(int i=0; i<5000; i++)
              reports[i]="";
          reportCounter=threadNum=numClinicalSNPs=numHomologs=numParalogs=0;
          PSICScore=new ArrayList<>();
          toleratedSubst=new ArrayList<>();
          geneInSQL=false;
      }
      
      public void nullFramework(){
       urlReader1=null;
       gene=null;
       geneSearchURL=null;
       geneURL=null;
       table=null;
       panel=null;
       nFasta=null; 
       pFasta=null;
       nFasta2=null;
       pFasta2=null;
       tempDNA=null;
       aFasta=null;
       report=null;
       reports=null;
       for(SNP s:allSNPs)
           s=null;
       for(SNP s:tempSNPs)
           s=null;
       allSNPs=null;
       tempSNPs=null;
       model=null;
       gene1.nullGene();
       geneTemp.nullGene();
       gene1=null;
       geneTemp=null;
       b=null;
       for(String s: geneProperties)
           s=null;
       for(String s: rowURL)
           s=null;
       geneProperties=null;
       rowURL=null;
       con=null;    
       SNPs=null;
       PSICScore=null;
       toleratedSubst=null;        
      }
      
      public boolean getActiveBatch(){
          return activeBatch;
      }
      
      public void setFramework(Framework f){
          this.f=f;
          geneTemp= new Gene(f);
          //System.out.print("");
      }
      
      public void setActiveBatch(boolean b){
          activeBatch=b;
      }
      
      public void setSNPs(List<String> SNPs){
          this.SNPs=SNPs;
      }
      
      public void setBatchManager(BatchManager b){
          this.b=b;
      }
      
      public void setTable(JTable t){
          table=t;
          model=(DefaultTableModel)table.getModel();
      }
      
      public void setReports(List<String> r){
          reports=r.toArray(new String[r.size()]);
      }
      
      public void setPSICScores(List<String> p){
          PSICScore=p;
      }
      
      public BatchManager getBatchManager(){
          return b;
      }
      
      public Framework getFramework(){
          return f;
      }
      
      public String[] getGeneProperties(){
          return geneProperties;
      }
      
      public String[] getReport(){
          return reports;
      }
      
      public List<String> getToleratedSubst(){
          return toleratedSubst;
      }
      
      public void setToleratedSubst(List<String> t){
          toleratedSubst=t;
      }
      
      public List<String> getPSICScores(){
          return PSICScore; 
      }
      
      public int getNumHomologs(){
          return numHomologs;
      }
      
      public int getNumParalogs(){
          return numParalogs;
      }
      
      public boolean activeBatch(){
          return activeBatch;
      }
      
      //Checks gene via either genes in cloud or NCBI Gene Database Search
      public String checkGene(String geneTemp) throws Exception{ 
          if(b==null&&!repeatCheck){            
              try{
                  connectToSQL();
                  gene=geneTemp;
                  if(checkSQLForGene()){
                      geneInSQL=true;
                      return geneTemp;
                  }else
                      System.out.println("Gene not Found");
              }catch(Exception exe){}
          }
          urlReader1= new URLReader();
          geneSearchURL="http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=gene&term="+geneTemp+"[pref]AND homo sapiens[orgn]";        
          geneSearchURL=geneSearchURL.replace(" ", "+");
          try{
              if(urlReader1.findStringinURL(geneSearchURL, "PhraseNotFound")){
                  if(b==null)
                      JOptionPane.showMessageDialog(null, "Could not find HUGO gene symbol for "+geneTemp+".", "Warning", JOptionPane.WARNING_MESSAGE);
                  return null;
              }else if(urlReader1.getHTML().contains("Failed to translate")){
                  JOptionPane.showMessageDialog(null, "Part of the NCBI servers are currently down, please try again later!", "Warning", JOptionPane.WARNING_MESSAGE);
              }else{
  		try{
                      String geneId=urlReader1.getHTML().substring(urlReader1.getHTML().indexOf("<Id>")+4,urlReader1.getHTML().indexOf("</Id"));
                      geneSearchURL="http://www.ncbi.nlm.nih.gov/gene/"+geneId;
                      geneURL=geneSearchURL;
                      gene=geneTemp;
                     
                      return geneSearchURL;
  		}catch(Exception exe){
  	            if(b==null)
                          JOptionPane.showMessageDialog(null, "Invalid Gene!");
                      return null;
                  }
  	    }
  	}catch(Exception exe){
              if(!repeatCheck){
                  repeatCheck=true;
                  return checkGene(geneTemp);
              }            
              if(exe instanceof SocketTimeoutException)
                  throw exe;
              if(b==null)    
                  JOptionPane.showMessageDialog(null, "This application requires a "
                      + "valid internet connection!", "Warning", JOptionPane.WARNING_MESSAGE);
              else{
                  b.addError("No internet connection found/internet connection lost!");
                  throw new IOException();
              }
              return null;
  	}        
         if(b==null)
              JOptionPane.showMessageDialog(null, "Invalid Gene!");
          return null;
      }
      
      public void setGeneURL(String g) throws Exception{
          urlReader1=new URLReader();
          try{    
              urlReader1.findStringinURL(g, "a");
          }catch(Exception exe){
              throw exe;
          }
          geneURL=geneSearchURL=g;
      }
      
      public void setGene(String gene){
          this.gene=gene;
      }
      
      public void setSaveToCloud(boolean save){
          saveDataToCloud=save;
      }
      
      //starting place for new threads
      @Override
      public void run(){
          try{
              start();
          }catch(OutOfMemoryError err){
              JFrameMain.numConcurrentThreads--;
              try{    
                  closeSQL();
              }catch(SQLException exe){}
  //            JOptionPane.showMessageDialog(null, "Fatal Error: JVM has run out of memory!", "Fatal Error", JOptionPane.ERROR_MESSAGE);
          }catch(Exception exe){
              exe.printStackTrace();
              try{
                  System.out.println("Exception in gene " + gene);
              }catch(Exception exe2){}            
              if(!(exe instanceof StringIndexOutOfBoundsException||exe instanceof ArrayIndexOutOfBoundsException))    
                  try{
                      clearAll();
                      start();
                      return;
                  }catch(Exception exe2){}   
                  try{
                      clearAll();
                      JFrameMain.useSQL=true;
                      start();
                      JFrameMain.useSQL=false;
                      if(activeBatch||b!=null){
                          b.addError("Error: An error was encountered while conventionally retrieving data. \nData was retrieved from the cloud.");
                      }else{
                          JOptionPane.showMessageDialog(null, "Error: An error was encountered while conventionally retrieving data. \nData was retrieved from the cloud.", "Error", JOptionPane.ERROR_MESSAGE);
                      }
                      return;
                  }catch(Exception exe2){
                      exe2.printStackTrace();
                  }
              try{    
                  closeSQL();
              }catch(SQLException exe2){}            
              exe.printStackTrace();                
              StringWriter sw = new StringWriter();
                  PrintWriter pw = new PrintWriter(sw);
                  exe.printStackTrace(pw);
                  String errorMessage=sw.toString();                
                  if(activeBatch||b!=null){
                      if(errorMessage.indexOf("eutils")!=-1||errorMessage.indexOf("NCBIFinder")==-1)
                          b.addError("Error: GenBank accession error. ");
                          try{
                              b.addError("for "+getGene().getName());
                          }catch(Exception exe2){}
                      activeBatch=false;
                      JFrameMain.numConcurrentThreads--;                      
                      this.b.threadManager();                    
                      return;
                  }
                  if(errorMessage.indexOf("eutils")!=-1||errorMessage.indexOf("NCBIFinder")==-1)
                      JOptionPane.showMessageDialog(null, "Error: GenBank accession error. ", "Error", JOptionPane.ERROR_MESSAGE);
                  JFrameMain.numConcurrentThreads--;                    
                  //else
                      //JOptionPane.showMessageDialog(null, "An unknown error occured! Please try again later.\n"+errorMessage, "Error", JOptionPane.ERROR_MESSAGE);
                  //Thread t=Thread.currentThread();
           //       Framework.okInternet=true;
      }catch(Error e){
          JFrameMain.numConcurrentThreads--;
          try{    
              closeSQL();
          }catch(SQLException exe){}        
          JOptionPane.showMessageDialog(null, "An unknown error "
                  + "occured!", "Error", JOptionPane.ERROR_MESSAGE);        
      }
  }
      
      public void setPanel(JPanel p){
          panel=(GenePanel)p;
      }
      
      /*All Framework threads go through this method which collects the data via 
       * either accessing the data through clouds or initiating collection through 
       * websites if data is not availible on the cloud. 
       */
      public void start() throws Exception{
          panel.setFramework(f);
     //    Framework.okInternet=false;
          threadNum=JFrameMain.getThreadCounter();
          gene=gene.toUpperCase();
          table=panel.getTable();
          geneSearchURL="";
          //Scanner reader = new Scanner(System.in);
          boolean b=false;
          if(JFrameMain.useSQL&&sqlTimeCheck){
              if(geneInSQL){
                  try{
                      saveDataToCloud=false;                    
                      retrieveDataFromSQL();                
                  }catch(Exception exe){
                      exe.printStackTrace();
                      saveDataToCloud=true;
                      SQLError=true;
                  }
              }else if(this.b!=null)
                  try{
                      connectToSQL();
                      if(checkSQLForGene()){
                          System.out.println("Gene Found");
                          saveDataToCloud=false;
                          this.retrieveDataFromSQL();
                      }else
                          System.out.println("Gene not Found");
                  }catch(Exception exe){
                      exe.printStackTrace();
                      saveDataToCloud=true;
                      SQLError=true;
              }   
          }
          if(!JFrameMain.useSQL||saveDataToCloud||!sqlTimeCheck)
              collectData();
          JFrameMain.disableSettings();
          int numRows=table.getRowCount();
          geneProperties[7]=numHomologs+"";
          geneProperties[8]=numParalogs+"";
          if(JFrameMain.useSQL&&saveDataToCloud&&!JFrameMain.askForParalog)
              try{
                  this.saveDataToSQL();
              }catch(Exception exe){
                  exe.printStackTrace();
                  //didn't work code
              }
          try{    
              closeSQL();
          }catch(SQLException exe){}  
          JFrameMain.enableSettings();
          existingSNPs=true;
          for(int j=0;j<numRows;j++){
              String s=(String)model.getValueAt(j, 1);
              enterCustomSNP(s);
          }        
          existingSNPs=false;
          JFrameMain.numConcurrentThreads--;          
          if(activeBatch){
              for(String s: SNPs){
                  try{
                      enterCustomSNP(s);
                  }catch(Exception exe){}
              }
              this.b.batchPanelManager(f, model);
              activeBatch=false;                      
              this.b.threadManager(); 
          }
          clearFinishedReferences(false);
      }
      
      //calls methods to collect data from various websites
      private void collectData() throws Exception{
          model=(DefaultTableModel)table.getModel();        
          NCBIFinder finder = new NCBIFinder();        
          //String MIM = (urlReader1.extractString(">MIM:", ";")).substring(5);
          //String geneID = (urlReader1.extractString(">Gene ID: ", ",")).substring(10);
          if(SQLError||!JFrameMain.useSQL){
              repeatCheck=true;            
              checkGene(gene);
          }
          finder.waitComplete();
          String nucleoURL="http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=gene&id="
                  +geneURL.substring(geneURL.lastIndexOf("/")+1);
          urlReader1.findStringinURL(nucleoURL, "a");
          finder.waitComplete();
          String urlHTML=urlReader1.getHTML();
          String tempID, nucleoID;
          while(true){
              urlHTML=urlHTML.substring(urlHTML.indexOf("products")+1);
              tempID=urlHTML.substring(0,300);
              if(tempID.contains("mRNA")&&tempID.contains("Reference")){
                  try{
                      nucleoID=tempID.substring(tempID.indexOf("accession")+11);
                      String nucleoVersion=nucleoID.substring(nucleoID.indexOf("version")+8);
                      nucleoVersion=nucleoVersion.substring(0, nucleoVersion.indexOf(","));
                      nucleoID=nucleoID.substring(0,nucleoID.indexOf(",")-1)+"."+nucleoVersion;
                      break;
                  }catch(Exception exe){}
              }
          }
         // String tempID = urlReader1.getHTML().substring(urlReader1.getHTML().indexOf("mRNA and Protein"),urlReader1.getHTML().indexOf("mRNA and Protein")+250);
          //String nucleoID = tempID.substring(tempID.indexOf("core")+5,tempID.indexOf("core")+ tempID.substring(tempID.indexOf("core")).indexOf("\""));
          //String protID = tempID.substring(tempID.indexOf("ein/")+4,tempID.indexOf("ein/") + tempID.substring(tempID.indexOf("ein/")).indexOf("\"")); 
          String protID;
          while(true){
              urlHTML=urlHTML.substring(urlHTML.indexOf("products")+1);
              tempID=urlHTML.substring(0,400);
              if(tempID.contains("peptide")&&tempID.contains("Reference")){
                  try{
                      protID=tempID.substring(tempID.indexOf("accession")+11);
                      String protVersion=protID.substring(protID.indexOf("version")+8);
                      protVersion=protVersion.substring(0, protVersion.indexOf(","));
                      protID=protID.substring(0,protID.indexOf(",")-1)+"."+protVersion;
                      break;
                  }catch(Exception exe){}
              }
          }
          try{    
              tempDNA = finder.nucleoFinder(nucleoID);
          }catch(Exception exe){
              throw exe;
          }
          try{
              aFasta = finder.protFinder(protID);
          }catch(Exception exe){
              throw exe;          
          }
          String nucleoFasta = ">" + gene +"\n" + tempDNA + "\n";
          String protFasta =">" + gene +"\n" + aFasta + "\n";
          String tempHTML=urlReader1.getHTML();
          String chromosome=tempHTML.substring(tempHTML.indexOf("subtype chromosome,"),tempHTML.indexOf("subtype chromosome,")+200);
          chromosome=chromosome.substring(chromosome.indexOf("name")+6,chromosome.indexOf("}")-7);
          String tempStartEnd=tempHTML.substring(tempHTML.indexOf("seqs {"),tempHTML.indexOf("seqs {")+250);//tempHTML.substring(tempHTML.indexOf(">Chr<")-1000, tempHTML.indexOf(">Chr<")+1000);
          //tempStartEnd=tempStartEnd.substring(tempStartEnd.indexOf("..")-25);
          //String tempStartEnd = urlReader1.extractString(urlReader">Chromosome", "<");
          String start = tempStartEnd.substring(tempStartEnd.indexOf("from ")+5,tempStartEnd.indexOf("to ")-11);//Integer.parseInt(tempStartEnd.substring(tempStartEnd.indexOf("(")+1,tempStartEnd.indexOf("(")+tempStartEnd.substring(tempStartEnd.indexOf("(")).indexOf(".")));
          String end = tempStartEnd.substring(tempStartEnd.indexOf("to ")+3,tempStartEnd.indexOf("strand ")-11);;
          try{
              start=""+(Integer.parseInt(start)+1);
              end=""+(Integer.parseInt(end)+1);            
          }catch(Exception exe){
              
          }
          /* try{
              if(tempStartEnd.indexOf("complement")==-1)
  		end = Integer.parseInt(tempStartEnd.substring(tempStartEnd.indexOf("..")+2,tempStartEnd.indexOf(")")));
              else 
                  end = Integer.parseInt(tempStartEnd.substring(tempStartEnd.indexOf("..")+2,tempStartEnd.indexOf(",")));
          }catch(Exception exe){}*/
          //String chromosome = tempStartEnd.substring(tempStartEnd.indexOf("Chromosome")+10,tempStartEnd.indexOf("Chromosome")+tempStartEnd.substring(tempStartEnd.indexOf("Chromosome")).indexOf("-"));
       	panel.setLabels(gene,chromosome,""+start,""+end,nucleoID,protID);
          panel.enableGeneSequences();
          geneProperties[0]=gene;
          geneProperties[1]=chromosome; 
          geneProperties[2]= start;
          geneProperties[3]= end;
          geneProperties[4]= nucleoID;
          geneProperties[5]=protID;
          geneProperties[6]=geneURL;        
          gene1=new Gene(gene,nucleoID, protID, nucleoFasta, protFasta);        
          Gene[] homologs = new Gene[67];
          String[] fastas=null;        
          int SNPFoundCounter=0;
          SNP:
          while(true){
      	   // System.out.println("Obtaining SNPs");            
              allSNPs = new SNP[5000]; 
              SNP snp=new SNP(f);
              snp.setAttempts(0);
              int attempts=0;
              while(true){
                  attempts++;
                  if(attempts>5){
                      tempSNPs=null;
                      saveDataToCloud=false;                    
                      break SNP;
                  }                    
                  try{    
                      tempSNPs=snp.getAllSNPsNew();
                  }catch(Exception exe){
                      exe.printStackTrace();
                      snp=new SNP(f);
                      snp.setAttempts(attempts);
                      continue;
                  }
                  break;
              }
              int counter=0;
              //tempSNPs=null;//REMOVE LATER
              if(tempSNPs!=null){    
                  for(SNP s:tempSNPs){
                      if(s!=null){
                          try{     
                              allSNPs[counter]=s;
                              String SNPID=aFasta.substring(s.getProtLoc()-1,s.getProtLoc())+s.getProtLoc()+s.getProtChange();
                              String SNPPheno=s.getPhenotype();
                              boolean verified=s.getMultipleConfirmed();
                              String SNPVerified="";
                              if(verified)
                                  SNPVerified="Multiple Publications";
                              else
                                  SNPVerified="Single Publication";
                              model.addRow(new Object[]{false,SNPID,SNPPheno,SNPVerified,"Please Wait"});
                              int x=model.getRowCount();
                              rowURL[model.getRowCount()-1]=allSNPs[counter].getInfoUrl();
                              counter++;
                          }catch(StringIndexOutOfBoundsException exe){}
                      }
                  }
                  numClinicalSNPs=model.getRowCount();
                  break SNP;
              }else{
                  if(SNPFoundCounter==3){
                      if(!activeBatch)
                          JOptionPane.showMessageDialog(null, "There are no "
                                  + "previously idenified clinically related SNPs "
                                  + "for "+getGene().getName()+"! However, feel free"
                                  + " to enter your own SNPs.", "Warning", 
                                  JOptionPane.WARNING_MESSAGE);
                      noExistingSNPs=true;
                      break SNP;
                  }
                  SNPFoundCounter++;
              }
          }
          if(model==null)
              model=(DefaultTableModel)table.getModel();            
          panel.infoReady();   
          if(JFrameMain.useParalogs)
              try{
                  fastas=geneTemp.getFamily();
                  numParalogs=geneTemp.getNumParalogs();
              }catch(Exception exe){
                  fastas=geneTemp.getFamily();
              }
          else
              saveDataToCloud=false;
          try{    
              nFasta2=fastas[0];
              pFasta2=fastas[1];
          }catch(NullPointerException exe){}
          panel.enableParalogs();
          int homologLoc=-1;
          try{
  	//		geneSearchURL = "http://www.ncbi.nlm.nih.gov" + urlReader1.extractHyperLink(150, "Homologs of the", "/homologene");
  	//		//System.out.println(geneSearchURL);	
              urlReader1.findStringinURL(nucleoURL,"");
              homologLoc=urlHTML.indexOf("db \"HomoloGene\",");
              if(homologLoc==-1)
                  throw new Exception();
          }catch(Exception exe){
      		//System.out.print("No Homologs");
      		homologs=null;
      	}
          String homologID="-1";
      	if(homologs!=null){
                  homologID=urlHTML.substring(homologLoc,homologLoc+100);
                  homologID=homologID.substring(homologID.indexOf("id")+3,homologID.indexOf("}")-1).trim();               
                  try{
                      finder.waitComplete();
                      urlReader1.findStringinURL(nucleoURL,"");
      		}catch(Exception exe){
      		//	System.out.print("");
      		}
      		HomologFinder h = new HomologFinder(urlReader1.getHTML(), nucleoURL, f);
                  try{
                      fastas = h.findHomologsEut(homologID);
                      //fastas = h.findHomologs();
                  }catch(Exception exe){
                      fastas=h.findHomologs();
                  }
                  numHomologs=h.getNumHomolgs();
      		if(fastas==null)
                      return;
                  nFasta=fastas[0];
      		pFasta=fastas[1];
      	}
          panel.stopWait();
          panel.enableMutationChecking();
          panel.stopWait2();
          panel.enableReport();
          panel.enableHomologs();        
      }
      
      //nulls instance variables containing unnecessary references
      private void clearFinishedReferences(boolean exception){
          if(!exception){
              urlReader1=null;
              gene=null;
              panel=null;           
          }
      }
      
      //Takes a mutation (SNP) as input and adds it to a table of SNPs
      public synchronized void enterCustomSNP(String cb){
          if(numParalogs==1)
              numParalogs=0;
          boolean subConservation=false;
      	if(cb==null)
              return;
          String cbSave=cb;
          boolean snpFound=false;
          int tempPercentage;
      	int snpNucleoLoc=-1;
      	int snpProtLoc=-1;
          double percentage=0;
          double percentageOriginal=0;
          int validCounterOriginal=0;
          int validCounter=0;
          String tempReport;
      	boolean notFound1 = false;
      	boolean notFound2=false;
      	boolean tooShort = false;
      	//tempDNA=tempDNA.substring(0, tempDNA.length()-45);	
      	String temp=tempDNA;
      	String nucleoSeq;
      	String codon="";
      	String protSeq;
          String cbOrigin;
          cbOrigin = cb.trim().toLowerCase();
          cb=cbOrigin;
          if(cb.substring(0,2).equals("rs"))
              cb=rsConvert(cb);
          if(cb==null)
              return;
          String nucleoChange="";
          try{
            cb=cb.replace(" ", "");
            int loc=Integer.parseInt(cb.substring(0,cb.indexOf(">")));
            nucleoChange=cb.substring(cb.length()-1);
            cb=tempDNA.substring(loc-1,loc+45).toLowerCase();
            cbOrigin=cb;
          }catch(Exception exe){}
      	if(cb.length()>2)
              codon = cb.substring(0,3); 	
          if((cb.indexOf("a")!=-1||cb.indexOf("c")!=-1||cb.indexOf("g")!=-1||cb.indexOf("t")!=-1)&&!(cb.substring(1,2).equals("1")||cb.substring(1,2).equals("2")||cb.substring(1,2).equals("3")||cb.substring(1,2).equals("4")||cb.substring(1,2).equals("5")||cb.substring(1,2).equals("6")||cb.substring(1,2).equals("7")||cb.substring(1,2).equals("8")||cb.substring(1,2).equals("9")||cb.substring(1,2).equals("0"))){
              cb=cb.toUpperCase();
              if(cb.indexOf(">")!=-1){
                  cb=cb.replace(" ", "");
                  nucleoChange=cb.substring(cb.length()-1);
                  cb=cb.substring(0,cb.indexOf(">"));
              }
              if(!checkInput(cb))
                  return;
              int index = tempDNA.indexOf(cb);
              nucleoSeq=findInProtein(index);
              if(nucleoSeq==null){
                  if(!activeBatch)
                      JOptionPane.showMessageDialog(null,"The nucleotide at the "
                              + "location entered is on an intron! "
                              + "Please enter a different SNP.", 
                              "Warning", JOptionPane.WARNING_MESSAGE);
                  else
                      b.addError("SNP:"+cbSave+" The nucleotide"
                          + " at the location of this SNP is "
                          + "on an intron! Please enter a "
                          + "different SNP.");
                      return;
              }
              String nucleoSeqOrigin=tempDNA.substring(index,index+40);
              index=tempDNA.indexOf(cb);
              snpProtLoc=aFasta.indexOf(geneTemp.convertToAmino(nucleoSeq))+1;
              //ADD BACKWARDS
              protSeq=aFasta.substring(snpProtLoc-1,snpProtLoc+14);
              String codon1=nucleoSeq.substring(0,3).toUpperCase();
              String codon2="";
              String protChange;
              snpNucleoLoc=index+1;
              String nAtLoc=tempDNA.substring(snpNucleoLoc-1,snpNucleoLoc).toUpperCase();
               int optionOriginal=nucleoSeq.indexOf(nucleoSeqOrigin);            
               if(optionOriginal==0)
                   codon2=nucleoChange+codon1.substring(1,2)+codon1.substring(2,3).toUpperCase();
               else if(optionOriginal==1)
                   codon2=codon1.substring(0,1)+nucleoChange+codon1.substring(2,3);
               else if(optionOriginal==2)
                   codon2=codon1.substring(0,1)+codon1.substring(1,2)+nucleoChange;
               codon2=codon2.toUpperCase();
               protChange=geneTemp.convertToAmino(codon2);
  