Skip to content

Commit

Permalink
Several package moves, as part of the org.bdgenomics.adam.util clea…
Browse files Browse the repository at this point in the history
…nup:

* Moved `NormalizationUtils` to `org.bdgenomics.adam.algorithms.consensus`, and
  made it package private to `consensus`.
* Moved `MdTag` to `org.bdgenomics.adam.models`.
* Moved `QualityScore` to `org.bdgenomics.adam.models` and made it package
  private to `consensus`.
  • Loading branch information
fnothaft committed Nov 6, 2016
1 parent 694dbe2 commit f148b07
Show file tree
Hide file tree
Showing 16 changed files with 44 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@
package org.bdgenomics.adam.algorithms.consensus

import org.apache.spark.rdd.RDD
import org.bdgenomics.adam.models.{ ReferencePosition, ReferenceRegion }
import org.bdgenomics.adam.models.{ MdTag, ReferencePosition, ReferenceRegion }
import org.bdgenomics.adam.rdd.read.realignment.IndelRealignmentTarget
import org.bdgenomics.adam.rich.RichAlignmentRecord._
import org.bdgenomics.adam.rich.RichCigar._
import org.bdgenomics.adam.rich.RichAlignmentRecord
import org.bdgenomics.adam.util.NormalizationUtils._
import org.bdgenomics.adam.util.MdTag
import org.bdgenomics.formats.avro.AlignmentRecord

