src/org/gel/mauve/LCB.java

Go to the documentation of this file.
00001 package org.gel.mauve;
00002 
00003 import java.awt.Color;
00004 
00005 import java.io.Serializable;
00006 import java.util.Arrays;
00007 import java.util.Comparator;
00008 
00009 import org.gel.mauve.analysis.Segment;
00010 
00015 public class LCB extends Segment {
00016 
00020         private int [] left_adjacency;
00021 
00025         private int [] right_adjacency;
00026 
00030         public int id;
00031 
00035         public long weight;
00036 
00040         public Color color;
00041 
00045         public Color match_color;
00046 
00050         boolean keep;
00051 
00052         public LCB (int seq_count) {
00053                 left = new long [seq_count];
00054                 right = new long [seq_count];
00055                 reverse = new boolean [seq_count];
00056                 left_adjacency = new int [seq_count];
00057                 right_adjacency = new int [seq_count];
00058         }
00059 
00060         public LCB (Match m, int id, int seq_count) {
00061                 left = new long [seq_count];
00062                 right = new long [seq_count];
00063                 reverse = new boolean [seq_count];
00064                 left_adjacency = new int [seq_count];
00065                 right_adjacency = new int [seq_count];
00066                 this.id = id;
00067 
00068                 m.copyArrays (this, left, right, reverse, seq_count);
00069 
00070                 // set weight to average lcb length for now...
00071                 long len_sum = 0;
00072                 for (int seqI = 0; seqI < seq_count; seqI++) {
00073                         len_sum += right[seqI] - left[seqI];
00074                 }
00075                 weight = len_sum / seq_count;
00076                 keep = false;
00077         }
00078 
00079         public LCB (LCB l) {
00080                 int seq_count = l.left.length;
00081                 left = new long [seq_count];
00082                 right = new long [seq_count];
00083                 left_adjacency = new int [seq_count];
00084                 right_adjacency = new int [seq_count];
00085                 reverse = new boolean [seq_count];
00086                 id = l.id;
00087                 weight = l.weight;
00088                 color = l.color;
00089                 match_color = l.match_color;
00090                 keep = l.keep;
00091 
00092                 System.arraycopy (l.left, 0, left, 0, seq_count);
00093                 System.arraycopy (l.right, 0, right, 0, seq_count);
00094                 System.arraycopy (l.left_adjacency, 0, left_adjacency, 0, seq_count);
00095                 System.arraycopy (l.right_adjacency, 0, right_adjacency, 0, seq_count);
00096                 System.arraycopy (l.reverse, 0, reverse, 0, seq_count);
00097         }
00098 
00099         public long midpoint (Genome g) {
00100                 return (right[g.getSourceIndex ()] + left[g.getSourceIndex ()]) / 2;
00101         }
00102 
00103         public void setReference (Genome g) {
00104                 if (getReverse (g)) {
00105                         for (int seqI = 0; seqI < reverse.length; seqI++) {
00106                                 Genome g2 = g.getModel ().getGenomeBySourceIndex (seqI);
00107                                 setReverse (g2, !getReverse (g2));
00108                         }
00109                 }
00110         }
00111 
00112         public long getLength (Genome g) {
00113                 return right[g.getSourceIndex ()] - left[g.getSourceIndex ()];
00114         }
00115 
00116         public long getLeftEnd (Genome g) {
00117                 return left[g.getSourceIndex ()];
00118         }
00119 
00120         public void setLeftEnd (Genome g, long leftEnd) {
00121                 left[g.getSourceIndex ()] = leftEnd;
00122         }
00123 
00124         public long getRightEnd (Genome g) {
00125                 return right[g.getSourceIndex ()];
00126         }
00127 
00128         public void setRightEnd (Genome g, long rightEnd) {
00129                 right[g.getSourceIndex ()] = rightEnd;
00130         }
00131 
00132         public boolean getReverse (Genome g) {
00133                 return reverse[g.getSourceIndex ()];
00134         }
00135 
00136         public void setReverse (Genome g, boolean r) {
00137                 reverse[g.getSourceIndex ()] = r;
00138         }
00139 
00140         public int getLeftAdjacency (Genome g) {
00141                 return left_adjacency[g.getSourceIndex ()];
00142         }
00143 
00144         public void setLeftAdjacency (Genome g, int lcbID) {
00145                 left_adjacency[g.getSourceIndex ()] = lcbID;
00146         }
00147 
00148         public int getRightAdjacency (Genome g) {
00149                 return right_adjacency[g.getSourceIndex ()];
00150         }
00151 
00152         public void setRightAdjacency (Genome g, int lcbID) {
00153                 right_adjacency[g.getSourceIndex ()] = lcbID;
00154         }
00155 
00156         public void resetAdjacencies (int genomeCount) {
00157                 Arrays.fill (left_adjacency, 0);
00158                 Arrays.fill (right_adjacency, 0);
00159         }
00160 
00161         public int multiplicity () {
00162                 int mult = 0;
00163                 for (int i = 0; i < left.length; ++i) {
00164                         if (left[i] != 0)
00165                                 mult++;
00166                 }
00167                 return mult;
00168         }
00169         
00170 
00171         
00172 }

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