473,395 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

database style data structure?

Hello,

I have a database style data structure, each record has several
fields.

I would like to create a nested data structure that would let me
'query' the data on the value of certain fields.

I did this by making the following type of data...
Sample PDB data...

ATOM 72 C ARG L 9 41.592 23.248 98.505 1.00 34.28
C
ATOM 73 O ARG L 9 42.467 23.303 97.634 1.00 33.66
O
ATOM 74 CB ARG L 9 40.542 25.445 99.063 1.00 32.51
C
ATOM 75 CG ARG L 9 40.415 26.641 99.989 1.00 30.92
C
ATOM 76 CD ARG L 9 39.771 27.823 99.291 0.00 47.64
C
ATOM 77 NE ARG L 9 38.331 27.672 99.123 0.00 67.84
N
package PDB;

our $pdbTemplate
= 'x6 A5 x1 A4 A1 A3 x1 A1 A4 A1 x3 A8 A8 A8 A6 A6 x6';

our @pdbDescriptive
= qw( serial name altLoc resName chainID resSeq iCode x y z
occupancy tempFactor segID element charge );

our @pdbDataIndex
= qw( serial name altLoc resName chainID resSeq iCode );

sub readPDB {
my $pdb = shift;

unless (ref($pdb) eq "GLOB"){
$pdb = openPDB($pdb);
}

# Data to return
my %pdbData;

while ( <$pdb> ){
next unless /^ATOM|^HETATM/o;

# Parse PDB file (see $pdbTemplate above)
my @atom = unpack( $pdbTemplate, $_ );

# Trim each value.
foreach ( @atom ){ s/^\s+// };

# Must be a better way? (to make a HASH).
my %atom = map { $pdbDescriptive[$_], $atom[$_] } ( 0..$#atom );

# Build up quite a complex data structure.
foreach (@pdbDataIndex){
push @{$pdbData{$_}{$atom{$_}}}, \%atom;
} push @{$pdbData{'data'}}, \%atom;
} return \%pdbData;
}

__END__

This lets me say...

use PDB;

my $data # Special data structure!
= readPDB( $pdb ); # Would be good to use Fields;

my @chainIDs # Lookup 'chain' entries
= sort keys %{ $data->{'chainID'} };

foreach my $chainID ( @chainIDs ){

my @atoms # Use 'chain' entry to get at underlying
atoms.
= @{ $data->{'chainID'}->{$chainID} };

print "$chain\t". scalar(@atoms). "\n";
}

__END__
But I would like to go one step further and for each chain return each
residue, or for each residue return each chain etc... (i.e. recursive
data structure).

How can I do this?
Jul 19 '05 #1
1 2094
dm*******@hotmail.com (dmb000006) wrote in message news:<93*************************@posting.google.c om>...

# Build up quite a complex data structure.
foreach (@pdbDataIndex){
push @{$pdbData{$_}{$atom{$_}}}, \%atom;
}
push @{$pdbData{'data'}}, \%atom;
} return \%pdbData;

= @{ $data->{'chainID'}->{$chainID} }; But I would like to go one step further and for each chain return each
residue, or for each residue return each chain etc... (i.e. recursive
data structure).
I'm not familar with the term "residue" in this context.

Is it just another field in the record? (Was it perhaps the one
called resName?)

So I'm figuring you are asking how given one chainID you can get the
list of corresponding resName values.

my @resNames = keys %{{ map { $_->{resName}, undef } @{
$data->{'chainID'}{$chainID} }};

This newsgroup does not exist (see FAQ). Please do not start threads
here.

How can I do this?

Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tim Mackey | last post by:
hi folks, i'm puzzled over this one, anyone with some solid db experience might be able to enlighten me here. i'm modelling a file system in a database as follows, and i can't figure out to...
9
by: Big Slim | last post by:
I'm working on a web application that makes heavy use of CSS, but I would like users to have a degree of control over some of the classes and attributes. To accomplish this, I want to store my CSS...
49
by: Relaxin | last post by:
It is just me or has MS created some of the worst ways to access and display data? You can use a DataSet, but if you want to sort or filter the data to must use a DataView which is created from...
9
by: shadow.demon | last post by:
G'day, I've separated my database calls into a separate dll, and return results from any database calls as a SqlDataReader (because of SQL Server use, it's nice and fast). However I'd like to be...
19
by: Andy B | last post by:
Hello, Sorry for this newbish question. Briefly, my problem: ------------------ I expect the database I'm working on to reach something in the order of 12-16 Gigabytes, and I am interested...
3
by: josh.kuo | last post by:
Sorry about the subject, I can't think of a better one. I recently wrote some PHP classes that I think might be of interest to this group. Since I have been reaping the benefits of reading news...
1
by: Eric Sadoyama | last post by:
I have a database documentation question, but I am not even sure how to phrase it properly so I don't know where to start looking for answers. We are developing a database that is based on...
4
by: raidvvan | last post by:
Hi there, We have been looking for some time now for a database system that can fit a large distributed computing project, but we haven't been able to find one. I was hoping that someone can...
9
by: Peter Duniho | last post by:
Is there a straightfoward API in .NET that allows for inspection of a database? That is, to look at the structure of the database, without knowing anything in advance about it? For example,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.