File: symop_build_spacegroup

package info (click to toggle)
cod-tools 2.3%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 114,852 kB
  • sloc: perl: 53,336; sh: 23,842; ansic: 6,318; xml: 1,982; yacc: 1,112; makefile: 716; python: 158; sql: 73
file content (67 lines) | stat: -rwxr-xr-x 2,050 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
#! /bin/sh
#!perl -w # --*- Perl -*--
eval 'exec perl -x $0 ${1+"$@"}'
    if 0;
#------------------------------------------------------------------------------
#$Author: antanas $
#$Date: 2017-05-24 20:10:55 +0300 (Tr, 24 geg. 2017) $ 
#$Revision: 5322 $
#$URL: svn://www.crystallography.net/cod-tools/tags/v2.3/scripts/symop_build_spacegroup $
#------------------------------------------------------------------------------
#*
#* Determine a space group from a list of symmetry operators
#* (generators), using the Ralf's (Ralf Grosse-Kunstleve) algorithm.
#*
#* USAGE: $0 < input.symop
#* USAGE: $0 input.symop
#* USAGE: $0 input.symop additional*.symop
#**

use strict;
use warnings;
use COD::Spacegroups::Lookup::COD;
use COD::Spacegroups::Lookup qw( make_symop_hash make_symop_key );
use COD::Spacegroups::Symop::Parse qw( string_from_symop );
use COD::Spacegroups::Builder;
use COD::SOptions qw( getOptions );
use COD::SUsage qw( usage );
use COD::ToolsVersion;

#* OPTIONS:
#*   --help, --usage
#*                     Output a short usage message (this message) and exit.
#*   --version
#*                     Output version information and exit.
#**
@ARGV = getOptions(
    "--help,--usage" => sub { usage; exit },
    '--version'      => sub { print 'cod-tools version ',
                              $COD::ToolsVersion::Version, "\n";
                              exit }
);

my $spacegroup = COD::Spacegroups::Builder->new;

while(<>) {
    next if /^#/;
    next if /^\s*$/;
    $spacegroup->insert_symop_string( $_ );
}

$spacegroup->print();

my @symops = $spacegroup->all_symops();

my %symop_lookup_table = make_symop_hash( [
    \@COD::Spacegroups::Lookup::COD::table,
    \@COD::Spacegroups::Lookup::COD::extra_settings
] );
my $key = make_symop_key( [ map { string_from_symop($_) } @symops ] );

if( exists $symop_lookup_table{$key} ) {
    my $estimated_sg = $symop_lookup_table{$key};
    use COD::Serialise qw( serialiseRef );
    serialiseRef( $estimated_sg );
} else {
    print "$0: spacegroup could not be identified\n"
}