Unverified Commit f41ded0c authored by Muhammad Saad Shamim's avatar Muhammad Saad Shamim Committed by GitHub
Browse files

Merge branch 'encode' into master

parents 2afef51e 4ff5fc44
Loading
Loading
Loading
Loading
+2 −2
Changes for AWS/scripts/check.sh: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -41,8 +41,8 @@ fi
# no reads were lost
total=1
total2=0
total=`ls -l ${outputdir}/merged_sort.txt | awk '{print $5}'`
total2=`ls -l ${outputdir}/merged_nodups.txt ${outputdir}/dups.txt ${outputdir}/opt_dups.txt | awk '{sum = sum + $5}END{print sum}'`
total=`ls -lgG ${outputdir}/merged_sort.txt | awk '{print $3}'`
total2=`ls -lgG ${outputdir}/merged_nodups.txt ${outputdir}/dups.txt ${outputdir}/opt_dups.txt | awk '{sum = sum + $3}END{print sum}'`

if [ -z $total ] || [ -z $total2 ] || [ $total -ne $total2 ]
then
+2 −2
Changes for AWS/scripts/cleanup.sh: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -25,8 +25,8 @@
# Script to clean up big repetitive files and zip fastqs. Run after you are 
# sure the pipeline ran successfully.  Run from top directory (HIC001 e.g.).
# Juicer version 1.5
total=`ls -l aligned/merged_sort.txt | awk '{print $5}'`
total2=`ls -l aligned/merged_nodups.txt aligned/dups.txt aligned/opt_dups.txt | awk '{sum = sum + $5}END{print sum}'`
total=`ls -lgG aligned/merged_sort.txt | awk '{print $3}'`
total2=`ls -lgG aligned/merged_nodups.txt aligned/dups.txt aligned/opt_dups.txt | awk '{sum = sum + $3}END{print sum}'`
if [ $total -eq $total2 ] 
then 
    rm aligned/merged_sort.txt 
+3 −3
Changes for AWS/scripts/juicer.sh: 3 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -351,14 +351,14 @@ fi
# If chunk size sent in, split. Otherwise check size before splitting
if [ -z $splitme ]
then
    fastqsize=`ls -lL ${fastqdir} | awk '{sum+=$5}END{print sum}'`
    fastqsize=`ls -lgGL ${fastqdir} | awk '{sum+=$3}END{print sum}'`
    if [ "$fastqsize" -gt "2592410750" ]
    then
	splitme=1
    fi
fi

testname=`ls -l ${fastqdir} | awk 'NR==1{print $9}'`
testname=`ls -lgG ${fastqdir} | awk 'NR==1{print $7}'`
if [ ${testname: -3} == ".gz" ]
then
    read1=${splitdir}"/*${read1str}*.fastq.gz"
@@ -500,7 +500,7 @@ SPLITMV
        ## No need to re-split fastqs if they already exist
        echo -e "---  Using already created files in $splitdir\n"
        # unzipped files will have .fastq extension, softlinked gz 
        testname=$(ls -l ${splitdir} | awk '$9~/fastq$/||$9~/gz$/{print $9; exit}')
        testname=$(ls -lgG ${splitdir} | awk '$7~/fastq$/||$7~/gz$/{print $7; exit}')
        if [ ${testname: -3} == ".gz" ]
        then
            read1=${splitdir}"/*${read1str}*.fastq.gz"
+167 −0
Changes for CPU/common/adjust_insert_size.awk: 167 added lines, 0 removed lines.
Original line number Diff line number Diff line
#!/usr/bin/awk -f

