#!/usr/bin/perl -w
use strict;

use FlipDB;

my $name = shift;
if (!defined $name || $name eq "") {
	print STDERR "Usage: dbcreator.pl DBName < data.tsv\n";
	exit 2;
}

my $file = "$name.pdb";

my $pdb = new FlipDB;
$pdb->{name} = $name;

while (<>) {
	if (/\w.*\t.*\w/ && $_ !~ /^#/) {
		my $record = $pdb->new_Record();
		$record->{known} = 0;
		($record->{word1}, $record->{word2}) = split /\t+/, $_;
		$record->{word1} = trim($record->{word1});
		$record->{word2} = trim($record->{word2});
		$pdb->append_Record($record);
	}
}

$pdb->Write($file);


sub trim
{
	$_ = $_[0];
	s/^\s*//;
	s/\s*$//;
	return $_;
}


