Skip to content

Commit

Permalink
Merge branch 'hotfix' into hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
saramonzon authored Jan 31, 2024
2 parents e3fac57 + fb17677 commit 904f639
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
6 changes: 3 additions & 3 deletions bu_isciii/autoclean_sftp.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ def get_sftp_services(self):
# Get sftp-service last modification
service_finder = LastMofdificationFinder(sftp_service_fullPath)
service_last_modification = service_finder.find_last_modification()
self.sftp_services[
sftp_service_fullPath
] = service_last_modification
self.sftp_services[sftp_service_fullPath] = (
service_last_modification
)
if len(self.sftp_services) == 0:
sys.exit(f"No services found in {self.path}")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ do

reads_hostR1=$(cat ${arr[1]}*/kraken2/${arr[0]}.kraken2.report.txt | grep -v 'unclassified' | cut -f3 | awk '{s+=$1}END{print s}')
reads_host_x2=$(echo $((reads_hostR1 * 2)) )
perc_mapped=$(echo $(awk -v v1=$total_reads -v v2=$reads_host_x2 'BEGIN {print (v2*100)/v1}') )
perc_host=$(echo $(awk -v v1=$total_reads -v v2=$reads_host_x2 'BEGIN {print (v2*100)/v1}') )

reads_virus=$(cat ${arr[1]}*/variants/bowtie2/samtools_stats/${arr[0]}.sorted.bam.flagstat | grep '+ 0 mapped' | cut -d ' ' -f1)

unmapped_reads=$(echo $((total_reads - (reads_host_x2+reads_virus))) )
perc_unmapped=$(echo $(awk -v v1=$total_reads -v v2=$unmapped_reads 'BEGIN {print (v2/v1)*100}') )

n_count=$(cat %Ns.tab | grep -w ${arr[0]} | grep ${arr[1]} | cut -f2)
ns_10x_perc=$(cat %Ns.tab | grep -w ${arr[0]} | grep ${arr[1]} | cut -f2)

missense=$(LC_ALL=C awk -F, '{if($10 >= 0.75)print $0}' ${arr[1]}*/variants/ivar/variants_long_table.csv | grep ^${arr[0]}, | grep 'missense' | wc -l)

Ns_10x_perc=$(zcat ${arr[1]}*/variants/ivar/consensus/bcftools/${arr[0]}.filtered.vcf.gz | grep -v '^#' | wc -l)
vars_in_cons10x=$(zcat ${arr[1]}*/variants/ivar/consensus/bcftools/${arr[0]}.filtered.vcf.gz | grep -v '^#' | wc -l)

lineage=$(cat ${arr[1]}*/variants/ivar/consensus/bcftools/pangolin/${arr[0]}.pangolin.csv | tail -n1 | cut -d ',' -f2)

Expand All @@ -47,5 +47,5 @@ do
analysis_date=$(date '+%Y%m%d')

# Introduce data row into output file
echo -e "${RUN}\t${USER}\t${HOST}\t${arr[1]}\t${arr[0]}\t$total_reads\t$reads_hostR1\t$reads_host_x2\t$perc_mapped\t$reads_virus\t$reads_virus_perc\t$unmapped_reads\t$perc_unmapped\t$medianDPcov\t$cov10x\t$Ns_10x_perc\t$missense\t$n_count\t$lineage\t$read_length\t$analysis_date" >> mapping_illumina_$(date '+%Y%m%d').tab
echo -e "${RUN}\t${USER}\t${HOST}\t${arr[1]}\t${arr[0]}\t$total_reads\t$reads_hostR1\t$reads_host_x2\t$perc_host\t$reads_virus\t$reads_virus_perc\t$unmapped_reads\t$perc_unmapped\t$medianDPcov\t$cov10x\t$vars_in_cons10x\t$missense\t$ns_10x_perc\t$lineage\t$read_length\t$analysis_date" >> mapping_illumina_$(date '+%Y%m%d').tab
done
3 changes: 2 additions & 1 deletion bu_isciii/templates/viralrecon/RESULTS/excel_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def excel_generator(csv_files: List[str]):
table["analysis_date"] = pd.to_datetime(
table["analysis_date"].astype(str), format="%Y%m%d"
)
elif "assembly" in str(file) or "tsv" in str(file) or "tab" in str(file):
elif "assembly" in str(file) or ".tsv" in str(file) or ".tab" in str(file):
table = pd.read_csv(file, sep="\t", header=0)
else:
try:
Expand Down Expand Up @@ -163,6 +163,7 @@ def main(args):
)
except FileNotFoundError as e:
print("Not variants_long_table found for ", str(e))

# Create excel files for individual tables
valid_extensions = [".csv", ".tsv", ".tab"]
rest_of_csvs = [
Expand Down

0 comments on commit 904f639

Please sign in to comment.