# returns absolute value
function abs(value)
{
  return (value<0?-value:value);
}
BEGIN{
  while(getline<avgInsertFile>0) {
    insertsize=$7
  }
  saved="";
  OFS="\t";
}
{
    if ($(NF-1) ~ /^rt:/ && ($(NF-1) ~ /:0$/ || $(NF-1) ~ /:1$/)) {
	# first appearance, process second one
	if (length(saved)==0) {
	    saved=$0;
	    saved_length=length($10);
	    next;
	}
	else {
	    split($NF, cb_str, ":");
	    split(cb_str[3], cb, "_");
	    strand1=cb[5];
	    strand2=cb[6];

	    for (i=12; i<=NF; i++) {
		if ($i ~ /^ip/) {
		    split($i, ip, ":");
		}
		else if ($i ~ /^mp/) {
		    split($i, mp, ":");
		}
	    }

	    is = insertsize - length($10) - saved_length;

	    split($(NF-1), rt, ":");
	    if (rt[3]==0) {
		cigar1=$6;
		split(saved, prev);
		cigar2=prev[6];
		pos1=ip[3];
		pos2=mp[3];
	    }
	    else {
		cigar2=$6;
		split(saved, prev);
		cigar1=prev[6];
		pos1=mp[3];
		pos2=ip[3];
	    }
	    cigloc1=0;
	    cigloc2=0;
	    newpos1=pos1;
	    newpos2=pos2;
	    if (strand1==0) {
		if (cigar1 ~ /[0-9]+S$/) {
		    where = match(cigar1,/[0-9]+S$/);
		    cigloc1 = cigloc1 + (substr(cigar1,where,RLENGTH-1) + 0);
		}
		else if (cigar1 ~ /[0-9]+H$/) {
		    where = match(cigar1,/[0-9]+H$/);
		    cigloc1 = cigloc1 + (substr(cigar1,where,RLENGTH-1) + 0);
		}
	    }
	    else if (strand1==16) {
		if (cigar1 ~ /^[0-9]+S/) {
		    where = match(cigar1,/^[0-9]+S/);
		    cigloc1 = cigloc1 + (substr(cigar1,where,RLENGTH-1) + 0);
		}
		else if (cigar1 ~ /^[0-9]+H/) {
		    where = match(cigar1,/^[0-9]+H/);
		    cigloc1 = cigloc1 + (substr(cigar1,where,RLENGTH-1) + 0);
		}
	    }
	    if (strand2==0) {
		if (cigar2 ~ /[0-9]+S$/) {
		    where = match(cigar2,/[0-9]+S$/);
		    cigloc2 = cigloc2 + (substr(cigar2,where,RLENGTH-1) + 0);
		}
		else if (cigar2 ~ /[0-9]+H$/) {
		    where = match(cigar2,/[0-9]+H$/);
		    cigloc2 = cigloc2 + (substr(cigar2,where,RLENGTH-1) + 0);
		}
	    }
	    else if (strand2==16) {
		if (cigar2 ~ /^[0-9]+S/) {
		    where = match(cigar2,/^[0-9]+S/);
		    cigloc2 = cigloc2 + (substr(cigar2,where,RLENGTH-1) + 0);
		}
		else if (cigar2 ~ /^[0-9]+H/) {
		    where = match(cigar2,/^[0-9]+H/);
		    cigloc2 = cigloc2 + (substr(cigar1,where,RLENGTH-1) + 0);
		}
	    }
	    if (cigloc1==0 && cigloc2==0) {
		if (strand1==0) {
		    newpos1 += int(is/2);
		}
		else if (strand1==16) {
		    newpos1 -= int(is/2);
		}
		if (strand2 ==0) {
		    newpos2 += int(is/2);
		}
		else if (strand2 == 16) {
		    newpos2 -= int(is/2);
		}
	    }
	    else if (cigloc1>0&&cigloc2==0) {
		if (strand2==0) {
		    newpos2 = newpos2 + int(is) + cigloc1;
		}
		else if (strand2==16) {
		    newpos2 = newpos2 - int(is) - cigloc1;
		}
	    }
	    else if (cigloc1==0&&cigloc2>0) {
		if (strand1==0) { 
		    newpos1 = newpos1 + int(is) + cigloc2;
		}
		else if (strand1==16) {
		    newpos1 = newpos1 - int(is) - cigloc2;
		}
	    }

	    if (rt[3]==0) {
		p1 = newpos1;
		p2 = newpos2;
	    }
	    else {
		p1 = newpos2;
		p2 = newpos1;
	    }
	    for (i=12; i<=NF; i++) {
		if ($i ~ /^ip/) {
		    $i = "ip:i:"p1;
		}
		else if ($i ~ /^mp/) {
		    $i = "mp:i:"p2;
		}
	    }
		
	    str=prev[1];
	    for (j=2; j<=length(prev); j++) {
		if (prev[j] ~ /^ip/) {
		    prev[j] = "ip:i:"p2;
		}
		else if (prev[j] ~ /^mp/) {
		    prev[j] = "mp:i:"p1;
		}
		str=str"\t"prev[j];
	    }
	    
	    print str;
	    print;
	    saved="";
	}
    }
    # otherwise, not adjusting the insert size, just print (also header, collisions, etc)
    else {
	print;
    }
}
+3 −15
Changes for CPU/common/check.sh: 3 added lines, 15 removed lines.
Original line number Diff line number Diff line
@@ -25,11 +25,11 @@
#
# Sanity check once pipeline is complete to be sure number of lines adds up, deduping
# proceeded appropriately, and that files were created
# Juicer version 1.5
# Juicer version 2.0

# Start by checking the statistics to see if they add up 
res1=`cat ${splitdir}/*norm*res*`
check1=`cat ${splitdir}/*norm*res* | awk '{s2+=$2; s3+=$3; s4+=$4; s5+=$5; s6+=$6}END{if (s2 != s3+s4+s5+s6){print 0}else{print 1}}'`
check1=`cat ${splitdir}/*norm*res* | awk '{s2+=$2; s3+=$3; s4+=$4; s5+=$5; s6+=$6; s7+=$7}END{if (s2 != s3+s4+s5+s6+s7){print 0}else{print 1}}'`
if [ $check1 -eq 0 ] || [ -z "$res1" ]
then
    echo "***! Error! The statistics do not add up. Alignment likely failed to complete on one or more files. Run relaunch_prep.sh"
@@ -37,19 +37,7 @@ then
    exit 1
fi

# Check the sizes of merged_sort versus the dups/no dups files to be sure
# no reads were lost
total=1
total2=0
total=`ls -l ${outputdir}/merged_sort.txt | awk '{print $5}'`
total2=`ls -l ${outputdir}/merged_nodups.txt ${outputdir}/dups.txt ${outputdir}/opt_dups.txt | awk '{sum = sum + $5}END{print sum}'`

if [ -z $total ] || [ -z $total2 ] || [ $total -ne $total2 ]
then
    echo "***! Error! The sorted file and dups/no dups files do not add up, or were empty. Merge or dedupping likely failed, restart pipeline with -S merge or -S dedup"
    echo "Dups don't add up.  Check ${outputdir} for results"
    exit 1
fi
# could add flagstat check here

wctotal=`cat ${splitdir}/*_linecount.txt | awk '{sum+=$1}END{print sum/4}'`
check2=`cat ${splitdir}/*norm*res* | awk '{s2+=$2;}END{print s2}'`
Loading