-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_isomorphy_sql.pl
More file actions
executable file
·78 lines (60 loc) · 2 KB
/
update_isomorphy_sql.pl
File metadata and controls
executable file
·78 lines (60 loc) · 2 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/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 = (?);");
my $fetch = $dbh->prepare("SELECT type, recognized FROM complexes WHERE signature = (?);");
my $overwrite = $dbh->prepare("UPDATE complexes SET type = (?), recognized = (?), remark = 'isomorphism_check' WHERE signature = (?) OR type = (SELECT type FROM complexes WHERE signature = (?)) AND type <> ''");
#my $regdesc = shift;
#$sth->execute($regdesc);
#my @row = $sth->fetchrow_array;
## 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{$_})) {
$fetch->execute($_);
my @row = $fetch->fetchrow_array;
$fetch->execute($c);
my @crow = $fetch->fetchrow_array;
if ( $row[1] and $crow[1] ) {
next;
}
if ( $row[1] ) {
$overwrite->execute($row[0],$row[1],$c,$c);
} elsif ($crow[1]) {
$overwrite->execute($crow[0],$crow[1],$_,$_);
} elsif (! $row[0] eq '') {
$overwrite->execute($row[0],$row[1],$c,$c);
} elsif (! $crow[0] eq '') {
$overwrite->execute($crow[0],$crow[1],$_,$_);
} else {
$overwrite->execute($_,0,$c,$c);
}
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;