1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
|
#!/bin/sh
#------------------------------------------------------------------------------
#$Author: antanas $
#$Date: 2020-04-09 20:56:38 +0300 (Thu, 09 Apr 2020) $
#$Revision: 7817 $
#$URL: svn+ssh://www.crystallography.net/home/coder/svn-repositories/cod-tools/tags/v3.1.0/scripts/cif_CODify $
#------------------------------------------------------------------------------
#*
#* Extract essential data from the input CIF file and format it
#* using the rules of the Crystallography Open Database (COD).
#*
#* USAGE:
#* $0 --options input1.cif input*.cif
#**
set -ue
# set -x
CIF_FILTER="cif_filter"
arg=""
while [ $# -gt 0 ]
do
case $1 in
--options|--option|--optio|--opti|--opt|--op|--o)
echo "`basename $0`:: The '--options' option is a placeholder."
echo "`basename $0`:: It should be replaced by one of the following options:"
awk '/#\* OPTIONS:/,/#\*\*/ {
sub("OPTIONS:", ""); \
sub("^ *#[*]?[*]?", ""); \
gsub("\\$0","'$0'"); \
print $0
}' `which ${CIF_FILTER}` < /dev/null
echo "$0:: NOTE, the option list was retrieved from the '${CIF_FILTER}' script."
exit
;;
--help|--hel|--he|--h|--usage)
gawk '/^#\*/,/^#\*\*/ {
sub("^ *#[*]?[*]?", ""); \
gsub("\\$0","'$0'"); \
print $0
}' $0
awk '/#\* OPTIONS:/,/#\*\*/ {
sub("^ *#[*]?[*]?", ""); \
gsub("\\$0","'$0'"); \
print $0
}' `which ${CIF_FILTER}` < /dev/null
echo "$0:: NOTE, the option list was retrieved from the '${CIF_FILTER}' script."
exit
;;
--version)
$(dirname $0)/cod-tools-version
exit
;;
*)
if [ -z ${file+1} ];
then
file=$1
else
arg="$arg $1"
fi
;;
esac
shift
done
arg="$file $arg"
if head $file | grep -q '^#' > /dev/null 2>&1
then
awk '{if( match( $0, "^#" )) print; else exit}' $file
else
cat <<EOF
#------------------------------------------------------------------------------
#\$Date\$
#\$Revision\$
#\$URL\$
#------------------------------------------------------------------------------
#
# This file is available in the Crystallography Open Database (COD),
# http://www.crystallography.net/
#
# All data on this site have been placed in the public domain by the
# contributors.
#
EOF
fi
NUMBER=`basename ${file} .cif | sed -e 's/[^0-9]//g'`
${CIF_FILTER} \
--renumber \
--start-data="${NUMBER}" \
--exclude-empty-non-loop-tags \
--estimate-spacegroup \
--reformat-spacegroup \
--keep-unrecognised-spacegroup \
--parse-formula-sum \
--calculate-cell-volume \
--use-all-datablocks \
${arg}
|