File: syminv

package info (click to toggle)
cod-tools 3.7.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 154,792 kB
  • sloc: perl: 57,588; sh: 36,842; ansic: 6,402; xml: 1,982; yacc: 1,117; makefile: 727; python: 166
file content (72 lines) | stat: -rwxr-xr-x 2,063 bytes parent folder | download
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
#! /bin/sh
#!perl -w # --*- Perl -*--
eval 'exec perl -x $0 ${1+"$@"}'
    if 0;
#------------------------------------------------------------------------------
#$Author: antanas $
#$Date: 2022-07-31 09:41:50 +0300 (Sun, 31 Jul 2022) $
#$Revision: 9352 $
#$URL: svn+ssh://www.crystallography.net/home/coder/svn-repositories/cod-tools/tags/v3.7.0/scripts/syminv $
#------------------------------------------------------------------------------
#*
#* Invert a symmetry operator provided on the command line.
#*
#* USAGE:
#*    $0 --options -- -y,-x,z -x,y,z
#*    $0 --options -- -y,-x,z -x,y,z z,y,x
#**

use strict;
use warnings;

use COD::Spacegroups::Symop::Parse qw(
    symop_from_string
    string_from_symop
);
use COD::Spacegroups::Symop::Algebra qw(
    symop_invert
    symop_modulo_1
);
use COD::SOptions qw( getOptions );
use COD::SUsage qw( usage );
use COD::ToolsVersion qw( get_version_string );

my $print_matrix = 0; # Print output as matrix or as a string.

#* OPTIONS:
#*   -m, --matrix
#*                     Print output in matrix form.
#*   -s, --string
#*                     Print output in string form as general position
#*                     coordinates (default).
#*
#*   --help, --usage
#*                     Output a short usage message (this message) and exit.
#*
#*   --version
#*                     Output version information and exit.
#**
@ARGV = getOptions(
    "-m,--matrix" => sub { $print_matrix = 1 },
    "-s,--string" => sub { $print_matrix = 0 },

    '--help,--usage' => sub { usage; exit },
    '--version'      => sub { print get_version_string(), "\n"; exit }
);

for my $symop_string (@ARGV) {
    my $symop = symop_from_string( $symop_string );
    my $result = symop_modulo_1( symop_invert( $symop ) );
    if( $print_matrix ) {
        for my $row (@$result) {
            my $separator = "";
            for (@$row) {
                print $separator, $_;
                $separator = "\t";
            }
            print "\n";
        }
    } else {
        print string_from_symop( $result ), "\n";
    }
}