src/org/gel/mauve/summary/AnalysisModuleFrame.java

Go to the documentation of this file.
00001 package org.gel.mauve.summary;
00002 
00003 import java.io.File;
00004 import java.util.Hashtable;
00005 import java.util.Iterator;
00006 
00007 import org.gel.mauve.BaseViewerModel;
00008 import org.gel.mauve.Chromosome;
00009 import org.gel.mauve.Genome;
00010 import org.gel.mauve.MauveConstants;
00011 import org.gel.mauve.analysis.Segment;
00012 import org.gel.mauve.contigs.ContigHandler;
00013 import org.gel.mauve.contigs.DefaultContigHandler;
00014 import org.gel.mauve.gui.Mauve;
00015 import org.gel.mauve.gui.MauveFrame;
00016 import org.gel.mauve.gui.sequence.FlatFileFeatureConstants;
00017 import org.gel.mauve.summary.output.SegmentDataProcessor;
00018 
00019 public class AnalysisModuleFrame extends MauveFrame implements FlatFileFeatureConstants,
00020                 ContigHandler {
00021         
00022         protected DefaultContigHandler contig_handler;
00023 
00024         public AnalysisModuleFrame (Mauve mauve) {
00025                 super (mauve);
00026                 
00027         }
00028         
00029         public void setModel (BaseViewerModel model) {
00030                 try {
00031                         super.setModel (model);
00032                         contig_handler = new DefaultContigHandler (model);
00033                         final Hashtable args = new Hashtable ();
00034                         File file = model.getSrc ();
00035                         System.out.println ("name: " + file.getName ());
00036                         int end = file.getName ().lastIndexOf ('.');
00037                         if (end > -1)
00038                                 file = new File (file.getParentFile (), 
00039                                                 file.getName ().substring (0, end));
00040                         System.out.println ("name: " + file.getName ());
00041                         args.put (ProcessBackboneFile.INPUT_FILE, file.toString ());
00042                         args.put (MODEL, model);
00043                         args.put (CONTIG_HANDLER, this);
00044                         Iterator itty = MauveInterfacer.feat_files.iterator (); 
00045                         while (itty.hasNext ()) {
00046                                 Object [] data = (Object []) itty.next (); 
00047                                 importer.importAnnotationFile ((File) data [0], 
00048                                                 model.getGenomeBySourceIndex (((Integer) data [1]).intValue ()));
00049                         }
00050                         long [] lengths = new long [model.getSequenceCount ()];
00051                         for (int i = 0; i < lengths.length; i++) {
00052                                 lengths [i] = model.getGenomeBySourceIndex (i).getLength ();
00053                                 System.out.println ("length: " + lengths [i]);
00054                         }
00055                         args.put (GENOME_LENGTHS, lengths);
00056                         new Thread (new Runnable () {
00057                                 public void run () {
00058                                         ProcessBackboneFile.startProcessor ((String) args.get (
00059                                                         ProcessBackboneFile.INPUT_FILE), args);
00060                                 }
00061                         }).start ();
00062                 } catch (Exception e) {
00063                         // TODO Auto-generated catch block
00064                         e.printStackTrace();
00065                 }
00066         }
00067         
00068         public long getContigCoord (int sequence, long loci) {
00069                 return contig_handler.getContigCoord(sequence, loci);
00070         }
00071         
00072         public String getContigName (int sequence, long loci) {
00073                 return contig_handler.getContigName(sequence, loci);
00074         }
00075         
00076         
00077 
00078         public long getPseudoCoord(int sequence, long loci, String contig) {
00079                 return contig_handler.getPseudoCoord(sequence, loci, contig);
00080         }
00081 
00082         public void fixSegmentByContigs (int sequence, Segment segment) {
00083                 Genome genome = model.getGenomeBySourceIndex (sequence);
00084                 Chromosome one = genome.getChromosomeAt (segment.left [sequence]);
00085                 Chromosome end = genome.getChromosomeAt (segment.right [sequence]);
00086                 if (one != end && SegmentDataProcessor.multiplicityForGenome (
00087                                 sequence, model.getSequenceCount ()) != segment.multiplicityType ()) {
00088                         System.out.println ("seg: " + segment);
00089                         return;
00090                 }
00091                 //System.out.println ("original: " + segment);
00092                 int part = 1;
00093                 while (one != end) {
00094                         Segment piece = new Segment (segment.left.length, true);
00095                         piece.left [sequence] = segment.left [sequence];
00096                         piece.right [sequence] = one.getEnd ();
00097                         segment.left [sequence] = one.getEnd () + 1;
00098                         piece.reverse [sequence] = segment.reverse [sequence];
00099                         if (segment.prevs [sequence] != null)
00100                                 segment.prevs [sequence].nexts [sequence] = piece;
00101                         piece.prevs [sequence] = segment.prevs [sequence];
00102                         segment.prevs [sequence] = piece;
00103                         piece.nexts [sequence] = segment;
00104                         //System.out.println ("part" + part++ + ": " + piece);
00105                         //System.out.println ("part" + part + ": " + segment);
00106                         int ref = sequence + 1;
00107                         /*while (ref != sequence) {
00108                                 if (segment.starts [ref] != 0) {
00109                                         piece.starts [ref] = segment.starts [ref];
00110                                         piece.lengths [ref] = 
00111                                 }
00112                         }*/
00113                         one = genome.getChromosomeAt (one.getEnd () + 1);
00114                 }
00115         }
00116 
00117 }

Generated on Mon Aug 19 06:03:43 2013 for Mauve by doxygen 1.3.6