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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
|
#! /bin/sh
#!perl -w # --*- Perl -*--
eval 'exec perl -x $0 ${1+"$@"}'
if 0;
#------------------------------------------------------------------------------
#$Author: saulius $
#$Date: 2022-06-09 18:32:06 +0300 (Thu, 09 Jun 2022) $
#$Revision: 9325 $
#$URL: svn+ssh://www.crystallography.net/home/coder/svn-repositories/cod-tools/tags/v3.7.0/scripts/symops $
#------------------------------------------------------------------------------
#*
#* Print out symmetry operators for a given space group, or print out
#* those symmetry operators that belong to the group, while diagnosing
#* as errors those operators that do not belong to the group.
#*
#* USAGE:
#* $0 --options P212121
#* $0 --options P212121 -- -y,-x,z -x,y,z
#* $0 --hall -- '-P 2 2'
#* $0 --hall -- '-P 2 2' "-y,-x,z" "-x,y,z"
#**
use strict;
use warnings;
use COD::CIF::Data;
use COD::Spacegroups::Symop::Parse qw(
symop_string_canonical_form
);
use COD::SOptions qw( getOptions );
use COD::SUsage qw( usage );
use COD::ToolsVersion qw( get_version_string );
my $quiet = 0; # Be quiet, do not print symmtry operators that are
# found to belong to the group.
my $do_not_report_errors = 0; # Do not output error messages when the
# argument symmetry operator does not
# belong to the group.
my $symbol_type = 'hermann_mauguin';
#* OPTIONS:
#* -q, --quiet
#* Do not output recognised operator names (default).
#* -v, --verbose
#* Print out symmetry operators, negate the '-q' option.
#*
#* --hall Use Hall symbols for lookup
#* --hermann-mauguin Use Hermann-Mauguin symbols for lookup
#* --schoenflies Use Schönflies symbols for lookup
#*
#* --error-messages
#* Print error messages about unrecognised symmetry
#* operators (default).
#* --no-error-messages
#* Do not print error messages about missing
#* symmetry operators, just return a non-zero
#* status if such are encountered.
#*
#* --help, --usage
#* Output a short usage message (this message) and exit.
#*
#* --version
#* Output version information and exit.
#**
@ARGV = getOptions(
"-q,--quiet" => sub { $quiet = 1 },
"-v,--verbose" => sub { $quiet = 0 },
"--hall" => sub {$symbol_type = 'hall'},
"--hermann-mauguin" => sub {$symbol_type = 'hermann_mauguin'},
"--schoenflies" => sub {$symbol_type = 'schoenflies'},
"--no-error-messages" => sub { $do_not_report_errors = 1 },
"--error-messages" => sub { $do_not_report_errors = 0 },
'--help,--usage' => sub { usage; exit },
'--version' => sub { print get_version_string(), "\n"; exit }
);
if( @ARGV < 1 ) {
print STDERR "$0: usage: $0 SGNAME\n";
print STDERR " e.g.: $0 P212121\n";
exit 1;
}
my $spacegroup_name = shift( @ARGV );
my $sym_data =
COD::CIF::Data::lookup_space_group( $symbol_type, $spacegroup_name );
if( defined $sym_data ) {
local $\ = "\n";
if( @ARGV == 0 ) {
for my $symop (@{$sym_data->{symops}}) {
print symop_string_canonical_form( $symop );
}
} else {
my $status = 0;
my %symops = map {
symop_string_canonical_form( $_ ) => 1
} @{$sym_data->{symops}};
for my $symop (@ARGV) {
my $symop_key = symop_string_canonical_form( $symop );
if( exists $symops{$symop_key} ) {
print $symop_key, "\t", $symop
unless $quiet;
} else {
print STDERR "$0: symetry operator '$symop' ('$symop_key') " .
"was not found in spacegroup '$spacegroup_name'"
unless $do_not_report_errors;
$status = 3;
}
}
exit $status;
}
} else {
print STDERR "$0: spacegroup '$spacegroup_name' could not be identified\n";
exit 2;
}
|