Skip to content

Commit

Permalink
update regex pattern for diff check
Browse files Browse the repository at this point in the history
  • Loading branch information
dweber2022 committed Aug 14, 2024
1 parent f0b1eb1 commit e0ab899
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tests/check_intermediate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ for path_to_cif in Resources/KnownCIFs/*.cif; do
echo -e "${GREEN}CHECKING${NC} $cif..."
output_path="Output/$cif"
known_path="Resources/KnownCIFs/Outputs/$cif"
# In order, a-zA-Z# -> a-zA-Z, NODE# -> "", Lines with # -> "", # -> 1 decimal place
pattern="s/([a-zA-Z]+)[0-9]+/\1/g; s/NODE [0-9]+/NODE/g; s/^[ \t]*#.*//g; s/([0-9]+)(.[0-9])?[0-9]+/\1\2/g"
# In order, a-zA-Z# -> a-zA-Z, NODE# -> "", Lines with # -> "", # -> 1 decimal place, #_#+ -> "", condense whitespace
pattern="s/([a-zA-Z]+)[0-9]+/\1/g; s/NODE [0-9]+/NODE/g; s/^[ \t]*#.*//g; s/([0-9]+)(.[0-9])?[0-9]+/\1\2/g; s/[0-9]_[0-9]+//g; s/[ \t]+/\t/g"
# Check orig_mol.cif
diff -b <(sed -E "$pattern" $known_path/orig_mol.cif | sort) <(sed -E "$pattern" $output_path/orig_mol.cif | sort) > /dev/null
diff -yw <(sed -E "$pattern" $known_path/orig_mol.cif | sort) <(sed -E "$pattern" $output_path/orig_mol.cif | sort) > /dev/null
if [[ $? -ne 0 ]]; then
echo -e "${RED}WARNING:${NC} orig_mol.cif is different"
diff -yb --suppress-common-lines <(sed -E "$pattern" $known_path/orig_mol.cif | sort) <(sed -E "$pattern" $output_path/orig_mol.cif | sort) | colordiff
diff -yw --suppress-common-lines <(sed -E "$pattern" $known_path/orig_mol.cif | sort) <(sed -E "$pattern" $output_path/orig_mol.cif | sort) | colordiff
mkdir -p Mismatch/$cif/
cp -u Output/$cif/orig_mol.cif Mismatch/$cif/orig_mol.cif
fi
Expand All @@ -44,15 +44,15 @@ for path_to_cif in Resources/KnownCIFs/*.cif; do
# Currently only checks CIF files
for path_to_file in $path_to_dir/*.cif; do
file="$(basename $path_to_file)"
diff -b <(sed -E "$pattern" $path_to_file | sort) <(sed -E "$pattern" $output_path/$dir/$file | sort) > /dev/null
diff -yw <(sed -E "$pattern" $path_to_file | sort) <(sed -E "$pattern" $output_path/$dir/$file | sort) > /dev/null
exit_code="$?"
if [[ $exit_code -ne 0 ]]; then
echo -e "${YELLOW}INVESTIGATING:${NC} $cif/$dir/$file may be different..."
#python tests/check_file.py "$path_to_file" "$output_path/$dir/$file"
bin/compare "$path_to_file" "$output_path/$dir/$file"
if [[ $? -ne 0 ]]; then
echo -e "${RED}WARNING:${NC} $cif/$dir/$file is different"
diff -yb --suppress-common-lines <(sed -E "$pattern" $path_to_file | sort) <(sed -E "$pattern" $output_path/$dir/$file | sort) | colordiff
diff -yw --suppress-common-lines <(sed -E "$pattern" $path_to_file | sort) <(sed -E "$pattern" $output_path/$dir/$file | sort) | colordiff
mkdir -p Mismatch/$cif/$dir/
cp -u Output/$cif/$dir/$file Mismatch/$cif/$dir/$file
else
Expand Down

0 comments on commit e0ab899

Please sign in to comment.