コード例 #1
0
 /**
  * Return the error probabilities from the specified FASTQ formatted sequence.
  *
  * @param fastq FASTQ formatted sequence, must not be null
  * @return the error probabilities from the specified FASTQ formatted sequence
  */
 public static Iterable<Number> errorProbabilities(final Fastq fastq) {
   if (fastq == null) {
     throw new IllegalArgumentException("fastq must not be null");
   }
   int size = fastq.getQuality().length();
   List<Number> errorProbabilities = Lists.newArrayListWithExpectedSize(size);
   FastqVariant variant = fastq.getVariant();
   for (int i = 0; i < size; i++) {
     char c = fastq.getQuality().charAt(i);
     errorProbabilities.add(variant.errorProbability(c));
   }
   return ImmutableList.copyOf(errorProbabilities);
 }
コード例 #2
0
 /**
  * Copy the error probabilities from the specified FASTQ formatted sequence into the specified
  * double array.
  *
  * @param fastq FASTQ formatted sequence, must not be null
  * @param errorProbabilities double array of error probabilities, must not be null and must be the
  *     same length as the FASTQ formatted sequence quality
  * @return the specified double array of error probabilities
  */
 public static double[] errorProbabilities(final Fastq fastq, final double[] errorProbabilities) {
   if (fastq == null) {
     throw new IllegalArgumentException("fastq must not be null");
   }
   if (errorProbabilities == null) {
     throw new IllegalArgumentException("errorProbabilities must not be null");
   }
   int size = fastq.getQuality().length();
   if (errorProbabilities.length != size) {
     throw new IllegalArgumentException(
         "errorProbabilities must be the same length as the FASTQ formatted sequence quality");
   }
   FastqVariant variant = fastq.getVariant();
   for (int i = 0; i < size; i++) {
     char c = fastq.getQuality().charAt(i);
     errorProbabilities[i] = variant.errorProbability(c);
   }
   return errorProbabilities;
 }