Merge branch 'develop' into update_212_Dec_merge_with_21125_chamges
[jalview.git] / test / jalview / analysis / AlignmentGenerator.java
index 9d3877c..f7d7e2b 100644 (file)
  */
 package jalview.analysis;
 
-import jalview.datamodel.Alignment;
-import jalview.datamodel.AlignmentI;
-import jalview.datamodel.Sequence;
-import jalview.datamodel.SequenceI;
-import jalview.gui.JvOptionPane;
-import jalview.io.FastaFile;
+import java.util.Locale;
 
 import java.io.File;
 import java.io.FileNotFoundException;
@@ -33,14 +28,19 @@ import java.io.PrintStream;
 import java.util.Arrays;
 import java.util.Random;
 
-import org.testng.annotations.BeforeClass;
+import jalview.datamodel.Alignment;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.Sequence;
+import jalview.datamodel.SequenceI;
+import jalview.io.FastaFile;
 
 /**
- * Generates, and outputs in Fasta format, a random peptide or nucleotide alignment for given
- * sequence length and count. Will regenerate the same alignment each time if
- * the same random seed is used (so may be used for reproducible unit tests).
- * Not guaranteed to reproduce the same results between versions, as the rules
- * may get tweaked to produce more 'realistic' results.
+ * Generates, and outputs in Fasta format, a random peptide or nucleotide
+ * alignment for given sequence length and count. Will regenerate the same
+ * alignment each time if the same random seed is used (so may be used for
+ * reproducible unit tests). Not guaranteed to reproduce the same results
+ * between versions, as the rules may get tweaked to produce more 'realistic'
+ * results.
  * 
  * @author gmcarstairs
  */
@@ -91,17 +91,16 @@ public class AlignmentGenerator
       ps = new PrintStream(new File(args[6]));
     }
 
-    boolean nucleotide = args[0].toLowerCase().startsWith("n");
+    boolean nucleotide = args[0].toLowerCase(Locale.ROOT).startsWith("n");
     int width = Integer.parseInt(args[1]);
     int height = Integer.parseInt(args[2]);
     long randomSeed = Long.valueOf(args[3]);
     int gapPercentage = Integer.valueOf(args[4]);
     int changePercentage = Integer.valueOf(args[5]);
 
-    ps.println("; " + height + " sequences of " + width
-            + " bases with " + gapPercentage + "% gaps and "
-            + changePercentage + "% mutations (random seed = " + randomSeed
-            + ")");
+    ps.println("; " + height + " sequences of " + width + " bases with "
+            + gapPercentage + "% gaps and " + changePercentage
+            + "% mutations (random seed = " + randomSeed + ")");
 
     new AlignmentGenerator(nucleotide, ps).generate(width, height,
             randomSeed, gapPercentage, changePercentage);
@@ -121,16 +120,16 @@ public class AlignmentGenerator
     System.out.println("arg0: n (for nucleotide) or p (for peptide)");
     System.out.println("arg1: number of (non-gap) bases per sequence");
     System.out.println("arg2: number of sequences");
-    System.out
-            .println("arg3: an integer as random seed (same seed = same results)");
+    System.out.println(
+            "arg3: an integer as random seed (same seed = same results)");
     System.out.println("arg4: percentage of gaps to (randomly) generate");
-    System.out
-            .println("arg5: percentage of 'mutations' to (randomly) generate");
-    System.out
-            .println("arg6: (optional) path to output file (default is sysout)");
+    System.out.println(
+            "arg5: percentage of 'mutations' to (randomly) generate");
+    System.out.println(
+            "arg6: (optional) path to output file (default is sysout)");
     System.out.println("Example: AlignmentGenerator n 12 15 387 10 5");
-    System.out
-            .println("- 15 nucleotide sequences of 12 bases each, approx 10% gaps and 5% mutations, random seed = 387");
+    System.out.println(
+            "- 15 nucleotide sequences of 12 bases each, approx 10% gaps and 5% mutations, random seed = 387");
 
   }
 
@@ -203,8 +202,8 @@ public class AlignmentGenerator
     for (int count = 0; count < length;)
     {
       boolean addGap = random.nextInt(100) < gapPercentage;
-      char c = addGap ? GAP : BASES[random.nextInt(Integer.MAX_VALUE)
-              % BASES.length];
+      char c = addGap ? GAP
+              : BASES[random.nextInt(Integer.MAX_VALUE) % BASES.length];
       seq.append(c);
       if (!addGap)
       {
@@ -228,8 +227,8 @@ public class AlignmentGenerator
    * @param changePercentage
    * @return
    */
-  private SequenceI generateAnotherSequence(char[] ds, int seqno,
-          int width, int changePercentage)
+  private SequenceI generateAnotherSequence(char[] ds, int seqno, int width,
+          int changePercentage)
   {
     int length = ds.length;
     char[] seq = new char[length];