#!/bin/sh
#!perl -w # --*- Perl -*--
eval 'exec perl -x $0 ${1+"$@"}'
    if 0;
#------------------------------------------------------------------------------
#$Author: antanas $
#$Date: 2017-05-17 17:28:57 +0300 (Wed, 17 May 2017) $
#$Revision: 5269 $
#$URL: svn+ssh://www.crystallography.net/home/coder/svn-repositories/cod-tools/tags/v3.0.1/tools/duplicate_space_groups $
#------------------------------------------------------------------------------
#*
# Find and print out duplicated space group definitions in COD::Spacegroups::Lookup::COD.
#**

use strict;
use warnings;
use COD::Spacegroups::Lookup::COD;
use COD::Spacegroups::Lookup qw( make_symop_hash make_symop_key );

# Identify the spacegroup from the symmetry operators:

my %symop_lookup_table = make_symop_hash( [
    \@COD::Spacegroups::Lookup::COD::table,
    \@COD::Spacegroups::Lookup::COD::extra_settings
] );

for my $sg ( @COD::Spacegroups::Lookup::COD::table,
             @COD::Spacegroups::Lookup::COD::extra_settings ) {
    my @symops = @{$sg->{symops}};
    my $key = make_symop_key( \@symops );

    if( exists $symop_lookup_table{$key} ) {
        my $estimated_sg = $symop_lookup_table{$key};
        if( $sg->{universal_h_m} ne $estimated_sg->{universal_h_m} ) {
            printf "%-20s\t%s\n",
                $sg->{universal_h_m},
                $estimated_sg->{universal_h_m};
        }
    } else {
        print STDERR "$0:: WARNING, space group could not be identified\n"
    }
}
