-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathisomorphy_check_sql.pl
More file actions
executable file
·55 lines (37 loc) · 1.1 KB
/
isomorphy_check_sql.pl
File metadata and controls
executable file
·55 lines (37 loc) · 1.1 KB
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
#!/usr/bin/env -S polymake --script
### Attempt to classify the simplicial complexes by combinatorial isomorphism
use application "topaz";
use strict;
use warnings;
use DBI;
my $dbh = DBI->connect("dbi:Pg:dbname=researchdata_test", '', '', {AutoCommit => 0});
my $sth = $dbh->prepare("UPDATE complexes SET type = (?), remark = 'isomorphism_check' WHERE signature = (?);");
## input: feed a directory of triangulations of the same number of simplices
my $dir=shift;
my @files=<$dir/*>;
my %complexes = ();
foreach (@files) {
my $basename = $_ =~ s,.*/([^/]*).poly$,$1,r;
$complexes{$basename} = load_data($_);
}
my $outdir="comb_iso_classes";
if (! -d $outdir ) {
mkdir $outdir;
}
my @ck = keys %complexes;
foreach (keys %complexes) {
my $c = shift @ck;
foreach (@ck) {
if (defined $complexes{$_} and defined $complexes{$c} and isomorphic($complexes{$c}, $complexes{$_})) {
if (! -d "$outdir/$c" ) {
mkdir "$outdir/$c";
}
$sth->execute($c,$_);
$sth->execute($c,$c);
save($complexes{$_}, "$outdir/$c/$_.poly");
print "$c $_ \n";
delete($complexes{$_});
}
}
}
$dbh->commit;