/**
Expand Down Expand Up @@ -59,7 +57,7 @@ private[adam] class ConsensusGeneratorFromReads extends ConsensusGenerator {
// if there are two alignment blocks (sequence matches) then there is a single indel in the read
if (r.samtoolsCigar.numAlignmentBlocks == 2) {
// left align this indel and update the mdtag
val cigar = leftAlignIndel(r)
val cigar = NormalizationUtils.leftAlignIndel(r)
val mdTag = MdTag.moveAlignment(r, cigar)

val newRead: RichAlignmentRecord = AlignmentRecord.newBuilder(r)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@
package org.bdgenomics.adam.algorithms.consensus

import org.bdgenomics.adam.algorithms.smithwaterman.SmithWatermanConstantGapScoring
import org.bdgenomics.adam.models.ReferenceRegion
import org.bdgenomics.adam.models.{ MdTag, ReferenceRegion }
import org.bdgenomics.adam.rich.RichAlignmentRecord._
import org.bdgenomics.adam.rich.RichCigar._
import org.bdgenomics.adam.rich.RichAlignmentRecord
import org.bdgenomics.adam.util.MdTag
import org.bdgenomics.formats.avro.AlignmentRecord

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.bdgenomics.adam.util
package org.bdgenomics.adam.algorithms.consensus

import htsjdk.samtools.{ Cigar, CigarOperator }
import org.bdgenomics.adam.rich.RichAlignmentRecord
Expand All @@ -27,7 +27,7 @@ import scala.collection.JavaConversions._
/**
* Utility for left normalizing INDELs in alignments.
*/
private[adam] object NormalizationUtils {
private[consensus] object NormalizationUtils {

/**
* Given a cigar, returns the cigar with the position of the cigar shifted left.
Expand Down Expand Up @@ -115,7 +115,7 @@ private[adam] object NormalizationUtils {
* @param preceeding Bases of sequence to left of variant.
* @return The number of bases to shift an indel for it to be left normalized.
*/
private[util] def numberOfPositionsToShiftIndel(variant: String, preceeding: String): Int = {
private[consensus] def numberOfPositionsToShiftIndel(variant: String, preceeding: String): Int = {

// tail recursive function to determine shift
@tailrec def numberOfPositionsToShiftIndelAccumulate(variant: String, preceeding: String, accumulator: Int): Int = {
Expand All @@ -142,7 +142,7 @@ private[adam] object NormalizationUtils {
* @param shifts Number of bases to shift element.
* @return Cigar that has been shifted as far left as possible.
*/
@tailrec private[util] def shiftIndel(cigar: Cigar, position: Int, shifts: Int): Cigar = {
@tailrec private[consensus] def shiftIndel(cigar: Cigar, position: Int, shifts: Int): Cigar = {
// generate new cigar with indel shifted by one
val newCigar = new Cigar(cigar.getCigarElements).moveLeft(position)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.bdgenomics.adam.util
package org.bdgenomics.adam.models

import htsjdk.samtools.{ Cigar, CigarOperator }
import org.bdgenomics.adam.models.ReferencePosition
import org.bdgenomics.adam.rich.RichAlignmentRecord._
import org.bdgenomics.adam.rich.RichAlignmentRecord
import scala.collection.JavaConversions._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.bdgenomics.adam.util
package org.bdgenomics.adam.models

import org.bdgenomics.adam.util.PhredUtils

/**
* Model describing a single Quality score.
*
* @param phred The phred score.
*/
case class QualityScore(phred: Int) extends Ordered[QualityScore] with Serializable {
private[adam] case class QualityScore(phred: Int) extends Ordered[QualityScore] with Serializable {

// Valid range of phred + 33 is described by the regex "[!-~]".
require(phred + 33 >= '!'.toInt && phred + 33 <= '~'.toInt, "Phred %s out of range".format(phred))
Expand Down Expand Up @@ -58,7 +60,7 @@ case class QualityScore(phred: Int) extends Ordered[QualityScore] with Serializa
/**
* Companion object for building quality score objects.
*/
object QualityScore {
private[adam] object QualityScore {

/**
* The lowest quality score.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ package org.bdgenomics.adam.rdd.read

import org.bdgenomics.adam.rdd.ADAMContext._
import htsjdk.samtools.{ TextCigarCodec, ValidationStringency }
import org.bdgenomics.utils.misc.Logging
// NOTE(ryan): this is necessary for Spark <= 1.2.1.
import org.apache.spark.SparkContext._
import org.apache.spark.rdd.RDD
import org.bdgenomics.adam.models.ReferenceRegion
import org.bdgenomics.adam.util.{ ReferenceFile, MdTag }
import org.bdgenomics.adam.models.{ MdTag, ReferenceRegion }
import org.bdgenomics.adam.util.ReferenceFile
import org.bdgenomics.formats.avro.AlignmentRecord
import org.bdgenomics.utils.misc.Logging

case class MDTagging(
reads: RDD[AlignmentRecord],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ import org.apache.spark.rdd.MetricsContext._
import org.apache.spark.rdd.RDD
import org.bdgenomics.adam.algorithms.consensus.{ Consensus, ConsensusGenerator, ConsensusGeneratorFromReads }
import org.bdgenomics.adam.models.ReferenceRegion._
import org.bdgenomics.adam.models.{ ReferencePosition, ReferenceRegion }
import org.bdgenomics.adam.models.{ MdTag, ReferencePosition, ReferenceRegion }
import org.bdgenomics.adam.rich.RichAlignmentRecord
import org.bdgenomics.adam.rich.RichAlignmentRecord._
import org.bdgenomics.adam.util.MdTag
import org.bdgenomics.adam.instrumentation.Timers._
import org.bdgenomics.formats.avro.AlignmentRecord
import scala.annotation.tailrec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ import org.apache.spark.SparkContext._
import org.bdgenomics.utils.misc.Logging
import org.apache.spark.broadcast.Broadcast
import org.apache.spark.rdd.RDD
import org.bdgenomics.adam.models.SnpTable
import org.bdgenomics.adam.models.{ QualityScore, SnpTable }
import org.bdgenomics.adam.rich.DecadentRead
import org.bdgenomics.adam.rich.DecadentRead._
import org.bdgenomics.adam.util.QualityScore
import org.bdgenomics.formats.avro.AlignmentRecord

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
*/
package org.bdgenomics.adam.rdd.read.recalibration

import org.bdgenomics.adam.models.QualityScore
import org.bdgenomics.adam.rich.DecadentRead
import org.bdgenomics.adam.util.QualityScore

/**
* A Covariate represents a predictor, also known as a "feature" or
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package org.bdgenomics.adam.rdd.read.recalibration

import org.bdgenomics.adam.instrumentation.Timers._
import org.bdgenomics.adam.util.QualityScore
import org.bdgenomics.adam.models.QualityScore
import scala.collection.mutable

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
*/
package org.bdgenomics.adam.rdd.read.recalibration

import org.bdgenomics.adam.models.QualityScore
import org.bdgenomics.adam.rich.DecadentRead.Residue
import org.bdgenomics.adam.rich.RichAlignmentRecord._
import org.bdgenomics.adam.rich.DecadentRead
import org.bdgenomics.adam.util.QualityScore
import org.bdgenomics.formats.avro.AlignmentRecord
import org.bdgenomics.adam.instrumentation.Timers._
import scala.math.{ exp, log }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@ package org.bdgenomics.adam.rich
import htsjdk.samtools.ValidationStringency
import org.bdgenomics.utils.misc.Logging
import org.apache.spark.rdd.RDD
import org.bdgenomics.adam.models.ReferencePosition
import org.bdgenomics.adam.models.{
MdTag,
ReferencePosition,
ReferenceRegion,
QualityScore
}
import org.bdgenomics.adam.rdd.ADAMContext._
import org.bdgenomics.adam.rich.RichAlignmentRecord._
import org.bdgenomics.adam.util.{ MdTag, QualityScore }
import org.bdgenomics.formats.avro.AlignmentRecord

@deprecated("Use RichAlignmentRecord wherever possible in new development.", since = "0.18.0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,20 @@
*/
package org.bdgenomics.adam.rich

import htsjdk.samtools.{ Cigar, CigarElement, CigarOperator, TextCigarCodec }
import htsjdk.samtools.{
Cigar,
CigarElement,
CigarOperator,
TextCigarCodec
}
import java.util.regex.Pattern
import org.bdgenomics.adam.models.{ Attribute, ReferencePosition, ReferenceRegion }
import org.bdgenomics.adam.util._
import org.bdgenomics.adam.models.{
Attribute,
MdTag,
ReferencePosition,
ReferenceRegion
}
import org.bdgenomics.adam.util.AttributeUtils
import org.bdgenomics.formats.avro.{ AlignmentRecord, Strand }
import scala.collection.JavaConversions._
import scala.collection.immutable.NumericRange
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,10 @@ class ADAMKryoRegistrator extends KryoRegistrator {

// org.bdgenomics.adam.models
kryo.register(classOf[org.bdgenomics.adam.models.Coverage])
kryo.register(classOf[org.bdgenomics.adam.models.MdTag])
kryo.register(classOf[org.bdgenomics.adam.models.MultiContigNonoverlappingRegions])
kryo.register(classOf[org.bdgenomics.adam.models.NonoverlappingRegions])
kryo.register(classOf[org.bdgenomics.adam.models.QualityScore])
kryo.register(classOf[org.bdgenomics.adam.models.RecordGroup])
kryo.register(classOf[org.bdgenomics.adam.models.RecordGroupDictionary])
kryo.register(classOf[org.bdgenomics.adam.models.ReferencePosition],
Expand Down Expand Up @@ -172,8 +174,6 @@ class ADAMKryoRegistrator extends KryoRegistrator {
kryo.register(classOf[org.bdgenomics.adam.rich.RichVariant])

// org.bdgenomics.adam.util
kryo.register(classOf[org.bdgenomics.adam.util.MdTag])
kryo.register(classOf[org.bdgenomics.adam.util.QualityScore])
kryo.register(classOf[org.bdgenomics.adam.util.ReferenceContigMap])
kryo.register(classOf[org.bdgenomics.adam.util.TwoBitFile],
new org.bdgenomics.adam.util.TwoBitFileSerializer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.bdgenomics.adam.util
package org.bdgenomics.adam.algorithms.consensus

import htsjdk.samtools.TextCigarCodec
import org.bdgenomics.adam.rich.RichAlignmentRecord._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.bdgenomics.adam.util
package org.bdgenomics.adam.models

import htsjdk.samtools.TextCigarCodec
import org.bdgenomics.adam.rich.RichAlignmentRecord._
Expand Down

0 comments on commit f148b07

Please sign in to comment.