File Info

Filename
.command.sh
Full Path
s3://natera-rnd-pltf-dev-nextflow-scratch-01/work/32/654858626fd2257604b9c482e7ea9c/.command.sh
Size
619 bytes
Attempt
#!/bin/bash -Ceuo pipefail
samtools idxstats HCC1395_BL.recalibrated.bam > idxstats.txt

x_map=$(grep -E "^chrX\s|^X\s" idxstats.txt | cut -f 3)
x_len=$(grep -E "^chrX\s|^X\s" idxstats.txt | cut -f 2)
y_map=$(grep -E "^chrY\s|^Y\s" idxstats.txt | cut -f 3)
y_len=$(grep -E "^chrY\s|^Y\s" idxstats.txt | cut -f 2)

awk -v xm="$x_map" -v xl="$x_len" -v ym="$y_map" -v yl="$y_len" '
BEGIN {
    if (ym == 0 || yl == 0) {
        print "XX"
    } else {
        x_cov = xm / xl
        y_cov = ym / yl
        ratio = x_cov / y_cov
        if (ratio > 50.0) print "XX"
        else print "XY"
    }
}' > HCC1395_BL.sex.txt