Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

host_map counts unmapped only if both mates unmapped #291

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions pathdiscov/host_map/bwa_filter_host.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ db=$5 # database
paired=$6 # paired - 1 if paired data, 0 if not
wellpaired=$7 # wellpaired - 1 if paired data "well-paired" (i.e., mate files have exact same IDs), 0 if not
opts=$8 # options

droppair=1
if ! cd ${outputdir}; then

echo "[error] changing directories";
Expand Down Expand Up @@ -46,10 +46,17 @@ else

echo "[stats] paired stats"
samtools flagstat paired.bam

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment above each of the commands
# Extracts unmapped read names as well as their mate
# Extracts unmapped reads, leaving unpaired mates

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

if [ "$droppair" == 1 ]; then
samtools view paired.bam -f 12 | cut -f1 | sort -u | awk '{print "@"$0}' > paired.unmap.id
else
#could maybe use samtools view paired.bam -f 4 . . . instead
cat paired.sam | awk '$3=="*"' | cut -f1 | sort -u | awk '{print "@"$0}' > paired.unmap.id
fi


# get unmapped read IDs
cat paired.sam | awk '$3=="*"' | cut -f1 | sort -u | awk '{print "@"$0}' > paired.unmap.id
rm paired.sam
# get unmapped read IDs

# extract the 4 line chunks from a fastq file, given in argument 1 file, for IDs give in argument 2 file
cmd="fastq_extract_id.pl ${r1} paired.unmap.id > R1.unmap.fastq"
Expand Down