Added scripts to create this dataset
This commit is contained in:
parent
9c636c1de3
commit
e98ea582a7
4 changed files with 154 additions and 0 deletions
34
scripts/README.md
Normal file
34
scripts/README.md
Normal file
|
@ -0,0 +1,34 @@
|
|||
## Scripts to filter out unique minimal triangulaitons
|
||||
|
||||
These scripts dig through directories to find triangulations, take the
|
||||
minimal ones, remove duplicates, and then export them, sorted by PL-type.
|
||||
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- Polymake
|
||||
- PostgreSQL
|
||||
|
||||
### How to use:
|
||||
|
||||
Create the database tables
|
||||
|
||||
```
|
||||
CREATE TABLE triangulations (signature varchar, f_vector varchar, vertices integer, path varchar);
|
||||
CREATE TABLE minimal_triangulations (signature varchar, f_vector varchar, vertices integer, path varchar);
|
||||
```
|
||||
|
||||
Populate the triangulations table
|
||||
|
||||
```
|
||||
find ~ -name *.poly -not -path "*comb_iso_classes*" -not -path "*flat*" | parallel --progress ./triangulation_bookkeeping.pl {}
|
||||
```
|
||||
|
||||
Populate the minimal triangulations (by vertices) table by finding the
|
||||
minimum triangulation for each signature
|
||||
|
||||
```
|
||||
INSERT INTO minimal_triangulations SELECT DISTINCT ON (signature) * FROM triangulations ORDER BY signature, vertices
|
||||
```
|
||||
|
||||
Remove combinatorially isomorphic triangulations by running `triangulation_bookkeeping_minimal.pl`, and output sorted by type using `triangulation_bookkeeping_output.pl`
|
28
scripts/triangulation_bookkeeping.pl
Executable file
28
scripts/triangulation_bookkeeping.pl
Executable file
|
@ -0,0 +1,28 @@
|
|||
#!/usr/local/bin/polymake --script
|
||||
|
||||
# Initialize table with triangulations
|
||||
|
||||
use application "topaz";
|
||||
use strict;
|
||||
use warnings;
|
||||
use DBI;
|
||||
|
||||
my $dbh = DBI->connect("dbi:Pg:dbname=researchdata_test", '', '', {AutoCommit => 0});
|
||||
my $sth = $dbh->prepare("INSERT INTO triangulations VALUES (?, ?, ?, ?);");
|
||||
|
||||
my $path = shift;
|
||||
|
||||
$path =~ m,([^/]+)\.poly$,;
|
||||
|
||||
my $regdesc = $1;
|
||||
|
||||
my $q=load_data("$path");
|
||||
|
||||
my $vert = @{$q->F_VECTOR}[0];
|
||||
|
||||
|
||||
$sth->execute($regdesc, "@{$q->F_VECTOR}", $vert, $path);
|
||||
$dbh->commit;
|
||||
|
||||
|
||||
# after this run INSERT INTO minimal_triangulations SELECT DISTINCT ON (signature) * FROM triangulations ORDER BY signature, vertices ; to get a table of minimal triangulations of each complex
|
45
scripts/triangulation_bookkeeping_minimal.pl
Executable file
45
scripts/triangulation_bookkeeping_minimal.pl
Executable file
|
@ -0,0 +1,45 @@
|
|||
#!/usr/local/bin/polymake --script
|
||||
|
||||
### removes duplicate (combinatorially isomorphic) triangulations
|
||||
|
||||
use application "topaz";
|
||||
use strict;
|
||||
use warnings;
|
||||
use DBI;
|
||||
|
||||
my $dbh = DBI->connect("dbi:Pg:dbname=researchdata_test", '', '', {AutoCommit => 0});
|
||||
my $vst = $dbh->prepare("SELECT DISTINCT(vertices) FROM minimal_triangulations");
|
||||
my $pst = $dbh->prepare("SELECT path FROM minimal_triangulations WHERE vertices = (?)");
|
||||
my $pathdel = $dbh->prepare("DELETE FROM minimal_triangulations WHERE path = (?)");
|
||||
|
||||
|
||||
|
||||
$vst->execute();
|
||||
|
||||
while (my @data = $vst->fetchrow_array) {
|
||||
my $vert = shift @data;
|
||||
print("$vert\n");
|
||||
my %complexes = ();
|
||||
$pst->execute($vert);
|
||||
while (my @data = $pst->fetchrow_array ) {
|
||||
my $path = shift @data;
|
||||
$complexes{$path} = load_data("$path");
|
||||
}
|
||||
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{$_})) {
|
||||
print "$c $_ \n";
|
||||
$pathdel->execute($_);
|
||||
delete($complexes{$_});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$dbh->commit;
|
||||
|
||||
|
47
scripts/triangulation_bookkeeping_output.pl
Executable file
47
scripts/triangulation_bookkeeping_output.pl
Executable file
|
@ -0,0 +1,47 @@
|
|||
#!/usr/local/bin/polymake --script
|
||||
|
||||
### Outputs minimal triangulations into sorted directories
|
||||
|
||||
use application "topaz";
|
||||
use strict;
|
||||
use warnings;
|
||||
use DBI;
|
||||
use File::Copy;
|
||||
|
||||
my $dbh = DBI->connect("dbi:Pg:dbname=researchdata_test", '', '', {AutoCommit => 0});
|
||||
my $types = $dbh->prepare("SELECT DISTINCT(type) FROM complexes;"); ## select the types
|
||||
|
||||
|
||||
|
||||
my $paths = $dbh->prepare("SELECT signature,vertices,path FROM minimal_triangulations WHERE signature IN (SELECT signature FROM complexes WHERE type = (?));");
|
||||
|
||||
|
||||
my $outdir = "minimal_triangulations";
|
||||
if (! -d $outdir ) {
|
||||
mkdir $outdir
|
||||
}
|
||||
|
||||
$types->execute;
|
||||
while (my @data = $types->fetchrow_array) {
|
||||
my $type = shift @data;
|
||||
if (not $type eq "") {
|
||||
print "$type\n";
|
||||
$paths->execute($type);
|
||||
if (! -d "$outdir/$type" ) {
|
||||
mkdir "$outdir/$type";
|
||||
}
|
||||
while (my @p = $paths->fetchrow_array) {
|
||||
my $sig = shift @p;
|
||||
my $vert = shift @p;
|
||||
if (! -d "$outdir/$type/$vert" ) {
|
||||
mkdir "$outdir/$type/$vert";
|
||||
}
|
||||
my $path = shift @p;
|
||||
copy($path,"$outdir/$type/$vert/$sig.poly");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$dbh->commit;
|
||||
|
Loading…
Reference in a new issue