next up previous contents
Next: The Sequence Structure Up: Accessing a Darwin Sequence Previous: The Entry Structure

The Offset Structure

Because a Darwin sequence database is stored as a string object assigned to DB[string], we can access elements of it as we would any array or string.
> ReadDb('Sample/SH2'):    # load the small Swiss-Prot database
> DB[string][1];           # the first character of the database
<
> DB[string][1..55];       # the first 55 characters of the database
<DBNAME>SH2 Database</DBNAME><DBRELEASE>1.0</DBRELEASE>
> DB[string][368..923];    # the sequence of the first entry.
NNEWCEARLYSTRKNDASNQRRLGEIGWVPSNFIAPYNSLDKYTWYHGKI ..(556).. DDVVPLAEKNV
If we cross-reference the above statements with Figure [*], we see that DB[string][1] is the first character of the database which is an opening angle bracket. The first through fifty-first characters offset from DB [string] consist of the database header and characters 368 through 923 represent the sequence of the first entry. The statement
> print(Offset(2536));
ID>ABL1_HUMAN</ID><AC>P00519;</AC><DE>PROTO-ONCOGE ..(74289).. G</SEQ></E>
is equivalent to
> print(DB[string][2536+1 .. DB[TotChars]]);
ID>ABL1_HUMAN</ID><AC>P00519;</AC><DE>PROTO-ONCOGE ..(74289).. G</SEQ></E>

The Offset structure allows us to find in which entry a particular offset from DB[string] lies. In Figure [*], offset 2536 lies in entry number 3.

> entry_num := Entry(Offset(2536));
entry_num := Entry(3)
> print(entry_num);
<E><ID>ABL1_HUMAN</ID><AC>P00519;</AC><DE>PROTO-ONCOGENE 
TYROSINE-PROTEIN KINASE ABL (EC 2.7.1.112) (P150) (C-ABL)
.</DE><OS>HOMO SAPIENS (HUMAN).</OS><OC>EUKARYOTA; METAZO
...
Darwin converts Offset(2536) into the entry number located at position DB[string][2536].
> entry_numbers := Entry(Offset(1, 55, 60, 881, 937, 2475, 2533, 76800));
entry_numbers := Entries(0,0,1,1,2,2,3,78)

Alternatively, we may select on an Entry structure using the option 'Offset' or 'O'. This returns a Offset structure containing the offset from DB[string].

> Entry(1)['Offset'];
Offset(56)
> Entry(1)['O'];
Offset(56)
> Entry(2, 3, 77, 78)['Offset'];
Offset(936,2532,74814,75833)



Gaston Gonnet
1998-09-15