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

Suggestion: parallelize low complexity masking #39

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
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: 11 additions & 2 deletions scripts/mask_low_complexity.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,26 @@ if ! which $MASKER > /dev/null; then
exit 1
fi

function mask_data_chunk () {
# Removes empty records and performs masking, all in pipes
MASKER=$1
awk -v RS=">" -v FS="\n" -v ORS="" ' { if ($2) print ">"$0 } ' |\
$MASKER -in - -outfmt fasta |\
sed -e '/^>/!s/[a-z]/x/g'
}
export -f mask_data_chunk

if [ -d $target ]; then
for file in $(find $target '(' -name '*.fna' -o -name '*.faa' ')'); do
if [ ! -e "$file.masked" ]; then
$MASKER -in $file -outfmt fasta | sed -e '/^>/!s/[a-z]/x/g' > "$file.tmp"
cat $file | parallel --pipe --recstart '>' --blocksize 100M mask_data_chunk $MASKER > "$file.tmp"
mv "$file.tmp" $file
touch "$file.masked"
fi
done
elif [ -f $target ]; then
if [ ! -e "$target.masked" ]; then
$MASKER -in $target -outfmt fasta | sed -e '/^>/!s/[a-z]/x/g' > "$target.tmp"
cat $target | parallel --pipe --recstart '>' --blocksize 100M mask_data_chunk $MASKER > "$target.tmp"
mv "$target.tmp" $target
touch "$target.masked"
fi
Expand Down