Saving multiple sequences contained in a linked list.

Brooks Mark brooks at embl-grenoble.fr
Mon Aug 26 17:44:06 UTC 2002


A quick teaser for those interested in testing their grey matter...

Can anyone spot the mistake in the following function please?  Actually,
I can't do it, that's why I'm asking ;-)!
...actually, there may be many mistakes, but as I try and traverse this
linked list (by moving to list->next) and save each sequence  in turn,
all I do in the end is save the first sequence as many times as there
are items in the list.

Here is the offending code
=====================================================

void real_export_all(GtkWidget * app, gchar * filename)
{
        GList *list;
        AjPStr seqfilename, seq_formatstr;
        AjPSeqout seqoutname;
        SeqListItem *seq_list_item;
        GNode *node;

        seqfilename = ajStrNewC("/tmp/wibble.fas");
        seq_formatstr = ajStrNewC("fasta");
        seqoutname = ajSeqoutNew();
        (void) ajSeqFileNewOut(seqoutname, seqfilename);

        for (list = trees ; list != NULL ; list = list->next){
                node = trees->data;
                seq_list_item = node->data;
                (void) ajSeqOutSetFormat(seqoutname, seq_formatstr);
                ajSeqAllWrite(seqoutname, seq_list_item->seq);
        }
        (void) ajSeqWriteClose(seqoutname);
        return;
}
========================================
and a SeqListItem is just this (for now)
========================================
typedef struct _SeqListItem SeqListItem;
struct _SeqListItem {
        AjPSeq seq;
        gint frame;
};
==========================================
"trees" is a global variable (ugh) of type GList.
==========================================


If you feel you need more information, you can always browse the cvs for
the entire program at
the  Sourceforge page....
http://sourceforge.net/projects/gnome-emboss/
........to browse the CVS...
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/gnome-emboss
........to see it in action at the web page...
http://gnome-emboss.sourceforge.net/
(which is very incomplete!).
or to download and try and build the thing (I think ssh is required, but
not sure on this one)
cvs
-d:pserver:anonymous at cvs.gnome-emboss.sourceforge.net:/cvsroot/gnome-emboss
login

cvs -z3
-d:pserver:anonymous at cvs.gnome-emboss.sourceforge.net:/cvsroot/gnome-emboss
co gnome-emboss

(Requires libxml, gnome, glade, libglade, auto(make,conf, etc.), the
usual suspects).

Any comments on anything related are more than welcome.
Sorry if this is a stupid question- I'm not great at programming yet!


Mark.

P.S.    Yes, it is a rip off of GDE, without as much functionality.

P.P.S.    By the way, the program's name is _not_ going to stay as "Gnome-EMBOSS" (I hope it doesn't cause offence in Cambs. that I even use EMBOSS in the name) for long; we're having a competition here

to come up with something better.  An average user would have no idea what Gnome-EMBOSS would do!

The leading contender for the name is currently: "DNAvigator" (despite potential confusion with Netscape Navigator, this is the best we've done).

If you have something better you could win a crate of beer.....

--
Mark Brooks,
EMBL Grenoble Outstation,
6, rue Jules Horowitz, BP181
38042 Grenoble Cedex 9, France.
Tel: + (0)4 76 20 72 85






More information about the emboss-dev mailing list