Example #1
0
 /**
  * Create random read qualities
  *
  * @param length the length of the read
  * @param allowNs whether or not to allow N's in the read
  * @return an array with randomized bases (A-N) with equal probability
  */
 public static byte[] createRandomReadBases(int length, boolean allowNs) {
   Random random = GenomeAnalysisEngine.getRandomGenerator();
   int numberOfBases = allowNs ? 5 : 4;
   byte[] bases = new byte[length];
   for (int i = 0; i < length; i++) {
     switch (random.nextInt(numberOfBases)) {
       case 0:
         bases[i] = 'A';
         break;
       case 1:
         bases[i] = 'C';
         break;
       case 2:
         bases[i] = 'G';
         break;
       case 3:
         bases[i] = 'T';
         break;
       case 4:
         bases[i] = 'N';
         break;
       default:
         throw new ReviewedStingException("Something went wrong, this is just impossible");
     }
   }
   return bases;
 }
Example #2
0
 /**
  * Create random read qualities
  *
  * @param length the length of the read
  * @return an array with randomized base qualities between 0 and 50
  */
 public static byte[] createRandomReadQuals(int length) {
   Random random = GenomeAnalysisEngine.getRandomGenerator();
   byte[] quals = new byte[length];
   for (int i = 0; i < length; i++) quals[i] = (byte) random.nextInt(50);
   return quals;
 }