[Biojava-l] circular sequences

Mark Schreiber mark_s@sanger.otago.ac.nz
Tue, 30 Jan 2001 15:05:19 +1300 (NZDT)


  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.
  Send mail to mime@docserver.cac.washington.edu for more info.

--0-846479053-980820319=:4511
Content-Type: TEXT/PLAIN; charset=US-ASCII

Hi

Attached are the CircularSequence and CircularView files. The circular
view allows for a temporary circular view onto a molecule that may be
discovered to be circular during or after parsing. Not sure how useful the
view is but it works.

Please look and poke and test to make sure It is compatible with other
code. The circular locations are still in the development but should be
out shortly

Mark


On Sun, 28 Jan 2001, Thomas Down wrote:

> On Mon, Jan 29, 2001 at 10:10:12AM +1300, Mark Schreiber wrote:
> > 
> > OK now i'm confused... why not just subclass simple sequence then since
> > the only thing that needs changing is the view onto the symbol list. All
> > other functionality is the same and doesn't need to be rewritten even if
> > it is minimal? I can't see how the delegation makes the job neater.
> 
> Yes, that would work fine too, if you'd prefer to take that
> approach.
> 
> Happy hacking,
> 
>     Thomas.
> _______________________________________________
> Biojava-l mailing list  -  Biojava-l@biojava.org
> http://biojava.org/mailman/listinfo/biojava-l
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Mark Schreiber			Ph: 64 3 4797875
Rm 218				email mark_s@sanger.otago.ac.nz
Department of Biochemistry	email m.schreiber@clear.net.nz
University of Otago		
PO Box 56
Dunedin
New Zealand
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

--0-846479053-980820319=:4511
Content-Type: TEXT/PLAIN; charset=US-ASCII; name="CircularView.java"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.OSF.3.96.1010130150519.4511B@sanger.otago.ac.nz>
Content-Description: 

LyoNCiAqICAgICAgICAgICAgICAgICAgICBCaW9KYXZhIGRldmVsb3BtZW50
IGNvZGUNCiAqDQogKiBUaGlzIGNvZG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bS5l
cnIucHJpbnRsbigvLyBUaGlzIHNob3VsZCBuZXZlciBoYXBwZW4NCiAgICAg
ICAgICAiQSBzZXJpb3VzIGVycm9yIGhhcyBvY2N1cmVkIGR1cmluZyB0aGUg
cmVjb25zdHJ1Y3Rpb24gb2YgIiArDQogICAgICAgICAgc3VwZXIuZ2V0TmFt
ZSgpKTsNCiAgICAgICAgICByZXR1cm4gbnVsbDsNCiAgICAgfQ0KICAgIH0N
CiAgfQ0KfQ0K
--0-846479053-980820319=:4511
Content-Type: TEXT/PLAIN; charset=US-ASCII; name="CircularSequence.java"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.OSF.3.96.1010130150519.4511C@sanger.otago.ac.nz>
Content-Description: 

LyoNCiAqICAgICAgICAgICAgICAgICAgICBCaW9KYXZhIGRldmVsb3BtZW50
IGNvZGUNCiAqDQogKiBUaGlzIGNvZGUgbWF5IGJlIGZyZWVseSBkaXN0cmli
dXRlZCBhbmQgbW9kaWZpZWQgdW5kZXIgdGhlDQogKiB0ZXJtcyBvZiB0aGUg
R05VIExlc3NlciBHZW5lcmFsIFB1YmxpYyBMaWNlbmNlLiAgVGhpcyBzaG91
bGQNCiAqIGJlIGRpc3RyaWJ1dGVkIHdpdGggdGhlIGNvZGUuICBJZiB5b3Ug
ZG8gbm90IGhhdmUgYSBjb3B5LA0KICogc2VlOg0KICoNCiAqICAgICAgaHR0
cDovL3d3dy5nbnUub3JnL2NvcHlsZWZ0L2xlc3Nlci5odG1sDQogKg0KICog
Q29weXJpZ2h0IGZvciB0aGlzIGNvZGUgaXMgaGVsZCBqb2ludGx5IGJ5IHRo
ZSBpbmRpdmlkdWFsDQogKiBhdXRob3JzLiAgVGhlc2Ugc2hvdWxkIGJlIGxp
c3RlZCBpbiBAYXV0aG9yIGRvYyBjb21tZW50cy4NCiAqDQogKiBGb3IgbW9y
ZSBpbmZvcm1hdGlvbiBvbiB0aGUgQmlvSmF2YSBwcm9qZWN0IGFuZCBpdHMg
YWltcywNCiAq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