File: cmp_settings.pl

package info (click to toggle)
primer3 2.6.1-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 142,144 kB
  • sloc: ansic: 11,153; cpp: 8,231; perl: 2,296; makefile: 318; sh: 53
file content (113 lines) | stat: -rwxr-xr-x 3,528 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/perl
#
# Logical compare (i.e. diff) of two settings files.
#
# For usage, see the usage statement in the code, below.
#
# ======================================================================
# (c) Copyright 1996,1997,1998,1999,2000,2001,2004,2006,2007,2008,2010,
#  2011,2012
# Whitehead Institute for Biomedical Research, Steve Rozen, 
# Andreas Untergasser and Helen Skaletsky
# All rights reserved.
# 
#   This file is part of the primer3 suite.
#
#   The primer3 suite is free software; you can redistribute it and/or
#   modify it under the terms of the GNU General Public License as
#   published by the Free Software Foundation; either version 2 of the
#   License, or (at your option) any later version.
#
#   This software is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this file (file gpl-2.0.txt in the source distribution); if
#   not, write to the Free Software Foundation, Inc., 51 Franklin St,
#   Fifth Floor, Boston, MA 02110-1301 USA
# 
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# ======================================================================



use strict;
use warnings "all";
use Getopt::Long;

my $file1;
my $file2;

my %tags1;
my %tags2;

sub read_file($$)
{
    my ($file, $tags) = @_;
    open IN, $file or die "open $file: $!\n";
    # skip first line
    my $line = <IN>;
    while ($line = <IN>) {
    chomp($line);
    # skip empty lines and comments
    if ($line =~ /^\s*$/) { next; }
    if ($line =~ "^#") { next; }
    unless ($line =~ /(\S*)=(.*)/) { print STDERR "wrong line format: $line\n"; next; }
    my $tag = $1;
    my $value = $2;
    $tags->{$tag} = $value;
    }
    close IN;
}

if (!GetOptions("file1=s" => \$file1, "file2=s" => \$file2) || !defined($file1) || !defined($file2)) {
    die "\nUsage:\n"
        . "$0 -file1 <filename1> -file2 <filename2>\n";
}

read_file($file1, \%tags1);
read_file($file2, \%tags2);

my @only1;

# cmp tags1 with tags2 print anything common different
print "Common tags with different values:\n";
foreach my $tag (sort (keys %tags1)) {
    if (defined($tags2{$tag})) {
    if ($tags1{$tag} ne $tags2{$tag}) {
        print "\t$tag:\n\t\t$file1: $tag=$tags1{$tag}\n\t\t$file2: $tag=$tags2{$tag}\n"
    }
    } else {
    push(@only1, $tag);
    }
}

print "Tags that exist only in $file1:\n";
foreach my $tag (@only1) {
    print "\t$tag=$tags1{$tag}\n";
}

print "Tags that exist only in $file2:\n";
foreach my $tag (keys %tags2) {
    if (!defined($tags1{$tag})) {
    print "\t$tag=$tags2{$tag}\n";
    }
}