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