[Biojava-l] SequenceDBInstallation
Gerald Loeffler
Gerald.Loeffler@vienna.at
Mon, 03 Jul 2000 20:22:28 +0200
This is a multi-part message in MIME format.
--------------5EDBE52F55F8D097795F69E5
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Hi!
We need factories for SequenceDB objects and we need managers for
SequenceDB objects such that e.g. there is only exactly one SequenceDB
object that accesses the SwissProt flat file /data/sprot/sprot.dat.
I attach 2 files: SequenceDBInstallation is an interface that defines
such a factory/manager for SequenceDB objects. It is very short and
documented rigorously, so please have a look at it for a more detailed
explanation why we need it. File StupidSequenceDBInstallation.java
contains an implementation of this interface for testing purposes.
Once interface SequenceDBInstallation is in place and implemented
widely, we should be able to do things like this:
SequenceDBInstallation inst = new SRSSequenceDBInstallation();
// or inst = new CorbaSequenceDBInstallation("bsa_naming_context");
// or inst = new FASTAFileSequenceDBInstallation("/data/sequences/");
SequenceDB sprot = inst.getSequenceDB("swissprot");
Sequence important = sprot.getSequence("FOO_DROME");
what do you think?,
cheers,
gerald
--
Gerald.Loeffler@vienna.at _________________ Software Architect
http://www.imp.univie.ac.at ____ http://www.daemonstration.com
OOA&D, Java, J2EE, JSP, Servlets, JavaBeans, ODBMS, RDBMS, XML
--------------5EDBE52F55F8D097795F69E5
Content-Type: application/x-unknown-content-type-java_auto_file;
name="SequenceDBInstallation.java"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="SequenceDBInstallation.java"
cGFja2FnZSBvcmcuYmlvamF2YS5iaW8uc2VxOwoKaW1wb3J0IGphdmEudXRpbC5TZXQ7Cgov
KioKICogQSBTZXF1ZW5jZURCSW5zdGFsbGF0aW9uIGhhcyB0aGUgZnVuY3Rpb25hbGl0eSBv
ZiBhIGZhY3RvcnkgZm9yIFNlcXVlbmNlREIgb2JqZWN0cyBhcmUgYWRkaXRpb25hbGx5IG1h
bmFnZXMgdGhlCiAqIFNlcXVlbmNlREIgb2JqZWN0cyBjcmVhdGVkIGJ5IGl0c2VsZiBz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ZXIgdGhlIHN0cmluZyB0aGF0IGlkZW50aWZpZXMgdGhlIHNlcXVlbmNlIGRi
LiBNYXkgbm90IGJlIG51bGwuCiAgICogQHJldHVybiB0aGUgU2VxdWVuY2VEQiBvYmplY3Qg
dGhhdCBtYXRjaGVzIHRoZSBnaXZlbiBpZGVudGlmaWVyIG9yIG51bGwgaWYgbm8gc3VjaCBT
ZXF1ZW5jZURCIG9iamVjdCBjb3VsZCBiZQogICAqICAgICAgICAgZm91bmQuIChJdCBpcyB0
aGUgcmVzcG9uc2liaWxpdHkgb2YgdGhlIGltcGxlbWVudGF0aW9uIHRvIHRha2UgY2FyZSB0
aGF0IGFsbCBpZGVudGlmaWVycyBhcmUgdW5pcXVlIHNvCiAgICogICAgICAgICBpZiBpdCB0
dXJucyBvdXQgdGhhdCB0aGUgZ2l2ZW4gaWRlbnRpZmllciBpZGVudGlmaWVzIG1vcmUgdGhh
biBvbmUgc2VxdWVuY2UgZGIsIHRoaXMgbWV0aG9kIHNob3VsZCB0aHJvdwogICAqICAgICAg
ICAgYSBSdW50aW1lRXhjZXB0aW9uLikKICAgKi8KICBTZXF1ZW5jZURCIGdldFNlcXVlbmNl
REIoU3RyaW5nIGlkZW50aWZpZXIpOwp9Cg==
--------------5EDBE52F55F8D097795F69E5
Content-Type: application/x-unknown-content-type-java_auto_file;
name="StupidSequenceDBInstallation.java"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="StupidSequenceDBInstallation.java"
cGFja2FnZSBvcmcuYmlvamF2YS5iaW8uc2VxOwoKaW1wb3J0IGNvbS5kYWVtb25zdHJhdGlv
bi5jb250cmFjdC5Db250cmFjdDsKaW1wb3J0IGNvbS5kYWVtb25zdHJhdGlvbi51dGlsLk9i
amVjdFV0aWw7CgppbXBvcnQgb3JnLmxvZzRqLkNhdGVnb3J5OwoKaW1wb3J0IGphdmEudXRp
bC4qOwoKLyoqCiAqIHRoaXMgY2xhc3MgaXMgYW4gaW1wbGVtZW50YXRpb24gb2YgaW50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