File: make-test

package info (click to toggle)
chemonomatopist 0.11.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,048 kB
  • sloc: perl: 11,480; makefile: 2
file content (53 lines) | stat: -rwxr-xr-x 1,170 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
#!/usr/bin/perl

use strict;
use warnings;

use File::Basename qw( basename );
use IPC::Run3;
use Getopt::Long::Descriptive;

my $basename = basename $0;
my( $opt, $usage ) = describe_options( <<"END" . 'OPTIONS',
USAGE
    $basename [<args>] [<files>]

DESCRIPTION
    $basename prepares tests for ChemOnomatopist

END
    [ 'author',  'mark output tests with AUTHOR flag' ],
    [ 'pubchem', 'treat the input as three-columned PubChem file' ],
    [],
    [ 'help', 'print usage message and exit', { shortcircuit => 1 } ],
);

if( $opt->help ) {
    print $usage->text;
    exit;
}

my @lines = <>;

for (@lines) {
    s/^\s+//;
    s/\s+$//;

    my( $smiles, $iupac, $source );
    if( $opt->pubchem ) {
        ( my $id, $iupac, $smiles ) = split /\t/, $_;
        $source = "PubChem $id";
    } else {
        my( $stderr );
        $iupac = $_;
        run3 [ 'java', '-jar', '/usr/share/java/opsin.jar' ], \$iupac, \$smiles, \$stderr;
        $smiles =~ s/\n$//;
    }
    $iupac =~ s/'/\\'/g;

    print "{ smiles => '$smiles', iupac => '$iupac'";
    print ', AUTHOR => 1' if $opt->author;
    print ' },';
    print " # $source" if $source;
    print "\n";
}