File: pattern.t

package info (click to toggle)
libchemistry-file-mdlmol-perl 0.24-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 192 kB
  • sloc: perl: 352; makefile: 2
file content (38 lines) | stat: -rw-r--r-- 1,085 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
use strict;
use warnings;
use Test::More;
use Chemistry::File::MDLMol;

my @patt_files = glob 't/pat/*.mol';
my @mol_files  = glob 't/mol/*.mol';

if (eval "use Chemistry::Pattern; 1") {
    plan tests => 1 + 1 * @patt_files + 1 * @patt_files * @mol_files;
    #plan 'no_plan';
    ok(1, "loaded Chemistry::Pattern");
} else {
    plan skip_all => 'Chemistry::Pattern not installed';
}

#$Chemistry::File::MDLMol::DEBUG = 1;

for my $patt_file (@patt_files) {
    my $patt = Chemistry::Pattern->read($patt_file);
    isa_ok ($patt, 'Chemistry::Pattern');
    my ($patt_basename) = $patt_file =~ /([^\/]*)\.mol/;
    my %expected = split " ", $patt->name;

    for my $mol_file (@mol_files) {
        my ($mol_basename) = $mol_file =~ /([^\/]*)\.mol/;
        $expected{$mol_basename} ||= 0;

        my $mol = Chemistry::Mol->read($mol_file);
        Chemistry::Ring::aromatize_mol($mol);

        my $n = 0;
        $n++ while $patt->match($mol);
        is ($n, $expected{$mol_basename}, 
            "$patt_basename matches $mol_basename $expected{$mol_basename} times?");
    }
}