[Biococoa-dev] New goodies - BCStandaloneReader
Alexander Griekspoor
a.griekspoor at nki.nl
Fri Mar 3 05:00:38 EST 2006
> I have never liked gck, and now hates it. I am stuck with files I
> can only open, and not even copy/paste from using their demo
> version. Good job!!
That was quite some fun to kind of reverse engineer actually, using
hexedit it was quite easy to do. It turns out that GCK writes a small
header of which the last int contains the size of the sequence. After
that it's just reading all bytes after the header up to the size of
the sequence using NSData. Easy does it, of course the fact that I
don't care about all the other crap GCK writes into the file
following that sequence (containing all annotations stuff etc) made
life (very) easy...
As far as I know, BioCocoa is now the only thing that can do
something at all with GCK files....
> And EnzymeX 3.0 is coming sooooooon... good news ;-)
Yeah, rub it in ;-)
Cheers,
Alex
>
>
> On Mar 2, 2006, at 3:10 AM, Alexander Griekspoor wrote:
>
>> Hi guys,
>>
>> Long time, no activity unfortunately. Still there is some news.
>> The last two weeks I've used my (very) few spare hours to fulfil
>> some long standing promises, and updated our programs to bring
>> them at least on par with OSX Tiger. For instance, we were so
>> optimistic (read: stupid) to write on our website that we would
>> release new versions of both EnzymeX and iRNAi "soon". That was 2
>> years ago ;-)
>> Anyway, they're finished now (iRNAi 2 released today and EnzymeX 3
>> finishing up). In both of them I used some of Peter's "old"
>> BioCocoa code to allow reading of most common sequence file
>> formats, and I would like to share that with you guys. Perhaps
>> Peter can give it a place on the BioCocoa CVS/SVN or post it on
>> the BioCocoa webpage.
>> I made a standalone version of the BCReader code, so that adding
>> these 4 files is sufficient to add reading of all of the following
>> formats to your app for free:
>>
>> - BEAST,
>> - Clustal
>> - DNA Strider
>> - EMBL
>> - Fasta
>> - GCG-MSF
>> - GCK (Gene Construction Kit)
>> - GDE
>> - Hennig86
>> - NCBI
>> - NEXUS
>> - NONA
>> - PDB
>> - Phylip
>> - PIR
>> - Plain/Raw
>> - Swiss-Prot
>> - TNT
>>
>> As you can see I've added the binary formats DNAStrider and Gene
>> Construction Kit files (the latter using a bit of (very simple)
>> reverse engineering ;-)
>> Below is a snippet from iRNAi that shows you how to read a
>> sequence file:
>>
>> - (IBAction)importSequence:(id)sender{
>>
>> NSOpenPanel * oPanel = [NSOpenPanel openPanel];
>> [oPanel setAllowsMultipleSelection:NO];
>> [oPanel setResolvesAliases: YES];
>> [oPanel setCanChooseDirectories: NO];
>> [oPanel setCanChooseFiles: YES];
>> NSArray *fileTypes = [NSArray arrayWithObjects: @"text",
>> @"TEXT", @"txt", @"TXT", @"fasta", @"FASTA", @"seq", @"SEQ",
>> @"html", @"HTML", @"htm", @"HTM", @"rtf", @"RTF", @"rtfd", @"RTFD",
>> @"gde", @"fas", @"nessig", @"pir", @"nona", @"phylip", @"nexus",
>> @"GDE", @"FAS", @"NESSIG", @"PIR", @"NONA", @"PHYLIP", @"NEXUS",
>> @"raw", @"clustal", @"pdb", @"embl", @"swissprot", @"NCBI", @"GCK",
>> @"RAW", @"CLUSTAL", @"PDB", @"EMBL", @"SWISSPROT", @"ncbi", @"gck",
>> @"aln", @"hen", @"fst", @"msf", @"nxs", @"non", @"phy", @"tnt",
>> @"ALN", @"HEN", @"FST", @"MSF", @"NXS", @"NON", @"PHY", @"TNT",
>> @"",
>> NSFileTypeForHFSTypeCode('TEXT'), NSFileTypeForHFSTypeCode('TXT
>> '), NSFileTypeForHFSTypeCode('text'),
>> NSFileTypeForHFSTypeCode('xDNA'), NSFileTypeForHFSTypeCode('DNA '),
>> NSFileTypeForHFSTypeCode('GCKc'), NSFileTypeForHFSTypeCode('GCKs'),
>> NSFileTypeForHFSTypeCode('NUCL'), nil];
>>
>> [oPanel beginSheetForDirectory: nil
>> file: nil
>> types: fileTypes
>> modalForWindow: [NSApp mainWindow]
>> modalDelegate: self
>> didEndSelector: @selector
>> (importPanelDidEnd:returnCode:contextInfo:)
>> contextInfo: nil];
>> }
>>
>>
>> - (void)importPanelDidEnd:(NSOpenPanel *)oPanel returnCode:(int)
>> returnCode contextInfo:(void *)contextInfo{
>>
>> if (returnCode == NSOKButton) {
>>
>> BCReader *reader = [[BCReader alloc]init];
>>
>> NS_DURING
>>
>> NSDictionary *dict = [reader readFile: [[oPanel filenames]
>> objectAtIndex: 0]];
>>
>> // In the future it would be nice to present a dialog to the user
>> // where he/she could choose which sequence to open in case the
>> file
>> // contains multiple sequences
>> if([[dict objectForKey: @"items"] count] > 0) {
>> NSString *name = [[dict objectForKey: @"items"]objectAtIndex: 0];
>> NSString *sequence = [[dict objectForKey: @"matrix"]
>> objectForKey: name];
>>
>> // do your stuff here with the obtained sequence...
>>
>> }
>>
>> NS_HANDLER
>> NSBeep();
>> NSString *title = @"Error Reading File";
>> NSString *defaultButton = @"OK";
>> NSString *alternateButton = nil;
>> NSString *otherButton = nil;
>> NSString *message = @"iRNAi could not read the selected file,
>> which might not be a sequence file or not of a format that EnzymeX
>> does not support. Try converting it to plain text or fasta format.
>> Alternatively, you can copy the sequence from its native
>> application.";
>>
>> NSRunAlertPanel(title, message, defaultButton,
>> alternateButton, otherButton);
>> NS_ENDHANDLER
>>
>> [BCReader release];
>> }
>> }
>>
>> The source code can be downloaded here:
>> http://www.mekentosj.com/biococoa/BCStandaloneReader.zip
>>
>>
>> Hey, but wait, that's not all!
>> In 4Peaks I used James S. Derry's JSDTextView to display sequences
>> in a TextView with linenumbers. James had received a lot of help
>> from Koen, who basically figured out how to do all this.
>> Unfortunately, in OSX 10.4 Tiger this textview shows a weird
>> drawing bug so I had to go on the look out for alternatives. And
>> guess what, Koen actually had posted some sample code himself as
>> well, which was actually a much more elegant solution. So I used
>> his KDTextView in 4Peaks.
>> For iRNAi 2 and EnzymeX 3 I decided to pimp Koen's textview a bit
>> more and added a number of interesting new features:
>> - better support for printing
>> - the mouse location and selections are shown using fancy semi-
>> transparent overlays
>> - added columnspacing support in the textcontainer class: instead
>> of xxxxxxxxxxxxxxxxx now: xxxxx xxxxx xxxxx , without introducing
>> spaces in the text, so copy/paste, drag and drop, selections etc
>> all work without having to think about spacing.
>>
>> Check out iRNAi 2 for a demo (http://www.mekentosj.com/irnai )
>> It isn't completely ready yet to release it, but once I've
>> finished EnzymeX 3, I'll post it and let you guys know. Thanks
>> Koen for the excellent foundation!
>>
>> Enjoy!
>> Cheers,
>> Alex
>>
>>
>> Ps. Peter kudos on the new stuff your doing and congratulations
>> with Orbicule, it seems a very successful launch and although not
>> so much biology, cool product you created!! Didn't have time to
>> write you this before, but "petje af!" Are you now fulltime doing
>> that?
>>
>> *********************************************************
>> ** Alexander Griekspoor **
>> *********************************************************
>> The Netherlands Cancer Institute
>> Department of Tumorbiology (H4)
>> Plesmanlaan 121, 1066 CX, Amsterdam
>> Tel: + 31 20 - 512 2023
>> Fax: + 31 20 - 512 2029
>> AIM: mekentosj at mac.com
>> E-mail: a.griekspoor at nki.nl
>> Web: http://www.mekentosj.com
>>
>> 4Peaks - For Peaks, Four Peaks.
>> 2004 Winner of the Apple Design Awards
>> Best Mac OS X Student Product
>> http://www.mekentosj.com/4peaks
>>
>> *********************************************************
>>
>> _______________________________________________
>> Biococoa-dev mailing list
>> Biococoa-dev at bioinformatics.org
>> https://bioinformatics.org/mailman/listinfo/biococoa-dev
>
> --
> Xgrid-at-Stanford
> Help science move fast forward:
> http://cmgm.stanford.edu/~cparnot/xgrid-stanford
>
> Charles Parnot
> charles.parnot at gmail.com
>
>
>
>
> _______________________________________________
> Biococoa-dev mailing list
> Biococoa-dev at bioinformatics.org
> https://bioinformatics.org/mailman/listinfo/biococoa-dev
>
*********************************************************
** Alexander Griekspoor **
*********************************************************
The Netherlands Cancer Institute
Department of Tumorbiology (H4)
Plesmanlaan 121, 1066 CX, Amsterdam
Tel: + 31 20 - 512 2023
Fax: + 31 20 - 512 2029
AIM: mekentosj at mac.com
E-mail: a.griekspoor at nki.nl
Web: http://www.mekentosj.com
Windows is a 32-bit patch to a 16-bit shell for an 8-bit
operating system, written for a 4-bit processor by a 2-
bit company without 1 bit of sense.
*********************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.bioinformatics.org/pipermail/biococoa-dev/attachments/20060303/5138a392/attachment.html>
More information about the Biococoa-dev
mailing list