diff --git a/uk/ac/sanger/artemis/plot/AGWindowAlgorithm.java b/uk/ac/sanger/artemis/plot/AGWindowAlgorithm.java index a900194fb7be4c8ca115c9d2c98f8d65d02a3b70..98d6d99a0b71ed729895a63887cb66de516d654a 100644 --- a/uk/ac/sanger/artemis/plot/AGWindowAlgorithm.java +++ b/uk/ac/sanger/artemis/plot/AGWindowAlgorithm.java @@ -20,7 +20,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - * $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/plot/AGWindowAlgorithm.java,v 1.3 2009-03-13 20:39:37 tjc Exp $ + * $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/plot/AGWindowAlgorithm.java,v 1.4 2009-03-17 17:47:42 tjc Exp $ */ package uk.ac.sanger.artemis.plot; @@ -37,7 +37,7 @@ import uk.ac.sanger.artemis.sequence.*; * constructor. * * @author Kim Rutherford - * @version $Id: AGWindowAlgorithm.java,v 1.3 2009-03-13 20:39:37 tjc Exp $ + * @version $Id: AGWindowAlgorithm.java,v 1.4 2009-03-17 17:47:42 tjc Exp $ **/ public class AGWindowAlgorithm extends BaseAlgorithm { @@ -59,18 +59,18 @@ public class AGWindowAlgorithm extends BaseAlgorithm { * this array. **/ public void getValues (int start, int end, final float [] values) { - final char[] sequence; + final String sequence; try { - sequence = getStrand ().getBases().getSubSequenceC (new Range (start, end), getStrand().getDirection()); + sequence = getStrand ().getSubSequence (new Range (start, end)); } catch (OutOfRangeException e) { throw new Error ("internal error - unexpected exception: " + e); } float gc_count = 0; - for (int i = 0 ; i < sequence.length ; ++i) { - final char this_char = sequence[i]; + for (int i = 0 ; i < sequence.length () ; ++i) { + final char this_char = sequence.charAt (i); // System.out.println (this_char); if (this_char == 'g' || this_char == 'a') { @@ -80,7 +80,7 @@ public class AGWindowAlgorithm extends BaseAlgorithm { // System.out.println ("start: " + start + " end: " + end + " returning: " + gc_count/sequence.length ()); - values[0] = gc_count/sequence.length * 100; + values[0] = gc_count/sequence.length () * 100; } /** diff --git a/uk/ac/sanger/artemis/plot/GCSDWindowAlgorithm.java b/uk/ac/sanger/artemis/plot/GCSDWindowAlgorithm.java index 70ae4e9bd84b8b4ac6cad11f59df65540e02272b..7b08e0d2aabf3ad13031d0d2599c6ed20d52ba17 100644 --- a/uk/ac/sanger/artemis/plot/GCSDWindowAlgorithm.java +++ b/uk/ac/sanger/artemis/plot/GCSDWindowAlgorithm.java @@ -20,7 +20,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - * $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/plot/GCSDWindowAlgorithm.java,v 1.3 2009-03-13 20:39:37 tjc Exp $ + * $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/plot/GCSDWindowAlgorithm.java,v 1.4 2009-03-17 17:47:42 tjc Exp $ */ package uk.ac.sanger.artemis.plot; @@ -39,7 +39,7 @@ import uk.ac.sanger.artemis.sequence.*; * to use is set in the constructor. * * @author Kim Rutherford - * @version $Id: GCSDWindowAlgorithm.java,v 1.3 2009-03-13 20:39:37 tjc Exp $ + * @version $Id: GCSDWindowAlgorithm.java,v 1.4 2009-03-17 17:47:42 tjc Exp $ **/ public class GCSDWindowAlgorithm extends BaseAlgorithm { @@ -82,18 +82,18 @@ public class GCSDWindowAlgorithm extends BaseAlgorithm { } } - final char[] sequence; + final String sequence; try { - sequence = getStrand ().getBases().getSubSequenceC (new Range (start, end), getStrand().getDirection()); + sequence = getStrand ().getSubSequence (new Range (start, end)); } catch (OutOfRangeException e) { throw new Error ("internal error - unexpected exception: " + e); } float gc_count = 0; - for (int i = 0 ; i < sequence.length ; ++i) { - final char this_char = sequence[i]; + for (int i = 0 ; i < sequence.length () ; ++i) { + final char this_char = sequence.charAt (i); // System.out.println (this_char); if (this_char == 'g' || this_char == 'c') { @@ -101,7 +101,7 @@ public class GCSDWindowAlgorithm extends BaseAlgorithm { } } - final float gc_content = gc_count/sequence.length * 100; + final float gc_content = gc_count/sequence.length () * 100; final float gc_average = getStrand ().getBases ().getAverageGCPercent (); @@ -122,17 +122,8 @@ public class GCSDWindowAlgorithm extends BaseAlgorithm { final int sequence_length = getStrand ().getBases ().getLength (); - //final String bases = getStrand ().getBases ().toString (); - char[] bases = null; - try - { - bases = getStrand ().getBases ().getSubSequenceC(new Range(1,sequence_length), Strand.FORWARD); - } - catch(OutOfRangeException e) - { - // TODO Auto-generated catch block - e.printStackTrace(); - } + final String bases = getStrand ().getBases ().toString (); + // the number of windows to search final int window_count = sequence_length - window_size; @@ -150,14 +141,14 @@ public class GCSDWindowAlgorithm extends BaseAlgorithm { for (int i = - window_size ; i < window_count ; ++i) { if (i > 0) { - final char previous_char = bases[i - 1]; + final char previous_char = bases.charAt (i - 1); if (previous_char == 'g' || previous_char == 'c') { --current_gc_count; } } - final char new_char = bases[i + window_size]; + final char new_char = bases.charAt (i + window_size); if (new_char == 'g' || new_char == 'c') { ++current_gc_count; diff --git a/uk/ac/sanger/artemis/plot/GCWindowAlgorithm.java b/uk/ac/sanger/artemis/plot/GCWindowAlgorithm.java index a608deab7cbb303fe5579a036e6346575e467774..a4b5bd362a74949a23d88db85bcb15c56d6939b3 100644 --- a/uk/ac/sanger/artemis/plot/GCWindowAlgorithm.java +++ b/uk/ac/sanger/artemis/plot/GCWindowAlgorithm.java @@ -20,7 +20,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - * $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/plot/GCWindowAlgorithm.java,v 1.3 2009-03-13 20:39:37 tjc Exp $ + * $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/plot/GCWindowAlgorithm.java,v 1.4 2009-03-17 17:47:42 tjc Exp $ **/ package uk.ac.sanger.artemis.plot; @@ -37,7 +37,7 @@ import uk.ac.sanger.artemis.sequence.*; * constructor. * * @author Kim Rutherford - * @version $Id: GCWindowAlgorithm.java,v 1.3 2009-03-13 20:39:37 tjc Exp $ + * @version $Id: GCWindowAlgorithm.java,v 1.4 2009-03-17 17:47:42 tjc Exp $ **/ public class GCWindowAlgorithm extends BaseAlgorithm { @@ -59,27 +59,28 @@ public class GCWindowAlgorithm extends BaseAlgorithm { * this array. **/ public void getValues (int start, int end, final float [] values) { - final char[] sequence; + final String sequence; try { - sequence = getStrand ().getBases().getSubSequenceC( - new Range (start, end), getStrand ().getDirection()); + sequence = getStrand ().getSubSequence (new Range (start, end)); } catch (OutOfRangeException e) { throw new Error ("internal error - unexpected exception: " + e); } float gc_count = 0; - final int sequence_length = sequence.length; - for (int i = 0 ; i < sequence_length ; ++i) - { - if (sequence[i] == 'g' || sequence[i] == 'c') + for (int i = 0 ; i < sequence.length () ; ++i) { + final char this_char = sequence.charAt (i); +// System.out.println (this_char); + + if (this_char == 'g' || this_char == 'c') { ++gc_count; + } } // System.out.println ("start: " + start + " end: " + end + " returning: " + gc_count/sequence.length ()); - values[0] = gc_count/sequence_length * 100; + values[0] = gc_count/sequence.length () * 100; } /**