-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #245 from Ferlab-Ste-Justine/feat/clin-2536
feat: CLIN-2536 normalize gnomad 4
- Loading branch information
Showing
7 changed files
with
411 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
...3/src/main/scala/bio/ferlab/datalake/spark3/publictables/normalized/gnomad/GnomadV4.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package bio.ferlab.datalake.spark3.publictables.normalized.gnomad | ||
|
||
import bio.ferlab.datalake.commons.config.{DatasetConf, RepartitionByRange, RuntimeETLContext} | ||
import bio.ferlab.datalake.spark3.etl.v4.SimpleETLP | ||
import bio.ferlab.datalake.spark3.implicits.DatasetConfImplicits._ | ||
import bio.ferlab.datalake.spark3.implicits.GenomicImplicits.columns._ | ||
import mainargs.{ParserForMethods, main} | ||
import org.apache.spark.sql.DataFrame | ||
|
||
import java.time.LocalDateTime | ||
|
||
case class GnomadV4(rc: RuntimeETLContext) extends SimpleETLP(rc) { | ||
|
||
override val mainDestination: DatasetConf = conf.getDataset("normalized_gnomad_genomes_v4") | ||
val gnomad_vcf: DatasetConf = conf.getDataset("raw_gnomad_genomes_v4") | ||
|
||
override def extract(lastRunValue: LocalDateTime = minValue, | ||
currentRunValue: LocalDateTime = LocalDateTime.now()): Map[String, DataFrame] = { | ||
Map(gnomad_vcf.id -> gnomad_vcf.read) | ||
} | ||
|
||
override def transformSingle(data: Map[String, DataFrame], | ||
lastRunValue: LocalDateTime = minValue, | ||
currentRunValue: LocalDateTime = LocalDateTime.now()): DataFrame = { | ||
import spark.implicits._ | ||
|
||
val df = data(gnomad_vcf.id) | ||
|
||
val intermediate = df | ||
.select( | ||
chromosome +: | ||
start +: | ||
end +: | ||
reference +: | ||
alternate +: | ||
$"qual" +: | ||
name +: | ||
flattenInfo(df): _* | ||
) | ||
|
||
intermediate.select( | ||
$"chromosome", | ||
$"start", | ||
$"end", | ||
$"reference", | ||
$"alternate", | ||
$"qual", | ||
$"name", | ||
$"ac".cast("long"), | ||
$"af", | ||
$"an".cast("long"), | ||
$"nhomalt".cast("long") as "hom" | ||
) | ||
} | ||
|
||
override val defaultRepartition: DataFrame => DataFrame = RepartitionByRange(columnNames = Seq("chromosome", "start"), n = Some(1000)) | ||
|
||
} | ||
|
||
object GnomadV4 { | ||
@main | ||
def run(rc: RuntimeETLContext): Unit = { | ||
GnomadV4(rc).run() | ||
} | ||
|
||
def main(args: Array[String]): Unit = ParserForMethods(this).runOrThrow(args) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.