src/org/gel/mauve/summary/output/IslandFeatureWriter.java

Go to the documentation of this file.
00001 package org.gel.mauve.summary.output;
00002 
00003 import java.util.Hashtable;
00004 import java.util.Vector;
00005 
00006 import org.gel.air.util.GroupHelpers;
00007 import org.gel.mauve.MauveConstants;
00008 import org.gel.mauve.MauveHelperFunctions;
00009 import org.gel.mauve.analysis.Segment;
00010 import org.gel.mauve.gui.sequence.FlatFileFeatureConstants;
00011 
00012 public class IslandFeatureWriter extends AbstractIslandWriter implements
00013                 MauveConstants, FlatFileFeatureConstants {
00014 
00015         public static final int MULTIPLICITY_INDEX = 6;
00016         public static final String ISLAND = "island";
00017 
00018         protected IslandFeatureWriter (SegmentDataProcessor processor) {
00019                 super (MauveHelperFunctions.getSeqPartOfFile (processor) + "islands", processor);
00020         }
00021         
00022         protected IslandFeatureWriter (String file, SegmentDataProcessor processor) {
00023                 super (file, processor);
00024         }
00025 
00026         protected void initSubClassParticulars (Hashtable args) {
00027                 seq_index = ((Integer) args.get (SEQUENCE_INDEX)).intValue ();
00028                 super.initSubClassParticulars (args);
00029         }
00030 
00031         public void printIslands () {
00032                 printHeaders ();
00033                 printData (BY_ONE_GENOME);
00034         }
00035 
00036         protected String getData (int column, int row) {
00037                 long value = 0;
00038                 switch (column) {
00039                         case TYPE:
00040                                 return ISLAND;
00041                         case LABEL:
00042                                 return current.typed_id;
00043                         case CONTIG:
00044                                 return contig_handler.getContigName (seq_index, current.left [seq_index]);
00045                         case STRAND:
00046                                 return current.reverse [seq_index] ? COMPLEMENT : FORWARD;
00047                         case LEFT:
00048                                 value = current.left [seq_index];
00049                                 break;
00050                         case RIGHT:
00051                                 value = current.right [seq_index];
00052                                 break;
00053                         case MULTIPLICITY_INDEX:
00054                                 return MauveHelperFunctions.getReadableMultiplicity (current);
00055                         default:
00056                                 return null;
00057                 }
00058                 return adjustForContigs (seq_index, value) + "";
00059         }
00060 
00061         public Vector setColumnHeaders () {
00062                 String [] cols = new String [] {TYPE_STRING, LABEL_STRING,
00063                                 CONTIG_STRING, STRAND_STRING, LEFT_STRING, RIGHT_STRING,
00064                                 Segment.MULTIPLICITY_STRING};
00065                 Vector vect = new Vector ();
00066                 GroupHelpers.arrayToCollection (vect, cols);
00067                 return vect;
00068         }
00069 
00070         public static void printIslandsAsFeatures (SegmentDataProcessor processor) {
00071                 int count = ((Object []) processor.get (FIRSTS)).length;
00072                 for (int i = 0; i < count; i++) {
00073                         processor.put (SEQUENCE_INDEX, new Integer (i));
00074                         new IslandFeatureWriter (processor);
00075                 }
00076         }
00077 
00078         public boolean shouldPrintRow (int row) {
00079                 long cur = current.multiplicityType ();
00080                 return (cur & multiplicity) == multiplicity && cur != all_seq_multiplicity &&
00081                                 current.getSegmentLength (seq_index) > island_min;
00082         }
00083 
00084 }

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