Skip to content

Commit

Permalink
re-org and bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nh13 committed Aug 24, 2020
1 parent e264f32 commit 242a786
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
6 changes: 5 additions & 1 deletion src/main/scala/com/fulcrumgenomics/vcf/ValidateVcf.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import com.fulcrumgenomics.FgBioDef.{PathToVcf, SafelyClosable}
import com.fulcrumgenomics.cmdline.{ClpGroups, FgBioTool}
import com.fulcrumgenomics.commons.util.{LazyLogging, LogLevel, Logger, SimpleCounter}
import com.fulcrumgenomics.sopt.{arg, clp}
import com.fulcrumgenomics.util.Io
import com.fulcrumgenomics.util.{Io, ProgressLogger}
import com.fulcrumgenomics.vcf.api.VcfHeader._
import com.fulcrumgenomics.vcf.api._
import com.fulcrumgenomics.vcf.validation.GenotypeValidator.{PhaseSetGenotypeValidator, VariantFormatExtraFieldValidator, VariantFormatValidator}
Expand Down Expand Up @@ -93,6 +93,8 @@ class ValidateVcf
override def execute(): Unit = {
Logger.level = this.level

val progress = new ProgressLogger(logger=logger, noun="variants", verb="examined", unit=100000)

// Validate the VCF header
val reader = VcfSource(path=input, allowKindMismatch=allowTypeMismatch, allowExtraFields=allowExtraFields)
val headerValidators = VcfHeaderValidator.Validators
Expand All @@ -111,8 +113,10 @@ class ValidateVcf
case Some(n) => reader.take(n)
}
iter.foreach { variant: Variant =>
progress.record(variant=variant)
variantValidators.foreach(_.validate(variant=variant).process())
}
progress.logLast()
reader.safelyClose

// Summarize and log errors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,18 @@ object ValidationResult {
def info(message: String, variant: Option[Variant] = None, genotype: Option[Genotype] = None): ValidationResult = {
ValidationResult(variant=variant, message=message, genotype=genotype, level=LogLevel.Info)
}
def info(message: String, variant: Variant): ValidationResult = debug(message=message, variant=Some(variant))
def info(message: String, variant: Variant, genotype: Genotype): ValidationResult = debug(message=message, variant=Some(variant), genotype=Some(genotype))
def info(message: String, variant: Variant): ValidationResult = info(message=message, variant=Some(variant))
def info(message: String, variant: Variant, genotype: Genotype): ValidationResult = info(message=message, variant=Some(variant), genotype=Some(genotype))

def warning(message: String, variant: Option[Variant] = None, genotype: Option[Genotype] = None): ValidationResult = {
ValidationResult(variant=variant, message=message, genotype=genotype, level=LogLevel.Warning)
}
def warning(message: String, variant: Variant): ValidationResult = debug(message=message, variant=Some(variant))
def warning(message: String, variant: Variant, genotype: Genotype): ValidationResult = debug(message=message, variant=Some(variant), genotype=Some(genotype))
def warning(message: String, variant: Variant): ValidationResult = warning(message=message, variant=Some(variant))
def warning(message: String, variant: Variant, genotype: Genotype): ValidationResult = warning(message=message, variant=Some(variant), genotype=Some(genotype))

def error(message: String, variant: Option[Variant] = None, genotype: Option[Genotype] = None): ValidationResult = {
ValidationResult(variant=variant, message=message, genotype=genotype, level=LogLevel.Error)
}
def error(message: String, variant: Variant): ValidationResult = debug(message=message, variant=Some(variant))
def error(message: String, variant: Variant, genotype: Genotype): ValidationResult = debug(message=message, variant=Some(variant), genotype=Some(genotype))
def error(message: String, variant: Variant): ValidationResult = error(message=message, variant=Some(variant))
def error(message: String, variant: Variant, genotype: Genotype): ValidationResult = error(message=message, variant=Some(variant), genotype=Some(genotype))
}

0 comments on commit 242a786

Please sign in to comment.