Looking for transformation scripts

Donn Davy davy at CUTTER.LBL.GOV
Thu Apr 18 16:13:23 EST 1996


On Thu, 18 Apr 1996, Corey Lovitt wrote:

> I'm interested if anyone in the ACeDB community has written scripts or
> knows of scripts which create an ACE readable database from a relational
> one.  I'm interested in ACE's visualization tools but we have all our
> data stored in a relational type format.
> 
There is an awk script called "line2ace" which converts a tab-delimited 
dump of tabular material (like  from a relational db) in the archives of 
acedb somewhere (at ncbi, I think).

I have written something similar in perl: enclosed below. The 1st line is 
gives the Class name then acedb 'field' tags, succeeding lines have 
tab-separated data.  The output is a .ace file suitable for loading a 
particular acedb class.  I plan a variant which will do the update 
directly, using the aceclient/aceserver.

 --------------------------------------------+------------------
 Donn F. Davy, Computer Systems Engineer     /    (510) 486-4162
 Lawrence Berkeley National Laboratory      \
 MS 50F-129, One Cyclotron Rd              /
 Berkeley, CA 94720                       \   fax (510) 486-5548
 -----------------------------------------+---------------------


----------- begin enclosed matter -------------
#!/usr/local/bin/perl
#l2a - convert tabular delimited data to .ace
#	assumptions:
#		- class object ID is column 1
#		- tag names are column titles in row 1
#		- for rows w/ blank col 1 (ID): any values on line accrue to prev object

$lno = 0;
LINE: while (<>) {

	if (/^\s*$/) { next LINE}; 			## skip blank lines

	$lno++;
	if ($lno == 1) {
		chop;
		@fields = split(/[\t]/);
		next LINE;
	}
	chop;
	split(/[\t]/);
	
	unless ($_[0] =~  /^[ \t]*$/) { 
		$_[0] =~ s/"//g;			## strip out all double quotes
		print "\n$fields[0] : \"$_[0]\"\n";
	}

	for ($i = 1; $i <= @fields; $i++) {

		unless ($_[$i] =~ /^[ \t]*$/) {
			$_[$i] =~ s/"//g;		## strip out all double quotes
			print "$fields[$i]  \"$_[$i]\"\n";
		}

	}
	print "\n";
}





More information about the Acedb mailing list