Skip to content
Browse files

added extensions

svn path=/bioperl-ext/branches/ewan/; revision=620
  • Loading branch information...
0 parents commit cab3ef9de554774c998be081aed74043b80e1842 birney committed Sep 16, 1999
Sorry, we could not display the entire diff because it was too big.
51 Bio/Ext/Align/Align.pm
@@ -0,0 +1,51 @@
+
+
+
+package Bio::Ext::Align;
+
+use vars qw($AUTOLOAD @ISA @EXPORT_OK $dl_debug);
+use Exporter;
+use Carp;
+use strict;
+
+use DynaLoader;
+
+
+@ISA = qw(Exporter DynaLoader);
+# Items to export into callers namespace by default. Note: do not export
+# names by default without a very good reason. Use EXPORT_OK instead.
+# Do not simply export all your public functions/methods/constants.
+
+sub AUTOLOAD {
+ # This AUTOLOAD is used to 'autoload' constants from the constant()
+ # XS function. If a constant is not found then control is passed
+ # to the AUTOLOAD in AutoLoader.
+
+ my $constname;
+ ($constname = $AUTOLOAD) =~ s/.*:://;
+ my $val = constant($constname, @_ ? $_[0] : 0);
+ if ($! != 0) {
+ if ($! =~ /Invalid/) {
+ $AutoLoader::AUTOLOAD = $AUTOLOAD;
+ goto &AutoLoader::AUTOLOAD;
+ }
+ else {
+ croak "Your vendor has not defined Test macro $constname";
+ }
+ }
+ eval "sub $AUTOLOAD { $val }";
+ goto &$AUTOLOAD;
+}
+
+BEGIN {
+ $dl_debug = 40;
+}
+
+bootstrap Bio::Ext::Align; # hopefully has the correct things...
+
+# Preloaded methods go here.
+
+# Autoload methods go after __END__, and are processed by the autosplit program.
+
+1;
+__END__
3,313 Bio/Ext/Align/Align.xs
3,313 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
21 Bio/Ext/Align/Makefile.PL
@@ -0,0 +1,21 @@
+use ExtUtils::MakeMaker;
+# See lib/ExtUtils/MakeMaker.pm for details of how to influence
+# the contents of the Makefile that is written.
+WriteMakefile(
+ 'NAME' => 'Bio::Ext::Align',
+ 'VERSION' => '0.1',
+ 'LIBS' => ['-lm'], # e.g., '-lm'
+ 'DEFINE' => '-DPOSIX -DNOERROR', # e.g., '-DHAVE_SOMETHING'
+ 'INC' => '-I./libs', # e.g., '-I/usr/include/other'
+ 'MYEXTLIB' => 'libs/libsw$(LIB_EXT)',
+ 'clean' => { 'FILES' => 'libs/*.o libs/*.a' }
+);
+
+sub MY::postamble{
+'
+$(MYEXTLIB):
+ DEFINE=\'$(DEFINE)\'; CC=\'$(PERLMAINCC)\'; export DEFINE INC CC; \
+ cd libs && $(MAKE) CC=$(CC) libsw$(LIB_EXT) -e
+
+';
+}
31 Bio/Ext/Align/blosum62.bla
@@ -0,0 +1,31 @@
+# Matrix made by matblas from blosum62.iij
+# * column uses minimum score
+# BLOSUM Clustered Scoring Matrix in 1/2 Bit Units
+# Blocks Database = /data/blocks_5.0/blocks.dat
+# Cluster Percentage: >= 62
+# Entropy = 0.6979, Expected = -0.5209
+ A R N D C Q E G H I L K M F P S T W Y V B Z X *
+ 4 -1 -2 -2 0 -1 -1 0 -2 -1 -1 -1 -1 -2 -1 1 0 -3 -2 0 -2 -1 0 -4
+-1 5 0 -2 -3 1 0 -2 0 -3 -2 2 -1 -3 -2 -1 -1 -3 -2 -3 -1 0 -1 -4
+-2 0 6 1 -3 0 0 0 1 -3 -3 0 -2 -3 -2 1 0 -4 -2 -3 3 0 -1 -4
+-2 -2 1 6 -3 0 2 -1 -1 -3 -4 -1 -3 -3 -1 0 -1 -4 -3 -3 4 1 -1 -4
+ 0 -3 -3 -3 9 -3 -4 -3 -3 -1 -1 -3 -1 -2 -3 -1 -1 -2 -2 -1 -3 -3 -2 -4
+-1 1 0 0 -3 5 2 -2 0 -3 -2 1 0 -3 -1 0 -1 -2 -1 -2 0 3 -1 -4
+-1 0 0 2 -4 2 5 -2 0 -3 -3 1 -2 -3 -1 0 -1 -3 -2 -2 1 4 -1 -4
+ 0 -2 0 -1 -3 -2 -2 6 -2 -4 -4 -2 -3 -3 -2 0 -2 -2 -3 -3 -1 -2 -1 -4
+-2 0 1 -1 -3 0 0 -2 8 -3 -3 -1 -2 -1 -2 -1 -2 -2 2 -3 0 0 -1 -4
+-1 -3 -3 -3 -1 -3 -3 -4 -3 4 2 -3 1 0 -3 -2 -1 -3 -1 3 -3 -3 -1 -4
+-1 -2 -3 -4 -1 -2 -3 -4 -3 2 4 -2 2 0 -3 -2 -1 -2 -1 1 -4 -3 -1 -4
+-1 2 0 -1 -3 1 1 -2 -1 -3 -2 5 -1 -3 -1 0 -1 -3 -2 -2 0 1 -1 -4
+-1 -1 -2 -3 -1 0 -2 -3 -2 1 2 -1 5 0 -2 -1 -1 -1 -1 1 -3 -1 -1 -4
+-2 -3 -3 -3 -2 -3 -3 -3 -1 0 0 -3 0 6 -4 -2 -2 1 3 -1 -3 -3 -1 -4
+-1 -2 -2 -1 -3 -1 -1 -2 -2 -3 -3 -1 -2 -4 7 -1 -1 -4 -3 -2 -2 -1 -2 -4
+ 1 -1 1 0 -1 0 0 0 -1 -2 -2 0 -1 -2 -1 4 1 -3 -2 -2 0 0 0 -4
+ 0 -1 0 -1 -1 -1 -1 -2 -2 -1 -1 -1 -1 -2 -1 1 5 -2 -2 0 -1 -1 0 -4
+-3 -3 -4 -4 -2 -2 -3 -2 -2 -3 -2 -3 -1 1 -4 -3 -2 11 2 -3 -4 -3 -2 -4
+-2 -2 -2 -3 -2 -1 -2 -3 2 -1 -1 -2 -1 3 -3 -2 -2 2 7 -1 -3 -2 -1 -4
+ 0 -3 -3 -3 -1 -2 -2 -3 -3 3 1 -2 1 -1 -2 -2 0 -3 -1 4 -3 -2 -1 -4
+-2 -1 3 4 -3 0 1 -1 0 -3 -4 0 -3 -3 -2 0 -1 -4 -3 -3 4 1 -1 -4
+-1 0 0 1 -3 3 4 -2 0 -3 -3 1 -1 -3 -1 0 -1 -3 -2 -2 1 4 -1 -4
+ 0 -1 -1 -1 -2 -1 -1 -1 -1 -1 -1 -1 -1 -1 -2 0 0 -2 -1 -1 -1 -1 -1 -4
+-4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 1
2,587 Bio/Ext/Align/libs/aln.c
2,587 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
977 Bio/Ext/Align/libs/aln.h
@@ -0,0 +1,977 @@
+#ifndef DYNAMITEalnHEADERFILE
+#define DYNAMITEalnHEADERFILE
+#ifdef _cplusplus
+extern "C" {
+#endif
+#include "wisebase.h"
+#include "probability.h"
+
+
+#define AlnColumnLISTLENGTH 32
+#define AlnBlockLISTLENGTH 32
+#define AlnBlockListLISTLENGTH 32
+
+#define AlnUnitSCORENUMBER 8
+
+#ifndef DYNAMITE_DEFINED_AlnColumn
+typedef struct bp_sw_AlnColumn bp_sw_AlnColumn;
+#define AlnColumn bp_sw_AlnColumn
+#define DYNAMITE_DEFINED_AlnColumn
+#endif
+
+#ifndef DYNAMITE_DEFINED_AlnUnit
+typedef struct bp_sw_AlnUnit bp_sw_AlnUnit;
+#define AlnUnit bp_sw_AlnUnit
+#define DYNAMITE_DEFINED_AlnUnit
+#endif
+
+#ifndef DYNAMITE_DEFINED_AlnSequence
+typedef struct bp_sw_AlnSequence bp_sw_AlnSequence;
+#define AlnSequence bp_sw_AlnSequence
+#define DYNAMITE_DEFINED_AlnSequence
+#endif
+
+/* Object AlnUnit
+ *
+ * Descrip: This is the basic unit of the label alignment.
+ * It describes a single mark-up over one sequence:
+ * being a start, an end and a text_label.
+ *
+ *
+ */
+struct bp_sw_AlnUnit {
+ int dynamite_hard_link;
+ int start; /* start position in the sequence */
+ int end; /* end position in the sequence */
+ int label; /* not used */
+ char * text_label; /* text label of this position */
+ AlnUnit * next; /* next AlnUnit in this sequence */
+ int score[AlnUnitSCORENUMBER]; /* a series of scores for this position. */
+ boolean in_column; /* not used */
+ AlnSequence * seq;
+ } ;
+/* AlnUnit defined */
+#ifndef DYNAMITE_DEFINED_AlnUnit
+typedef struct bp_sw_AlnUnit bp_sw_AlnUnit;
+#define AlnUnit bp_sw_AlnUnit
+#define DYNAMITE_DEFINED_AlnUnit
+#endif
+
+
+/* Object AlnColumn
+ *
+ * Descrip: This is a coupling of AlnUnits from different sequences.
+ * Each AlnUnit is meant to represent *the equivalent* piece
+ * of biological information in some sense (ie, they are
+ * alignmed), even though quite possibly they are very
+ * different types of information
+ *
+ *
+ */
+struct bp_sw_AlnColumn {
+ int dynamite_hard_link;
+ AlnUnit ** alu; /* list of the AlnUnits in this column */
+ int len;/* len for above alu */
+ int maxlen; /* maxlen for above alu */
+ AlnColumn * next; /* the next AlnColumn in this block */
+ } ;
+/* AlnColumn defined */
+#ifndef DYNAMITE_DEFINED_AlnColumn
+typedef struct bp_sw_AlnColumn bp_sw_AlnColumn;
+#define AlnColumn bp_sw_AlnColumn
+#define DYNAMITE_DEFINED_AlnColumn
+#endif
+
+
+/* Object AlnSequence
+ *
+ * Descrip: Each Sequence in an AlnBlock is represented by one of these, and
+ * in many ways this is an orthogonal way of looking at the alignment
+ * than the AlnColumns. If you look at the alignment from one
+ * AlnSequence you will just see the individual labels on this
+ * sequence
+ *
+ *
+ */
+struct bp_sw_AlnSequence {
+ int dynamite_hard_link;
+ AlnUnit * start; /* the first AlnUnit of this sequence */
+ int data_type; /* not used */
+ void * data; /* not used - don't use! */
+ int bio_start; /* start of this sequence in its 'bio' coordinates */
+ int bio_end; /* end of this sequence in its 'bio' coordinates */
+ } ;
+/* AlnSequence defined */
+#ifndef DYNAMITE_DEFINED_AlnSequence
+typedef struct bp_sw_AlnSequence bp_sw_AlnSequence;
+#define AlnSequence bp_sw_AlnSequence
+#define DYNAMITE_DEFINED_AlnSequence
+#endif
+
+
+/* Object AlnBlock
+ *
+ * Descrip: AlnBlock is the main representation of alignments from Dynamite. Each
+ * AlnBlock represents any number of 'sequences', of any type, which share
+ * things in common. The alignment is represented by a series of /AlnColumns
+ * (linked list) in which each AlnColumn has a series of AlnUnits, each
+ * Unit being a start/end/text_label triple. Alternatively, one can see
+ * each sequence in isolation, and not ask what it is aligned to, but rather
+ * what labels it has on it.
+ *
+ *
+ */
+struct bp_sw_AlnBlock {
+ int dynamite_hard_link;
+ AlnColumn * start; /* the first AlnColumn in the alignment */
+ AlnSequence ** seq; /* a list of AlnSequences in the alignment */
+ int len;/* len for above seq */
+ int maxlen; /* maxlen for above seq */
+ int length; /* not used */
+ int score; /* not used */
+ } ;
+/* AlnBlock defined */
+#ifndef DYNAMITE_DEFINED_AlnBlock
+typedef struct bp_sw_AlnBlock bp_sw_AlnBlock;
+#define AlnBlock bp_sw_AlnBlock
+#define DYNAMITE_DEFINED_AlnBlock
+#endif
+
+
+/* Object AlnBlockList
+ *
+ * Descrip: No Description
+ *
+ */
+struct bp_sw_AlnBlockList {
+ int dynamite_hard_link;
+ AlnBlock ** alb;
+ int len;/* len for above alb */
+ int maxlen; /* maxlen for above alb */
+ } ;
+/* AlnBlockList defined */
+#ifndef DYNAMITE_DEFINED_AlnBlockList
+typedef struct bp_sw_AlnBlockList bp_sw_AlnBlockList;
+#define AlnBlockList bp_sw_AlnBlockList
+#define DYNAMITE_DEFINED_AlnBlockList
+#endif
+
+
+
+
+ /***************************************************/
+ /* Callable functions */
+ /* These are the functions you are expected to use */
+ /***************************************************/
+
+
+
+/* Function: at_end_AlnColumn(alc)
+ *
+ * Descrip: This tells you whether the AlnColumn is at the
+ * end without passing NULL's around
+ *
+ *
+ *
+ * Arg: alc [READ ] AlnColumn [AlnColumn *]
+ *
+ * Return [UNKN ] Undocumented return value [boolean]
+ *
+ */
+boolean bp_sw_at_end_AlnColumn(AlnColumn * alc);
+#define at_end_AlnColumn bp_sw_at_end_AlnColumn
+
+
+/* Function: bio_start_AlnUnit(alu)
+ *
+ * Descrip: Tells the bio-coordinate of the
+ * start point of this alnunit
+ *
+ *
+ * Arg: alu [UNKN ] Undocumented argument [AlnUnit *]
+ *
+ * Return [UNKN ] Undocumented return value [int]
+ *
+ */
+int bp_sw_bio_start_AlnUnit(AlnUnit * alu);
+#define bio_start_AlnUnit bp_sw_bio_start_AlnUnit
+
+
+/* Function: bio_end_AlnUnit(alu)
+ *
+ * Descrip: Tells the bio-coordinate of the
+ * end point of this alnunit
+ *
+ *
+ * Arg: alu [UNKN ] Undocumented argument [AlnUnit *]
+ *
+ * Return [UNKN ] Undocumented return value [int]
+ *
+ */
+int bp_sw_bio_end_AlnUnit(AlnUnit * alu);
+#define bio_end_AlnUnit bp_sw_bio_end_AlnUnit
+
+
+/* Function: swallow_AlnColumn_multiple(master,eaten,comp_func)
+ *
+ * Descrip: This function will 'swallow' any number of AlnColumns as long
+ * as the comparison function of the labels match (the basic
+ * comp function would be something like strcmp(a,b) == 0 ? TRUE : FALSE)
+ * The columns are 'swallowed' into master and come from eaten. (these
+ * columns could be in the same linked list, though it only makes sense
+ * if the master is before the eaten).
+ *
+ * It returns the first column that it could not swallow.
+ *
+ * you use this to collapse regions of the label alignment.
+ *
+ *
+ * Arg: master [UNKN ] column which will eat other columns [AlnColumn *]
+ * Arg: eaten [UNKN ] column which will be consumed [AlnColumn *]
+ * Arg: comp_func [FUNCP] comparison function for label set [boolean (*comp_func]
+ *
+ * Return [UNKN ] Undocumented return value [AlnColumn *]
+ *
+ */
+AlnColumn * bp_sw_swallow_AlnColumn_multiple(AlnColumn * master,AlnColumn * eaten,boolean (*comp_func)(char *,char *));
+#define swallow_AlnColumn_multiple bp_sw_swallow_AlnColumn_multiple
+
+
+/* Function: swallow_AlnColumn_number(master,eaten,num,comp_func)
+ *
+ * Descrip: Basicaly the same as /swallow_AlnColumn_mulitple but there is a maximum number
+ * of columns it will swallow
+ *
+ *
+ * Arg: master [UNKN ] column which will eat other columns [AlnColumn *]
+ * Arg: eaten [UNKN ] column which will be consumed [AlnColumn *]
+ * Arg: num [UNKN ] max number of columns to eat [int]
+ * Arg: comp_func [FUNCP] comparison function for label set [boolean (*comp_func]
+ *
+ * Return [UNKN ] number of columns eaten [int]
+ *
+ */
+int bp_sw_swallow_AlnColumn_number(AlnColumn * master,AlnColumn * eaten,int num,boolean (*comp_func)(char *,char *));
+#define swallow_AlnColumn_number bp_sw_swallow_AlnColumn_number
+
+
+/* Function: swallow_AlnColumn(master,eaten,comp_func)
+ *
+ * Descrip: This is the function that actually does the 'swallowing'. It will
+ * try to swallow eaten into master. If comp_func does not give us an
+ * ok (actually using /can_swallow_AlnColumn it returns FALSE. Otherwise
+ * it moves on the end of AlnColumn in master to eaten and adds the
+ * score of eaten to master.
+ *
+ *
+ * Arg: master [UNKN ] column which will eat [AlnColumn *]
+ * Arg: eaten [UNKN ] column which will dissappear into master if eatable [AlnColumn *]
+ * Arg: comp_func [FUNCP] comparison function for labels [boolean (*comp_func]
+ *
+ * Return [UNKN ] Undocumented return value [boolean]
+ *
+ */
+boolean bp_sw_swallow_AlnColumn(AlnColumn * master,AlnColumn * eaten,boolean (*comp_func)(char *,char *));
+#define swallow_AlnColumn bp_sw_swallow_AlnColumn
+
+
+/* Function: replace_and_free_AlnColumn_with_one(start,end,insert)
+ *
+ * Descrip: Linked list manipulation function
+ *
+ * Puts insert between start and end, and free's from start->next
+ * onwards. *Beware* if start is linked to end before calling this
+ * function thsi wil free end and everything chained to it. Think
+ * before you call this!
+ *
+ *
+ * Arg: start [UNKN ] Undocumented argument [AlnColumn *]
+ * Arg: end [UNKN ] Undocumented argument [AlnColumn *]
+ * Arg: insert [UNKN ] Undocumented argument [AlnColumn *]
+ *
+ */
+void bp_sw_replace_and_free_AlnColumn_with_one(AlnColumn * start,AlnColumn * end,AlnColumn * insert);
+#define replace_and_free_AlnColumn_with_one bp_sw_replace_and_free_AlnColumn_with_one
+
+
+/* Function: replace_AlnColumn_with_one(start,end,insert)
+ *
+ * Descrip: Linked list manipulation function
+ *
+ * places insert between start and end. If start/end are not
+ * continuous then it will loop out the start/end region
+ *
+ *
+ * Arg: start [UNKN ] Undocumented argument [AlnColumn *]
+ * Arg: end [UNKN ] Undocumented argument [AlnColumn *]
+ * Arg: insert [UNKN ] Undocumented argument [AlnColumn *]
+ *
+ */
+void bp_sw_replace_AlnColumn_with_one(AlnColumn * start,AlnColumn * end,AlnColumn * insert);
+#define replace_AlnColumn_with_one bp_sw_replace_AlnColumn_with_one
+
+
+/* Function: insert_AlnColumn(start,insert)
+ *
+ * Descrip: Linked list manipulation function
+ *
+ * places insert just after start: links insert
+ * up to what start was linked to
+ *
+ *
+ * Arg: start [UNKN ] Undocumented argument [AlnColumn *]
+ * Arg: insert [UNKN ] Undocumented argument [AlnColumn *]
+ *
+ */
+void bp_sw_insert_AlnColumn(AlnColumn * start,AlnColumn * insert);
+#define insert_AlnColumn bp_sw_insert_AlnColumn
+
+
+/* Function: go_back_n_AlnColumn(alb,start,n)
+ *
+ * Descrip: Linked list movement function
+ *
+ * A nasty function to reverse up a singly linked list by going to
+ * the start and coming back until you are in the current position. yuk.
+ *
+ *
+ * Arg: alb [UNKN ] Undocumented argument [AlnBlock *]
+ * Arg: start [UNKN ] Undocumented argument [AlnColumn *]
+ * Arg: n [UNKN ] Undocumented argument [int]
+ *
+ * Return [UNKN ] Undocumented return value [AlnColumn *]
+ *
+ */
+AlnColumn * bp_sw_go_back_n_AlnColumn(AlnBlock * alb,AlnColumn * start,int n);
+#define go_back_n_AlnColumn bp_sw_go_back_n_AlnColumn
+
+
+/* Function: dump_ascii_AlnBlock(alb,ofp)
+ *
+ * Descrip: Dumps the alignment in rereadable ascii form.
+ *
+ * Not really for human consumption
+ *
+ *
+ * Arg: alb [UNKN ] AlnBlock to dump [AlnBlock *]
+ * Arg: ofp [UNKN ] File stream to dump to [FILE *]
+ *
+ */
+void bp_sw_dump_ascii_AlnBlock(AlnBlock * alb,FILE * ofp);
+#define dump_ascii_AlnBlock bp_sw_dump_ascii_AlnBlock
+
+
+/* Function: bit_ascii_AlnBlock(alb,ofp)
+ *
+ * Descrip: Should not be here...
+ *
+ *
+ * Arg: alb [UNKN ] AlnBlock to dump [AlnBlock *]
+ * Arg: ofp [UNKN ] File stream to dump to [FILE *]
+ *
+ */
+void bp_sw_bit_ascii_AlnBlock(AlnBlock * alb,FILE * ofp);
+#define bit_ascii_AlnBlock bp_sw_bit_ascii_AlnBlock
+
+
+/* Function: read_ascii_dump_AlnBlock(ifp)
+ *
+ * Descrip: Reads an ascii dumped alignment
+ *
+ *
+ * Arg: ifp [UNKN ] File stream to read from [FILE *]
+ *
+ * Return [UNKN ] Undocumented return value [AlnBlock *]
+ *
+ */
+AlnBlock * bp_sw_read_ascii_dump_AlnBlock(FILE * ifp);
+#define read_ascii_dump_AlnBlock bp_sw_read_ascii_dump_AlnBlock
+
+
+/* Function: show_flat_AlnBlock(alb,ofp)
+ *
+ * Descrip: Shows the AlnBlock in vaguely human
+ * readable form
+ *
+ *
+ * Arg: alb [UNKN ] AlnBlock to show [AlnBlock *]
+ * Arg: ofp [UNKN ] output [FILE *]
+ *
+ */
+void bp_sw_show_flat_AlnBlock(AlnBlock * alb,FILE * ofp);
+#define show_flat_AlnBlock bp_sw_show_flat_AlnBlock
+
+
+/* Function: get_second_end_AlnColumn(alb)
+ *
+ * Descrip: Not sure if this is used!
+ *
+ *
+ * Arg: alb [UNKN ] Undocumented argument [AlnBlock *]
+ *
+ * Return [UNKN ] Undocumented return value [AlnColumn *]
+ *
+ */
+AlnColumn * bp_sw_get_second_end_AlnColumn(AlnBlock * alb);
+#define get_second_end_AlnColumn bp_sw_get_second_end_AlnColumn
+
+
+/* Function: get_end_AlnColumn(alb)
+ *
+ * Descrip: To get to the last AlnColumn. If this was
+ * a doubly linked list, life would be much easier
+ *
+ *
+ * Arg: alb [UNKN ] Undocumented argument [AlnBlock *]
+ *
+ * Return [UNKN ] Undocumented return value [AlnColumn *]
+ *
+ */
+AlnColumn * bp_sw_get_end_AlnColumn(AlnBlock * alb);
+#define get_end_AlnColumn bp_sw_get_end_AlnColumn
+
+
+/* Function: link_AlnUnits_AlnBlock(alb)
+ *
+ * Descrip: Links up all AlnUnits to their parent
+ * sequences
+ *
+ *
+ * Arg: alb [UNKN ] Undocumented argument [AlnBlock *]
+ *
+ * Return [UNKN ] Undocumented return value [boolean]
+ *
+ */
+boolean bp_sw_link_AlnUnits_AlnBlock(AlnBlock * alb);
+#define link_AlnUnits_AlnBlock bp_sw_link_AlnUnits_AlnBlock
+
+
+/* Function: new_pairwise_AlnColumn(void)
+ *
+ * Descrip: Function as a constructor for the special
+ * case of a pairwise alignment. Makes an
+ * AlnColumn and puts in two AlnUnits all ready
+ * to be linked in.
+ *
+ *
+ *
+ * Return [UNKN ] Undocumented return value [AlnColumn *]
+ *
+ */
+AlnColumn * bp_sw_new_pairwise_AlnColumn(void);
+#define new_pairwise_AlnColumn bp_sw_new_pairwise_AlnColumn
+
+
+/* Function: free_AlnColumn(obj)
+ *
+ * Descrip: Specilased deconstructor needed because
+ * of linked list nature of the data structure
+ *
+ *
+ * Arg: obj [UNKN ] Undocumented argument [AlnColumn *]
+ *
+ * Return [UNKN ] Undocumented return value [AlnColumn *]
+ *
+ */
+AlnColumn * bp_sw_free_AlnColumn(AlnColumn * obj);
+#define free_AlnColumn bp_sw_free_AlnColumn
+
+
+/* Function: free_AlnUnit(obj)
+ *
+ * Descrip: Specilased deconstructor needed because
+ * of linked list nature of the data structure
+ *
+ *
+ * Arg: obj [UNKN ] Undocumented argument [AlnUnit *]
+ *
+ * Return [UNKN ] Undocumented return value [AlnUnit *]
+ *
+ */
+AlnUnit * bp_sw_free_AlnUnit(AlnUnit * obj);
+#define free_AlnUnit bp_sw_free_AlnUnit
+
+
+/* Function: hard_link_AlnUnit(obj)
+ *
+ * Descrip: Bumps up the reference count of the object
+ * Meaning that multiple pointers can 'own' it
+ *
+ *
+ * Arg: obj [UNKN ] Object to be hard linked [AlnUnit *]
+ *
+ * Return [UNKN ] Undocumented return value [AlnUnit *]
+ *
+ */
+AlnUnit * bp_sw_hard_link_AlnUnit(AlnUnit * obj);
+#define hard_link_AlnUnit bp_sw_hard_link_AlnUnit
+
+
+/* Function: AlnUnit_alloc(void)
+ *
+ * Descrip: Allocates structure: assigns defaults if given
+ *
+ *
+ *
+ * Return [UNKN ] Undocumented return value [AlnUnit *]
+ *
+ */
+AlnUnit * bp_sw_AlnUnit_alloc(void);
+#define AlnUnit_alloc bp_sw_AlnUnit_alloc
+
+
+/* Function: add_AlnColumn(obj,add)
+ *
+ * Descrip: Adds another object to the list. It will expand the list if necessary
+ *
+ *
+ * Arg: obj [UNKN ] Object which contains the list [AlnColumn *]
+ * Arg: add [OWNER] Object to add to the list [AlnUnit *]
+ *
+ * Return [UNKN ] Undocumented return value [boolean]
+ *
+ */
+boolean bp_sw_add_AlnColumn(AlnColumn * obj,AlnUnit * add);
+#define add_AlnColumn bp_sw_add_AlnColumn
+
+
+/* Function: flush_AlnColumn(obj)
+ *
+ * Descrip: Frees the list elements, sets length to 0
+ * If you want to save some elements, use hard_link_xxx
+ * to protect them from being actually destroyed in the free
+ *
+ *
+ * Arg: obj [UNKN ] Object which contains the list [AlnColumn *]
+ *
+ * Return [UNKN ] Undocumented return value [int]
+ *
+ */
+int bp_sw_flush_AlnColumn(AlnColumn * obj);
+#define flush_AlnColumn bp_sw_flush_AlnColumn
+
+
+/* Function: AlnColumn_alloc_std(void)
+ *
+ * Descrip: Equivalent to AlnColumn_alloc_len(AlnColumnLISTLENGTH)
+ *
+ *
+ *
+ * Return [UNKN ] Undocumented return value [AlnColumn *]
+ *
+ */
+AlnColumn * bp_sw_AlnColumn_alloc_std(void);
+#define AlnColumn_alloc_std bp_sw_AlnColumn_alloc_std
+
+
+/* Function: AlnColumn_alloc_len(len)
+ *
+ * Descrip: Allocates len length to all lists
+ *
+ *
+ * Arg: len [UNKN ] Length of lists to allocate [int]
+ *
+ * Return [UNKN ] Undocumented return value [AlnColumn *]
+ *
+ */
+AlnColumn * bp_sw_AlnColumn_alloc_len(int len);
+#define AlnColumn_alloc_len bp_sw_AlnColumn_alloc_len
+
+
+/* Function: hard_link_AlnColumn(obj)
+ *
+ * Descrip: Bumps up the reference count of the object
+ * Meaning that multiple pointers can 'own' it
+ *
+ *
+ * Arg: obj [UNKN ] Object to be hard linked [AlnColumn *]
+ *
+ * Return [UNKN ] Undocumented return value [AlnColumn *]
+ *
+ */
+AlnColumn * bp_sw_hard_link_AlnColumn(AlnColumn * obj);
+#define hard_link_AlnColumn bp_sw_hard_link_AlnColumn
+
+
+/* Function: AlnColumn_alloc(void)
+ *
+ * Descrip: Allocates structure: assigns defaults if given
+ *
+ *
+ *
+ * Return [UNKN ] Undocumented return value [AlnColumn *]
+ *
+ */
+AlnColumn * bp_sw_AlnColumn_alloc(void);
+#define AlnColumn_alloc bp_sw_AlnColumn_alloc
+
+
+/* Function: hard_link_AlnSequence(obj)
+ *
+ * Descrip: Bumps up the reference count of the object
+ * Meaning that multiple pointers can 'own' it
+ *
+ *
+ * Arg: obj [UNKN ] Object to be hard linked [AlnSequence *]
+ *
+ * Return [UNKN ] Undocumented return value [AlnSequence *]
+ *
+ */
+AlnSequence * bp_sw_hard_link_AlnSequence(AlnSequence * obj);
+#define hard_link_AlnSequence bp_sw_hard_link_AlnSequence
+
+
+/* Function: AlnSequence_alloc(void)
+ *
+ * Descrip: Allocates structure: assigns defaults if given
+ *
+ *
+ *
+ * Return [UNKN ] Undocumented return value [AlnSequence *]
+ *
+ */
+AlnSequence * bp_sw_AlnSequence_alloc(void);
+#define AlnSequence_alloc bp_sw_AlnSequence_alloc
+
+
+/* Function: free_AlnSequence(obj)
+ *
+ * Descrip: Free Function: removes the memory held by obj
+ * Will chain up to owned members and clear all lists
+ *
+ *
+ * Arg: obj [UNKN ] Object that is free'd [AlnSequence *]
+ *
+ * Return [UNKN ] Undocumented return value [AlnSequence *]
+ *
+ */
+AlnSequence * bp_sw_free_AlnSequence(AlnSequence * obj);
+#define free_AlnSequence bp_sw_free_AlnSequence
+
+
+/* Function: add_AlnBlock(obj,add)
+ *
+ * Descrip: Adds another object to the list. It will expand the list if necessary
+ *
+ *
+ * Arg: obj [UNKN ] Object which contains the list [AlnBlock *]
+ * Arg: add [OWNER] Object to add to the list [AlnSequence *]
+ *
+ * Return [UNKN ] Undocumented return value [boolean]
+ *
+ */
+boolean bp_sw_add_AlnBlock(AlnBlock * obj,AlnSequence * add);
+#define add_AlnBlock bp_sw_add_AlnBlock
+
+
+/* Function: flush_AlnBlock(obj)
+ *
+ * Descrip: Frees the list elements, sets length to 0
+ * If you want to save some elements, use hard_link_xxx
+ * to protect them from being actually destroyed in the free
+ *
+ *
+ * Arg: obj [UNKN ] Object which contains the list [AlnBlock *]
+ *
+ * Return [UNKN ] Undocumented return value [int]
+ *
+ */
+int bp_sw_flush_AlnBlock(AlnBlock * obj);
+#define flush_AlnBlock bp_sw_flush_AlnBlock
+
+
+/* Function: AlnBlock_alloc_std(void)
+ *
+ * Descrip: Equivalent to AlnBlock_alloc_len(AlnBlockLISTLENGTH)
+ *
+ *
+ *
+ * Return [UNKN ] Undocumented return value [AlnBlock *]
+ *
+ */
+AlnBlock * bp_sw_AlnBlock_alloc_std(void);
+#define AlnBlock_alloc_std bp_sw_AlnBlock_alloc_std
+
+
+/* Function: AlnBlock_alloc_len(len)
+ *
+ * Descrip: Allocates len length to all lists
+ *
+ *
+ * Arg: len [UNKN ] Length of lists to allocate [int]
+ *
+ * Return [UNKN ] Undocumented return value [AlnBlock *]
+ *
+ */
+AlnBlock * bp_sw_AlnBlock_alloc_len(int len);
+#define AlnBlock_alloc_len bp_sw_AlnBlock_alloc_len
+
+
+/* Function: hard_link_AlnBlock(obj)
+ *
+ * Descrip: Bumps up the reference count of the object
+ * Meaning that multiple pointers can 'own' it
+ *
+ *
+ * Arg: obj [UNKN ] Object to be hard linked [AlnBlock *]
+ *
+ * Return [UNKN ] Undocumented return value [AlnBlock *]
+ *
+ */
+AlnBlock * bp_sw_hard_link_AlnBlock(AlnBlock * obj);
+#define hard_link_AlnBlock bp_sw_hard_link_AlnBlock
+
+
+/* Function: AlnBlock_alloc(void)
+ *
+ * Descrip: Allocates structure: assigns defaults if given
+ *
+ *
+ *
+ * Return [UNKN ] Undocumented return value [AlnBlock *]
+ *
+ */
+AlnBlock * bp_sw_AlnBlock_alloc(void);
+#define AlnBlock_alloc bp_sw_AlnBlock_alloc
+
+
+/* Function: free_AlnBlock(obj)
+ *
+ * Descrip: Free Function: removes the memory held by obj
+ * Will chain up to owned members and clear all lists
+ *
+ *
+ * Arg: obj [UNKN ] Object that is free'd [AlnBlock *]
+ *
+ * Return [UNKN ] Undocumented return value [AlnBlock *]
+ *
+ */
+AlnBlock * bp_sw_free_AlnBlock(AlnBlock * obj);
+#define free_AlnBlock bp_sw_free_AlnBlock
+
+
+/* Function: add_AlnBlockList(obj,add)
+ *
+ * Descrip: Adds another object to the list. It will expand the list if necessary
+ *
+ *
+ * Arg: obj [UNKN ] Object which contains the list [AlnBlockList *]
+ * Arg: add [OWNER] Object to add to the list [AlnBlock *]
+ *
+ * Return [UNKN ] Undocumented return value [boolean]
+ *
+ */
+boolean bp_sw_add_AlnBlockList(AlnBlockList * obj,AlnBlock * add);
+#define add_AlnBlockList bp_sw_add_AlnBlockList
+
+
+/* Function: flush_AlnBlockList(obj)
+ *
+ * Descrip: Frees the list elements, sets length to 0
+ * If you want to save some elements, use hard_link_xxx
+ * to protect them from being actually destroyed in the free
+ *
+ *
+ * Arg: obj [UNKN ] Object which contains the list [AlnBlockList *]
+ *
+ * Return [UNKN ] Undocumented return value [int]
+ *
+ */
+int bp_sw_flush_AlnBlockList(AlnBlockList * obj);
+#define flush_AlnBlockList bp_sw_flush_AlnBlockList
+
+
+/* Function: AlnBlockList_alloc_std(void)
+ *
+ * Descrip: Equivalent to AlnBlockList_alloc_len(AlnBlockListLISTLENGTH)
+ *
+ *
+ *
+ * Return [UNKN ] Undocumented return value [AlnBlockList *]
+ *
+ */
+AlnBlockList * bp_sw_AlnBlockList_alloc_std(void);
+#define AlnBlockList_alloc_std bp_sw_AlnBlockList_alloc_std
+
+
+/* Function: AlnBlockList_alloc_len(len)
+ *
+ * Descrip: Allocates len length to all lists
+ *
+ *
+ * Arg: len [UNKN ] Length of lists to allocate [int]
+ *
+ * Return [UNKN ] Undocumented return value [AlnBlockList *]
+ *
+ */
+AlnBlockList * bp_sw_AlnBlockList_alloc_len(int len);
+#define AlnBlockList_alloc_len bp_sw_AlnBlockList_alloc_len
+
+
+/* Function: hard_link_AlnBlockList(obj)
+ *
+ * Descrip: Bumps up the reference count of the object
+ * Meaning that multiple pointers can 'own' it
+ *
+ *
+ * Arg: obj [UNKN ] Object to be hard linked [AlnBlockList *]
+ *
+ * Return [UNKN ] Undocumented return value [AlnBlockList *]
+ *
+ */
+AlnBlockList * bp_sw_hard_link_AlnBlockList(AlnBlockList * obj);
+#define hard_link_AlnBlockList bp_sw_hard_link_AlnBlockList
+
+
+/* Function: AlnBlockList_alloc(void)
+ *
+ * Descrip: Allocates structure: assigns defaults if given
+ *
+ *
+ *
+ * Return [UNKN ] Undocumented return value [AlnBlockList *]
+ *
+ */
+AlnBlockList * bp_sw_AlnBlockList_alloc(void);
+#define AlnBlockList_alloc bp_sw_AlnBlockList_alloc
+
+
+/* Function: free_AlnBlockList(obj)
+ *
+ * Descrip: Free Function: removes the memory held by obj
+ * Will chain up to owned members and clear all lists
+ *
+ *
+ * Arg: obj [UNKN ] Object that is free'd [AlnBlockList *]
+ *
+ * Return [UNKN ] Undocumented return value [AlnBlockList *]
+ *
+ */
+AlnBlockList * bp_sw_free_AlnBlockList(AlnBlockList * obj);
+#define free_AlnBlockList bp_sw_free_AlnBlockList
+
+
+ /* Unplaced functions */
+ /* There has been no indication of the use of these functions */
+
+
+ /***************************************************/
+ /* Internal functions */
+ /* you are not expected to have to call these */
+ /***************************************************/
+int bp_sw_length_seq_AlnBlock(AlnBlock * obj);
+#define length_seq_AlnBlock bp_sw_length_seq_AlnBlock
+AlnUnit * bp_sw_access_alu_AlnColumn(AlnColumn * obj,int i);
+#define access_alu_AlnColumn bp_sw_access_alu_AlnColumn
+int bp_sw_length_alu_AlnColumn(AlnColumn * obj);
+#define length_alu_AlnColumn bp_sw_length_alu_AlnColumn
+int bp_sw_access_start_AlnUnit(AlnUnit * obj);
+#define access_start_AlnUnit bp_sw_access_start_AlnUnit
+int bp_sw_access_bio_end_AlnSequence(AlnSequence * obj);
+#define access_bio_end_AlnSequence bp_sw_access_bio_end_AlnSequence
+boolean bp_sw_replace_end_AlnUnit(AlnUnit * obj,int end);
+#define replace_end_AlnUnit bp_sw_replace_end_AlnUnit
+boolean bp_sw_replace_label_AlnUnit(AlnUnit * obj,int label);
+#define replace_label_AlnUnit bp_sw_replace_label_AlnUnit
+int bp_sw_access_label_AlnUnit(AlnUnit * obj);
+#define access_label_AlnUnit bp_sw_access_label_AlnUnit
+boolean bp_sw_replace_start_AlnBlock(AlnBlock * obj,AlnColumn * start);
+#define replace_start_AlnBlock bp_sw_replace_start_AlnBlock
+boolean bp_sw_replace_text_label_AlnUnit(AlnUnit * obj,char * text_label);
+#define replace_text_label_AlnUnit bp_sw_replace_text_label_AlnUnit
+AlnColumn * bp_sw_access_start_AlnBlock(AlnBlock * obj);
+#define access_start_AlnBlock bp_sw_access_start_AlnBlock
+char * bp_sw_access_text_label_AlnUnit(AlnUnit * obj);
+#define access_text_label_AlnUnit bp_sw_access_text_label_AlnUnit
+boolean bp_sw_replace_length_AlnBlock(AlnBlock * obj,int length);
+#define replace_length_AlnBlock bp_sw_replace_length_AlnBlock
+boolean bp_sw_replace_bio_start_AlnSequence(AlnSequence * obj,int bio_start);
+#define replace_bio_start_AlnSequence bp_sw_replace_bio_start_AlnSequence
+boolean bp_sw_replace_next_AlnUnit(AlnUnit * obj,AlnUnit * next);
+#define replace_next_AlnUnit bp_sw_replace_next_AlnUnit
+boolean bp_sw_replace_score_AlnBlock(AlnBlock * obj,int score);
+#define replace_score_AlnBlock bp_sw_replace_score_AlnBlock
+AlnUnit * bp_sw_access_next_AlnUnit(AlnUnit * obj);
+#define access_next_AlnUnit bp_sw_access_next_AlnUnit
+boolean bp_sw_replace_next_AlnColumn(AlnColumn * obj,AlnColumn * next);
+#define replace_next_AlnColumn bp_sw_replace_next_AlnColumn
+void * bp_sw_access_data_AlnSequence(AlnSequence * obj);
+#define access_data_AlnSequence bp_sw_access_data_AlnSequence
+boolean bp_sw_replace_in_column_AlnUnit(AlnUnit * obj,boolean in_column);
+#define replace_in_column_AlnUnit bp_sw_replace_in_column_AlnUnit
+boolean bp_sw_replace_start_AlnUnit(AlnUnit * obj,int start);
+#define replace_start_AlnUnit bp_sw_replace_start_AlnUnit
+boolean bp_sw_access_in_column_AlnUnit(AlnUnit * obj);
+#define access_in_column_AlnUnit bp_sw_access_in_column_AlnUnit
+boolean bp_sw_replace_bio_end_AlnSequence(AlnSequence * obj,int bio_end);
+#define replace_bio_end_AlnSequence bp_sw_replace_bio_end_AlnSequence
+boolean bp_sw_replace_seq_AlnUnit(AlnUnit * obj,AlnSequence * seq);
+#define replace_seq_AlnUnit bp_sw_replace_seq_AlnUnit
+AlnSequence * bp_sw_access_seq_AlnBlock(AlnBlock * obj,int i);
+#define access_seq_AlnBlock bp_sw_access_seq_AlnBlock
+AlnSequence * bp_sw_access_seq_AlnUnit(AlnUnit * obj);
+#define access_seq_AlnUnit bp_sw_access_seq_AlnUnit
+int bp_sw_access_score_AlnBlock(AlnBlock * obj);
+#define access_score_AlnBlock bp_sw_access_score_AlnBlock
+boolean bp_sw_replace_start_AlnSequence(AlnSequence * obj,AlnUnit * start);
+#define replace_start_AlnSequence bp_sw_replace_start_AlnSequence
+int bp_sw_access_end_AlnUnit(AlnUnit * obj);
+#define access_end_AlnUnit bp_sw_access_end_AlnUnit
+AlnUnit * bp_sw_access_start_AlnSequence(AlnSequence * obj);
+#define access_start_AlnSequence bp_sw_access_start_AlnSequence
+int bp_sw_access_length_AlnBlock(AlnBlock * obj);
+#define access_length_AlnBlock bp_sw_access_length_AlnBlock
+boolean bp_sw_replace_data_type_AlnSequence(AlnSequence * obj,int data_type);
+#define replace_data_type_AlnSequence bp_sw_replace_data_type_AlnSequence
+int bp_sw_access_bio_start_AlnSequence(AlnSequence * obj);
+#define access_bio_start_AlnSequence bp_sw_access_bio_start_AlnSequence
+int bp_sw_access_data_type_AlnSequence(AlnSequence * obj);
+#define access_data_type_AlnSequence bp_sw_access_data_type_AlnSequence
+AlnColumn * bp_sw_access_next_AlnColumn(AlnColumn * obj);
+#define access_next_AlnColumn bp_sw_access_next_AlnColumn
+boolean bp_sw_replace_data_AlnSequence(AlnSequence * obj,void * data);
+#define replace_data_AlnSequence bp_sw_replace_data_AlnSequence
+boolean bp_sw_can_swallow_AlnColumn(AlnColumn * master,AlnColumn * eaten,boolean (*comp_func)(char *,char *));
+#define can_swallow_AlnColumn bp_sw_can_swallow_AlnColumn
+boolean bp_sw_identical_labels_in_AlnColumn(AlnColumn * one,AlnColumn * two,boolean (*comp_func)(char *,char *));
+#define identical_labels_in_AlnColumn bp_sw_identical_labels_in_AlnColumn
+boolean bp_sw_identical_labels_in_AlnUnits(AlnUnit * one,AlnUnit * two,boolean (*comp_func)(char *,char *));
+#define identical_labels_in_AlnUnits bp_sw_identical_labels_in_AlnUnits
+AlnColumn * bp_sw_read_dumped_ascii_AlnColumn_line(char * line);
+#define read_dumped_ascii_AlnColumn_line bp_sw_read_dumped_ascii_AlnColumn_line
+void bp_sw_show_flat_AlnColumn(AlnColumn * alc,FILE * ofp);
+#define show_flat_AlnColumn bp_sw_show_flat_AlnColumn
+void bp_sw_show_flat_AlnUnit(AlnUnit * alu,FILE * ofp);
+#define show_flat_AlnUnit bp_sw_show_flat_AlnUnit
+AlnUnit * bp_sw_read_flat_AlnUnit_line(char * line,int * ret_pos);
+#define read_flat_AlnUnit_line bp_sw_read_flat_AlnUnit_line
+void bp_sw_swap_AlnColumn(AlnUnit ** list,int i,int j) ;
+#define swap_AlnColumn bp_sw_swap_AlnColumn
+void bp_sw_qsort_AlnColumn(AlnUnit ** list,int left,int right,int (*comp)(AlnUnit * ,AlnUnit * ));
+#define qsort_AlnColumn bp_sw_qsort_AlnColumn
+void bp_sw_sort_AlnColumn(AlnColumn * obj,int (*comp)(AlnUnit *, AlnUnit *));
+#define sort_AlnColumn bp_sw_sort_AlnColumn
+boolean bp_sw_expand_AlnColumn(AlnColumn * obj,int len);
+#define expand_AlnColumn bp_sw_expand_AlnColumn
+void bp_sw_swap_AlnBlock(AlnSequence ** list,int i,int j) ;
+#define swap_AlnBlock bp_sw_swap_AlnBlock
+void bp_sw_qsort_AlnBlock(AlnSequence ** list,int left,int right,int (*comp)(AlnSequence * ,AlnSequence * ));
+#define qsort_AlnBlock bp_sw_qsort_AlnBlock
+void bp_sw_sort_AlnBlock(AlnBlock * obj,int (*comp)(AlnSequence *, AlnSequence *));
+#define sort_AlnBlock bp_sw_sort_AlnBlock
+boolean bp_sw_expand_AlnBlock(AlnBlock * obj,int len);
+#define expand_AlnBlock bp_sw_expand_AlnBlock
+void bp_sw_swap_AlnBlockList(AlnBlock ** list,int i,int j) ;
+#define swap_AlnBlockList bp_sw_swap_AlnBlockList
+void bp_sw_qsort_AlnBlockList(AlnBlock ** list,int left,int right,int (*comp)(AlnBlock * ,AlnBlock * ));
+#define qsort_AlnBlockList bp_sw_qsort_AlnBlockList
+void bp_sw_sort_AlnBlockList(AlnBlockList * obj,int (*comp)(AlnBlock *, AlnBlock *));
+#define sort_AlnBlockList bp_sw_sort_AlnBlockList
+boolean bp_sw_expand_AlnBlockList(AlnBlockList * obj,int len);
+#define expand_AlnBlockList bp_sw_expand_AlnBlockList
+
+#ifdef _cplusplus
+}
+#endif
+
+#endif
586 Bio/Ext/Align/libs/alnconvert.c
@@ -0,0 +1,586 @@
+#ifdef _cplusplus
+extern "C" {
+#endif
+#include "alnconvert.h"
+
+ static char * unknown_label = "UNKNOWN_LABEL";
+
+
+/* Function: add_collapse_label_AlnConvertSet(acs,label1,label2)
+ *
+ * Descrip: Not a sensible function. Makes the convert with label1 and label2
+ * a collapsable label
+ *
+ *
+ * Arg: acs [UNKN ] Undocumented argument [AlnConvertSet *]
+ * Arg: label1 [UNKN ] Undocumented argument [char *]
+ * Arg: label2 [UNKN ] Undocumented argument [char *]
+ *
+ */
+# line 36 "alnconvert.dy"
+void add_collapse_label_AlnConvertSet(AlnConvertSet * acs,char * label1,char * label2)
+{
+ int i;
+
+ for(i=0;i<acs->len;i++)
+ if( strcmp(acs->acu[i]->label1,label1) == 0 && strcmp(acs->acu[i]->label2,label2) == 0 )
+ acs->acu[i]->can_collapse = TRUE;
+
+}
+
+/* Function: AlnBlock_from_PackAln(acs,*pal)
+ *
+ * Descrip: Takes a AlnConvertSet (acs) and a PackAln (pal)
+ * and blindly converts it to AlnBlock. This is really
+ * an internal for a dynamite produced dy function
+ *
+ *
+ * Arg: acs [UNKN ] Undocumented argument [AlnConvertSet *]
+ * Arg: *pal [UNKN ] Undocumented argument [PackAln]
+ *
+ * Return [UNKN ] Undocumented return value [AlnBlock *]
+ *
+ */
+# line 51 "alnconvert.dy"
+AlnBlock * AlnBlock_from_PackAln(AlnConvertSet * acs,PackAln *pal)
+{
+ AlnBlock * alb;
+ AlnColumn * prev;
+ AlnColumn * new;
+ boolean coll;
+ int i;
+
+ alb = AlnBlock_alloc_len(2);
+
+ add_AlnBlock(alb,AlnSequence_alloc());
+ add_AlnBlock(alb,AlnSequence_alloc());
+
+ prev = NULL;
+ alb->score = pal->score;
+ for(i=1;i<pal->len;i++) {
+ coll = FALSE;
+ new=AlnColumn_from_Pal_Convert(acs,pal->pau[i-1],pal->pau[i],prev,&coll);
+ if( new == NULL ) {
+ if( coll == FALSE ) {
+ warn("Unrecoverable error in converting PackAln to AlnBlock... bugging out with partial alignment!");
+ return alb;
+ }
+ else {
+ /** ok, was collapsed, just loop back **/
+ continue;
+ }
+ }
+ else {
+ /** got a new AlnColumn **/
+ if( prev == NULL ) {
+ /** then first col **/
+
+ alb->start = new;
+ alb->seq[0]->start = new->alu[0];
+ alb->seq[1]->start = new->alu[1];
+ prev = new;
+
+ }
+ else {
+ prev->next = new;
+ prev->alu[0]->next = new->alu[0];
+ prev->alu[1]->next = new->alu[1];
+ prev = new;
+ }
+ }
+
+ }
+
+ return alb;
+}
+
+
+/* Function: AlnColumn_from_Pal_Convert(acs,before,after,prev,was_collapsed)
+ *
+ * Descrip: the core of the conversion.
+ *
+ *
+ * Arg: acs [UNKN ] Undocumented argument [AlnConvertSet *]
+ * Arg: before [UNKN ] Undocumented argument [PackAlnUnit *]
+ * Arg: after [UNKN ] Undocumented argument [PackAlnUnit *]
+ * Arg: prev [UNKN ] Undocumented argument [AlnColumn *]
+ * Arg: was_collapsed [UNKN ] Undocumented argument [boolean *]
+ *
+ * Return [UNKN ] Undocumented return value [AlnColumn *]
+ *
+ */
+# line 108 "alnconvert.dy"
+AlnColumn * AlnColumn_from_Pal_Convert(AlnConvertSet * acs,PackAlnUnit * before,PackAlnUnit * after,AlnColumn * prev,boolean * was_collapsed)
+{
+ AlnConvertUnit * acu;
+ AlnColumn * alc;
+
+
+ acu = AlnConvertUnit_from_state_and_offset(acs,before->state,after->state,after->i - before->i,after->j - before->j);
+
+ if( acu == NULL) {
+ warn("Between state [%d,%d,%d] and [%d,%d,%d] got no labels... labelling as UNKNOWN",before->i,before->j,before->state,after->i,after->j,after->state);
+ alc = new_pairwise_AlnColumn();
+
+ alc->alu[0]->start = before->i;
+ alc->alu[0]->end = after->i;
+
+ alc->alu[1]->start = before->j;
+ alc->alu[1]->end = after->j;
+ alc->alu[0]->score[0] = alc->alu[1]->score[0] = after->score;
+
+ alc->alu[1]->text_label = alc->alu[0]->text_label = unknown_label;
+
+ return alc;
+ }
+
+ if( acu->can_collapse == TRUE && prev != NULL && strcmp(prev->alu[0]->text_label,acu->label1) == 0 && strcmp(prev->alu[1]->text_label,acu->label2) == 0 ) {
+ /*** don't return something, just add into the next one ***/
+ prev->alu[0]->end = after->i;
+ prev->alu[1]->end = after->j;
+ prev->alu[0]->score[0] += after->score;
+ prev->alu[1]->score[0] += after->score;
+ if( was_collapsed != NULL ) {
+ *was_collapsed = TRUE;
+ }
+ return NULL;
+ }
+
+ /*** else, put away this unit ***/
+
+ alc = new_pairwise_AlnColumn();
+
+ if( acu->is_from_special == TRUE ) {
+ alc->alu[0]->start = after->i -1;
+ alc->alu[0]->end = after->i;
+ } else {
+ alc->alu[0]->start = before->i;
+ alc->alu[0]->end = after->i;
+ }
+
+ alc->alu[1]->start = before->j;
+ alc->alu[1]->end = after->j;
+ alc->alu[0]->score[0] = alc->alu[1]->score[0] = after->score;
+
+ alc->alu[0]->text_label = acu->label1;
+ alc->alu[1]->text_label = acu->label2;
+
+ return alc;
+}
+
+
+/* Function: AlnConvertUnit_from_state_and_offset(acs,state1,state2,offi,offj)
+ *
+ * Descrip: Finds the correct AlnConvertUnit for this state,state,offi,offj
+ * quad
+ *
+ *
+ * Arg: acs [UNKN ] Undocumented argument [AlnConvertSet *]
+ * Arg: state1 [UNKN ] Undocumented argument [int]
+ * Arg: state2 [UNKN ] Undocumented argument [int]
+ * Arg: offi [UNKN ] Undocumented argument [int]
+ * Arg: offj [UNKN ] Undocumented argument [int]
+ *
+ * Return [UNKN ] Undocumented return value [AlnConvertUnit *]
+ *
+ */
+# line 172 "alnconvert.dy"
+AlnConvertUnit * AlnConvertUnit_from_state_and_offset(AlnConvertSet * acs,int state1,int state2,int offi,int offj)
+{
+ register int i;
+
+ for(i=0;i<acs->len;i++) {
+ if( acs->acu[i]->state1 == state1 && acs->acu[i]->state2 == state2 && (acs->acu[i]->offi == -1 || acs->acu[i]->offi == offi) && offj == acs->acu[i]->offj)
+ return acs->acu[i];
+ }
+ return NULL;
+}
+
+
+# line 191 "alnconvert.c"
+/* Function: hard_link_AlnConvertUnit(obj)
+ *
+ * Descrip: Bumps up the reference count of the object
+ * Meaning that multiple pointers can 'own' it
+ *
+ *
+ * Arg: obj [UNKN ] Object to be hard linked [AlnConvertUnit *]
+ *
+ * Return [UNKN ] Undocumented return value [AlnConvertUnit *]
+ *
+ */
+AlnConvertUnit * hard_link_AlnConvertUnit(AlnConvertUnit * obj)
+{
+ if( obj == NULL ) {
+ warn("Trying to hard link to a AlnConvertUnit object: passed a NULL object");
+ return NULL;
+ }
+ obj->dynamite_hard_link++;
+ return obj;
+}
+
+
+/* Function: AlnConvertUnit_alloc(void)
+ *
+ * Descrip: Allocates structure: assigns defaults if given
+ *
+ *
+ *
+ * Return [UNKN ] Undocumented return value [AlnConvertUnit *]
+ *
+ */
+AlnConvertUnit * AlnConvertUnit_alloc(void)
+{
+ AlnConvertUnit * out; /* out is exported at end of function */
+
+
+ /* call ckalloc and see if NULL */
+ if((out=(AlnConvertUnit *) ckalloc (sizeof(AlnConvertUnit))) == NULL) {
+ warn("AlnConvertUnit_alloc failed ");
+ return NULL; /* calling function should respond! */
+ }
+ out->dynamite_hard_link = 1;
+ out->state1 = 0;
+ out->state2 = 0;
+ out->offi = 0;
+ out->offj = 0;
+ out->can_collapse = FALSE;
+ out->is_from_special = FALSE;
+
+
+ return out;
+}
+
+
+/* Function: free_AlnConvertUnit(obj)
+ *
+ * Descrip: Free Function: removes the memory held by obj
+ * Will chain up to owned members and clear all lists
+ *
+ *
+ * Arg: obj [UNKN ] Object that is free'd [AlnConvertUnit *]
+ *
+ * Return [UNKN ] Undocumented return value [AlnConvertUnit *]
+ *
+ */
+AlnConvertUnit * free_AlnConvertUnit(AlnConvertUnit * obj)
+{
+
+
+ if( obj == NULL) {
+ warn("Attempting to free a NULL pointer to a AlnConvertUnit obj. Should be trappable");
+ return NULL;
+ }
+
+
+ if( obj->dynamite_hard_link > 1) {
+ obj->dynamite_hard_link--;
+ return NULL;
+ }
+ /* obj->label1 is linked in */
+ /* obj->label2 is linked in */
+
+
+ ckfree(obj);
+ return NULL;
+}
+
+
+/* Function: swap_AlnConvertSet(list,i,j)
+ *
+ * Descrip: swap function: an internal for qsort_AlnConvertSet
+ * swaps two positions in the array
+ *
+ *
+ * Arg: list [UNKN ] List of structures to swap in [AlnConvertUnit **]
+ * Arg: i [UNKN ] swap position [int]
+ * Arg: j [UNKN ] swap position [int]
+ *
+ */
+/* swap function for qsort function */
+void swap_AlnConvertSet(AlnConvertUnit ** list,int i,int j)
+{
+ AlnConvertUnit * temp;
+ temp=list[i];
+ list[i]=list[j];
+ list[j]=temp;
+}
+
+
+/* Function: qsort_AlnConvertSet(list,left,right,comp)
+ *
+ * Descrip: qsort - lifted from K&R
+ * sorts the array using quicksort
+ * Probably much better to call sort_AlnConvertSet which sorts from start to end
+ *
+ *
+ * Arg: list [UNKN ] List of structures to swap in [AlnConvertUnit **]
+ * Arg: left [UNKN ] left position [int]
+ * Arg: right [UNKN ] right position [int]
+ * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp]
+ *
+ */
+void qsort_AlnConvertSet(AlnConvertUnit ** list,int left,int right,int (*comp)(AlnConvertUnit * ,AlnConvertUnit * ))
+{
+ int i,last;
+ if( left >= right )
+ return;
+
+
+ swap_AlnConvertSet(list,left,(left+right)/2);
+ last = left;
+ for ( i=left+1; i <= right;i++) {
+ if( (*comp)(list[i],list[left]) < 0)
+ swap_AlnConvertSet (list,++last,i);
+ }
+ swap_AlnConvertSet (list,left,last);
+ qsort_AlnConvertSet(list,left,last-1,comp);
+ qsort_AlnConvertSet(list,last+1,right,comp);
+}
+
+
+/* Function: sort_AlnConvertSet(obj,comp)
+ *
+ * Descrip: sorts from start to end using comp
+ * sorts the array using quicksort by calling qsort_AlnConvertSet
+ *
+ *
+ * Arg: obj [UNKN ] Object containing list [AlnConvertSet *]
+ * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp]
+ *
+ */
+void sort_AlnConvertSet(AlnConvertSet * obj,int (*comp)(AlnConvertUnit *, AlnConvertUnit *))
+{
+ qsort_AlnConvertSet(obj->acu,0,obj->len-1,comp);
+ return;
+}
+
+
+/* Function: expand_AlnConvertSet(obj,len)
+ *
+ * Descrip: Really an internal function for add_AlnConvertSet
+ *
+ *
+ * Arg: obj [UNKN ] Object which contains the list [AlnConvertSet *]
+ * Arg: len [UNKN ] Length to add one [int]
+ *
+ * Return [UNKN ] Undocumented return value [boolean]
+ *
+ */
+boolean expand_AlnConvertSet(AlnConvertSet * obj,int len)
+{
+
+
+ if( obj->maxlen > obj->len ) {
+ warn("expand_AlnConvertSet called with no need");
+ return TRUE;
+ }
+
+
+ if( (obj->acu = (AlnConvertUnit ** ) ckrealloc (obj->acu,sizeof(AlnConvertUnit *)*len)) == NULL) {
+ warn("ckrealloc failed for expand_AlnConvertSet, returning FALSE");
+ return FALSE;
+ }
+ obj->maxlen = len;
+ return TRUE;
+}
+
+
+/* Function: add_AlnConvertSet(obj,add)
+ *
+ * Descrip: Adds another object to the list. It will expand the list if necessary
+ *
+ *
+ * Arg: obj [UNKN ] Object which contains the list [AlnConvertSet *]
+ * Arg: add [OWNER] Object to add to the list [AlnConvertUnit *]
+ *
+ * Return [UNKN ] Undocumented return value [boolean]
+ *
+ */
+/* will expand function if necessary */
+boolean add_AlnConvertSet(AlnConvertSet * obj,AlnConvertUnit * add)
+{
+ if( obj->len >= obj->maxlen) {
+ if( expand_AlnConvertSet(obj,obj->len + AlnConvertSetLISTLENGTH) == FALSE)
+ return FALSE;
+ }
+
+
+ obj->acu[obj->len++]=add;
+ return TRUE;
+}
+
+
+/* Function: flush_AlnConvertSet(obj)
+ *
+ * Descrip: Frees the list elements, sets length to 0
+ * If you want to save some elements, use hard_link_xxx
+ * to protect them from being actually destroyed in the free
+ *
+ *
+ * Arg: obj [UNKN ] Object which contains the list [AlnConvertSet *]
+ *
+ * Return [UNKN ] Undocumented return value [int]
+ *
+ */
+int flush_AlnConvertSet(AlnConvertSet * obj)
+{
+ int i;
+
+
+ for(i=0;i<obj->len;i++) {
+ if( obj->acu[i] != NULL) {
+ free_AlnConvertUnit(obj->acu[i]);
+ obj->acu[i] = NULL;
+ }
+ } /* end of for i over list length */
+
+
+ obj->len = 0;
+ return i;
+}
+
+
+/* Function: AlnConvertSet_alloc_std(void)
+ *
+ * Descrip: Equivalent to AlnConvertSet_alloc_len(AlnConvertSetLISTLENGTH)
+ *
+ *
+ *
+ * Return [UNKN ] Undocumented return value [AlnConvertSet *]
+ *
+ */
+AlnConvertSet * AlnConvertSet_alloc_std(void)
+{
+ return AlnConvertSet_alloc_len(AlnConvertSetLISTLENGTH);
+}
+
+
+/* Function: AlnConvertSet_alloc_len(len)
+ *
+ * Descrip: Allocates len length to all lists
+ *
+ *
+ * Arg: len [UNKN ] Length of lists to allocate [int]
+ *
+ * Return [UNKN ] Undocumented return value [AlnConvertSet *]
+ *
+ */
+AlnConvertSet * AlnConvertSet_alloc_len(int len)
+{
+ AlnConvertSet * out;/* out is exported at the end of function */
+
+
+ /* Call alloc function: return NULL if NULL */
+ /* Warning message alread in alloc function */
+ if((out = AlnConvertSet_alloc()) == NULL)
+ return NULL;
+
+
+ /* Calling ckcalloc for list elements */
+ if((out->acu = (AlnConvertUnit ** ) ckcalloc (len,sizeof(AlnConvertUnit *))) == NULL) {
+ warn("Warning, ckcalloc failed in AlnConvertSet_alloc_len");
+ return NULL;
+ }
+ out->len = 0;
+ out->maxlen = len;
+
+
+ return out;
+}
+
+
+/* Function: hard_link_AlnConvertSet(obj)
+ *
+ * Descrip: Bumps up the reference count of the object
+ * Meaning that multiple pointers can 'own' it
+ *
+ *
+ * Arg: obj [UNKN ] Object to be hard linked [AlnConvertSet *]
+ *
+ * Return [UNKN ] Undocumented return value [AlnConvertSet *]
+ *
+ */
+AlnConvertSet * hard_link_AlnConvertSet(AlnConvertSet * obj)
+{
+ if( obj == NULL ) {
+ warn("Trying to hard link to a AlnConvertSet object: passed a NULL object");
+ return NULL;
+ }
+ obj->dynamite_hard_link++;
+ return obj;
+}
+
+
+/* Function: AlnConvertSet_alloc(void)
+ *
+ * Descrip: Allocates structure: assigns defaults if given
+ *
+ *
+ *
+ * Return [UNKN ] Undocumented return value [AlnConvertSet *]
+ *
+ */
+AlnConvertSet * AlnConvertSet_alloc(void)
+{
+ AlnConvertSet * out;/* out is exported at end of function */
+
+
+ /* call ckalloc and see if NULL */
+ if((out=(AlnConvertSet *) ckalloc (sizeof(AlnConvertSet))) == NULL) {
+ warn("AlnConvertSet_alloc failed ");
+ return NULL; /* calling function should respond! */
+ }
+ out->dynamite_hard_link = 1;
+ out->acu = NULL;
+ out->len = out->maxlen = 0;
+
+
+ return out;
+}
+
+
+/* Function: free_AlnConvertSet(obj)
+ *
+ * Descrip: Free Function: removes the memory held by obj
+ * Will chain up to owned members and clear all lists
+ *
+ *
+ * Arg: obj [UNKN ] Object that is free'd [AlnConvertSet *]
+ *
+ * Return [UNKN ] Undocumented return value [AlnConvertSet *]
+ *
+ */
+AlnConvertSet * free_AlnConvertSet(AlnConvertSet * obj)
+{
+ int i;
+
+
+ if( obj == NULL) {
+ warn("Attempting to free a NULL pointer to a AlnConvertSet obj. Should be trappable");
+ return NULL;
+ }
+
+
+ if( obj->dynamite_hard_link > 1) {
+ obj->dynamite_hard_link--;
+ return NULL;
+ }
+ if( obj->acu != NULL) {
+ for(i=0;i<obj->len;i++) {
+ if( obj->acu[i] != NULL)
+ free_AlnConvertUnit(obj->acu[i]);
+ }
+ ckfree(obj->acu);
+ }
+
+
+ ckfree(obj);
+ return NULL;
+}
+
+
+
+#ifdef _cplusplus
+}
+#endif
253 Bio/Ext/Align/libs/alnconvert.h
@@ -0,0 +1,253 @@
+#ifndef DYNAMITEalnconvertHEADERFILE
+#define DYNAMITEalnconvertHEADERFILE
+#ifdef _cplusplus
+extern "C" {
+#endif
+#include "dyna.h"
+
+#define AlnConvertSetLISTLENGTH 64
+
+struct bp_sw_AlnConvertUnit {
+ int dynamite_hard_link;
+ int state1;
+ int state2;
+ int offi;
+ int offj;
+ char * label1;
+ char * label2;
+ boolean can_collapse;
+ boolean is_from_special;
+ } ;
+/* AlnConvertUnit defined */
+#ifndef DYNAMITE_DEFINED_AlnConvertUnit
+typedef struct bp_sw_AlnConvertUnit bp_sw_AlnConvertUnit;
+#define AlnConvertUnit bp_sw_AlnConvertUnit
+#define DYNAMITE_DEFINED_AlnConvertUnit
+#endif
+
+
+struct bp_sw_AlnConvertSet {
+ int dynamite_hard_link;
+ AlnConvertUnit ** acu;
+ int len;/* len for above acu */
+ int maxlen; /* maxlen for above acu */
+ } ;
+/* AlnConvertSet defined */
+#ifndef DYNAMITE_DEFINED_AlnConvertSet
+typedef struct bp_sw_AlnConvertSet bp_sw_AlnConvertSet;
+#define AlnConvertSet bp_sw_AlnConvertSet
+#define DYNAMITE_DEFINED_AlnConvertSet
+#endif
+
+
+
+
+ /***************************************************/
+ /* Callable functions */
+ /* These are the functions you are expected to use */
+ /***************************************************/
+
+
+
+/* Function: add_collapse_label_AlnConvertSet(acs,label1,label2)
+ *
+ * Descrip: Not a sensible function. Makes the convert with label1 and label2
+ * a collapsable label
+ *
+ *
+ * Arg: acs [UNKN ] Undocumented argument [AlnConvertSet *]
+ * Arg: label1 [UNKN ] Undocumented argument [char *]
+ * Arg: label2 [UNKN ] Undocumented argument [char *]
+ *
+ */
+void bp_sw_add_collapse_label_AlnConvertSet(AlnConvertSet * acs,char * label1,char * label2);
+#define add_collapse_label_AlnConvertSet bp_sw_add_collapse_label_AlnConvertSet
+
+
+/* Function: AlnBlock_from_PackAln(acs,*pal)
+ *
+ * Descrip: Takes a AlnConvertSet (acs) and a PackAln (pal)
+ * and blindly converts it to AlnBlock. This is really
+ * an internal for a dynamite produced dy function
+ *
+ *
+ * Arg: acs [UNKN ] Undocumented argument [AlnConvertSet *]
+ * Arg: *pal [UNKN ] Undocumented argument [PackAln]
+ *
+ * Return [UNKN ] Undocumented return value [AlnBlock *]
+ *
+ */
+AlnBlock * bp_sw_AlnBlock_from_PackAln(AlnConvertSet * acs,PackAln *pal);
+#define AlnBlock_from_PackAln bp_sw_AlnBlock_from_PackAln
+
+
+/* Function: hard_link_AlnConvertUnit(obj)
+ *
+ * Descrip: Bumps up the reference count of the object
+ * Meaning that multiple pointers can 'own' it
+ *
+ *
+ * Arg: obj [UNKN ] Object to be hard linked [AlnConvertUnit *]
+ *
+ * Return [UNKN ] Undocumented return value [AlnConvertUnit *]
+ *
+ */
+AlnConvertUnit * bp_sw_hard_link_AlnConvertUnit(AlnConvertUnit * obj);
+#define hard_link_AlnConvertUnit bp_sw_hard_link_AlnConvertUnit
+
+
+/* Function: AlnConvertUnit_alloc(void)
+ *
+ * Descrip: Allocates structure: assigns defaults if given
+ *
+ *
+ *
+ * Return [UNKN ] Undocumented return value [AlnConvertUnit *]
+ *
+ */
+AlnConvertUnit * bp_sw_AlnConvertUnit_alloc(void);
+#define AlnConvertUnit_alloc bp_sw_AlnConvertUnit_alloc
+
+
+/* Function: free_AlnConvertUnit(obj)
+ *
+ * Descrip: Free Function: removes the memory held by obj
+ * Will chain up to owned members and clear all lists
+ *
+ *
+ * Arg: obj [UNKN ] Object that is free'd [AlnConvertUnit *]
+ *
+ * Return [UNKN ] Undocumented return value [AlnConvertUnit *]
+ *
+ */
+AlnConvertUnit * bp_sw_free_AlnConvertUnit(AlnConvertUnit * obj);
+#define free_AlnConvertUnit bp_sw_free_AlnConvertUnit
+
+
+/* Function: add_AlnConvertSet(obj,add)
+ *
+ * Descrip: Adds another object to the list. It will expand the list if necessary
+ *
+ *
+ * Arg: obj [UNKN ] Object which contains the list [AlnConvertSet *]
+ * Arg: add [OWNER] Object to add to the list [AlnConvertUnit *]
+ *
+ * Return [UNKN ] Undocumented return value [boolean]
+ *
+ */
+boolean bp_sw_add_AlnConvertSet(AlnConvertSet * obj,AlnConvertUnit * add);
+#define add_AlnConvertSet bp_sw_add_AlnConvertSet
+
+
+/* Function: flush_AlnConvertSet(obj)
+ *
+ * Descrip: Frees the list elements, sets length to 0
+ * If you want to save some elements, use hard_link_xxx
+ * to protect them from being actually destroyed in the free
+ *
+ *
+ * Arg: obj [UNKN ] Object which contains the list [AlnConvertSet *]
+ *
+ * Return [UNKN ] Undocumented return value [int]
+ *
+ */
+int bp_sw_flush_AlnConvertSet(AlnConvertSet * obj);
+#define flush_AlnConvertSet bp_sw_flush_AlnConvertSet
+
+
+/* Function: AlnConvertSet_alloc_std(void)
+ *
+ * Descrip: Equivalent to AlnConvertSet_alloc_len(AlnConvertSetLISTLENGTH)
+ *
+ *
+ *
+ * Return [UNKN ] Undocumented return value [AlnConvertSet *]
+ *
+ */
+AlnConvertSet * bp_sw_AlnConvertSet_alloc_std(void);
+#define AlnConvertSet_alloc_std bp_sw_AlnConvertSet_alloc_std
+
+
+/* Function: AlnConvertSet_alloc_len(len)
+ *
+ * Descrip: Allocates len length to all lists
+ *
+ *
+ * Arg: len [UNKN ] Length of lists to allocate [int]
+ *
+ * Return [UNKN ] Undocumented return value [AlnConvertSet *]
+ *
+ */
+AlnConvertSet * bp_sw_AlnConvertSet_alloc_len(int len);
+#define AlnConvertSet_alloc_len bp_sw_AlnConvertSet_alloc_len
+
+
+/* Function: hard_link_AlnConvertSet(obj)
+ *
+ * Descrip: Bumps up the reference count of the object
+ * Meaning that multiple pointers can 'own' it
+ *
+ *
+ * Arg: obj [UNKN ] Object to be hard linked [AlnConvertSet *]
+ *
+ * Return [UNKN ] Undocumented return value [AlnConvertSet *]
+ *
+ */
+AlnConvertSet * bp_sw_hard_link_AlnConvertSet(AlnConvertSet * obj);
+#define hard_link_AlnConvertSet bp_sw_hard_link_AlnConvertSet
+
+
+/* Function: AlnConvertSet_alloc(void)
+ *
+ * Descrip: Allocates structure: assigns defaults if given
+ *
+ *
+ *
+ * Return [UNKN ] Undocumented return value [AlnConvertSet *]
+ *
+ */
+AlnConvertSet * bp_sw_AlnConvertSet_alloc(void);
+#define AlnConvertSet_alloc bp_sw_AlnConvertSet_alloc
+
+
+/* Function: free_AlnConvertSet(obj)
+ *
+ * Descrip: Free Function: removes the memory held by obj
+ * Will chain up to owned members and clear all lists
+ *
+ *
+ * Arg: obj [UNKN ] Object that is free'd [AlnConvertSet *]
+ *
+ * Return [UNKN ] Undocumented return value [AlnConvertSet *]
+ *
+ */
+AlnConvertSet * bp_sw_free_AlnConvertSet(AlnConvertSet * obj);
+#define free_AlnConvertSet bp_sw_free_AlnConvertSet
+
+
+ /* Unplaced functions */
+ /* There has been no indication of the use of these functions */
+
+
+ /***************************************************/
+ /* Internal functions */
+ /* you are not expected to have to call these */
+ /***************************************************/
+AlnColumn * bp_sw_AlnColumn_from_Pal_Convert(AlnConvertSet * acs,PackAlnUnit * before,PackAlnUnit * after,AlnColumn * prev,boolean * was_collapsed);
+#define AlnColumn_from_Pal_Convert bp_sw_AlnColumn_from_Pal_Convert
+AlnConvertUnit * bp_sw_AlnConvertUnit_from_state_and_offset(AlnConvertSet * acs,int state1,int state2,int offi,int offj);
+#define AlnConvertUnit_from_state_and_offset bp_sw_AlnConvertUnit_from_state_and_offset
+void bp_sw_swap_AlnConvertSet(AlnConvertUnit ** list,int i,int j) ;
+#define swap_AlnConvertSet bp_sw_swap_AlnConvertSet
+void bp_sw_qsort_AlnConvertSet(AlnConvertUnit ** list,int left,int right,int (*comp)(AlnConvertUnit * ,AlnConvertUnit * ));
+#define qsort_AlnConvertSet bp_sw_qsort_AlnConvertSet
+void bp_sw_sort_AlnConvertSet(AlnConvertSet * obj,int (*comp)(AlnConvertUnit *, AlnConvertUnit *));
+#define sort_AlnConvertSet bp_sw_sort_AlnConvertSet
+boolean bp_sw_expand_AlnConvertSet(AlnConvertSet * obj,int len);
+#define expand_AlnConvertSet bp_sw_expand_AlnConvertSet
+
+#ifdef _cplusplus
+}
+#endif
+
+#endif
908 Bio/Ext/Align/libs/alnrange.c
@@ -0,0 +1,908 @@
+#ifdef _cplusplus
+extern "C" {
+#endif
+
+#include "alnrange.h"
+
+
+/* Function: show_AlnRangeSet(ars,ofp)
+ *
+ * Descrip: shows AlnRangeSet in vaguely human form
+ *
+ *
+ * Arg: ars [UNKN ] Undocumented argument [AlnRangeSet *]
+ * Arg: ofp [UNKN ] Undocumented argument [FILE *]
+ *
+ */
+# line 42 "alnrange.dy"
+void show_AlnRangeSet(AlnRangeSet * ars,FILE * ofp)
+{
+ int i;
+
+ for(i=0;i<ars->len;i++) {
+ show_AlnRange(ars->alr[i],ofp);
+ }
+
+}
+
+/* Function: show_AlnRange(alr,ofp)
+ *
+ * Descrip: shows AlnRange in vaguely human form
+ *
+ *
+ * Arg: alr [UNKN ] Undocumented argument [AlnRange *]
+ * Arg: ofp [UNKN ] Undocumented argument [FILE *]
+ *
+ */
+# line 55 "alnrange.dy"
+void show_AlnRange(AlnRange * alr,FILE * ofp)
+{
+ fprintf(ofp,"(%d,%d,%d)-(%d,%d,%d) [%d,%d]\n",alr->starti,alr->startj,alr->startstate,
+alr->stopi,alr->stopj,alr->stopstate,alr->startscore,alr->stopscore);
+}
+
+/* Function: sort_AlnRangeSet_by_start(ars)
+ *
+ * Descrip: Sorts an AlnRangeSet by start of each AlnRange
+ *
+ *
+ * Arg: ars [UNKN ] Undocumented argument [AlnRangeSet *]
+ *
+ */
+# line 64 "alnrange.dy"
+void sort_AlnRangeSet_by_start(AlnRangeSet * ars)
+{
+ sort_AlnRangeSet(ars,compare_AlnRange_start);
+}
+
+/* Function: compare_AlnRange_start(one,two)
+ *
+ * Descrip: compares to AlnRange for /sort_AlnRangeSet_by_start
+ *
+ *
+ * Arg: one [UNKN ] Undocumented argument [AlnRange *]
+ * Arg: two [UNKN ] Undocumented argument [AlnRange *]
+ *
+ * Return [UNKN ] Undocumented return value [int]
+ *
+ */
+# line 73 "alnrange.dy"
+int compare_AlnRange_start(AlnRange * one,AlnRange * two)
+{
+ if( one->startj > two->startj)
+ return 1;
+ else return -1;
+}
+
+
+# line 69 "alnrange.c"
+/* Function: hard_link_AlnRange(obj)
+ *
+ * Descrip: Bumps up the reference count of the object
+ * Meaning that multiple pointers can 'own' it
+ *
+ *
+ * Arg: obj [UNKN ] Object to be hard linked [AlnRange *]
+ *
+ * Return [UNKN ] Undocumented return value [AlnRange *]
+ *
+ */
+AlnRange * hard_link_AlnRange(AlnRange * obj)
+{
+ if( obj == NULL ) {
+ warn("Trying to hard link to a AlnRange object: passed a NULL object");
+ return NULL;
+ }
+ obj->dynamite_hard_link++;
+ return obj;
+}
+
+
+/* Function: AlnRange_alloc(void)
+ *
+ * Descrip: Allocates structure: assigns defaults if given
+ *
+ *
+ *
+ * Return [UNKN ] Undocumented return value [AlnRange *]
+ *
+ */
+AlnRange * AlnRange_alloc(void)
+{
+ AlnRange * out; /* out is exported at end of function */
+
+
+ /* call ckalloc and see if NULL */
+ if((out=(AlnRange *) ckalloc (sizeof(AlnRange))) == NULL) {
+ warn("AlnRange_alloc failed ");
+ return NULL; /* calling function should respond! */
+ }
+ out->dynamite_hard_link = 1;
+ out->starti = 0;
+ out->startj = 0;
+ out->startstate = 0;
+ out->stopi = 0;
+ out->stopj = 0;
+ out->stopstate = 0;
+ out->startscore = 0;
+ out->stopscore = 0;
+
+
+ return out;
+}
+
+
+/* Function: free_AlnRange(obj)
+ *
+ * Descrip: Free Function: removes the memory held by obj
+ * Will chain up to owned members and clear all lists
+ *
+ *
+ * Arg: obj [UNKN ] Object that is free'd [AlnRange *]
+ *
+ * Return [UNKN ] Undocumented return value [AlnRange *]
+ *
+ */
+AlnRange * free_AlnRange(AlnRange * obj)
+{
+
+
+ if( obj == NULL) {
+ warn("Attempting to free a NULL pointer to a AlnRange obj. Should be trappable");
+ return NULL;
+ }
+
+
+ if( obj->dynamite_hard_link > 1) {
+ obj->dynamite_hard_link--;
+ return NULL;
+ }
+
+
+ ckfree(obj);
+ return NULL;
+}
+
+
+/* Function: swap_AlnRangeSet(list,i,j)
+ *
+ * Descrip: swap function: an internal for qsort_AlnRangeSet
+ * swaps two positions in the array
+ *
+ *
+ * Arg: list [UNKN ] List of structures to swap in [AlnRange **]
+ * Arg: i [UNKN ] swap position [int]
+ * Arg: j [UNKN ] swap position [int]
+ *
+ */
+/* swap function for qsort function */
+void swap_AlnRangeSet(AlnRange ** list,int i,int j)
+{
+ AlnRange * temp;
+ temp=list[i];
+ list[i]=list[j];
+ list[j]=temp;
+}
+
+
+/* Function: qsort_AlnRangeSet(list,left,right,comp)
+ *
+ * Descrip: qsort - lifted from K&R
+ * sorts the array using quicksort
+ * Probably much better to call sort_AlnRangeSet which sorts from start to end
+ *
+ *
+ * Arg: list [UNKN ] List of structures to swap in [AlnRange **]
+ * Arg: left [UNKN ] left position [int]
+ * Arg: right [UNKN ] right position [int]
+ * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp]
+ *
+ */
+void qsort_AlnRangeSet(AlnRange ** list,int left,int right,int (*comp)(AlnRange * ,AlnRange * ))
+{
+ int i,last;
+ if( left >= right )
+ return;
+
+
+ swap_AlnRangeSet(list,left,(left+right)/2);
+ last = left;
+ for ( i=left+1; i <= right;i++) {
+ if( (*comp)(list[i],list[left]) < 0)
+ swap_AlnRangeSet (list,++last,i);
+ }
+ swap_AlnRangeSet (list,left,last);
+ qsort_AlnRangeSet(list,left,last-1,comp);
+ qsort_AlnRangeSet(list,last+1,right,comp);
+}
+
+
+/* Function: sort_AlnRangeSet(obj,comp)
+ *
+ * Descrip: sorts from start to end using comp
+ * sorts the array using quicksort by calling qsort_AlnRangeSet
+ *
+ *
+ * Arg: obj [UNKN ] Object containing list [AlnRangeSet *]
+ * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp]
+ *
+ */
+void sort_AlnRangeSet(AlnRangeSet * obj,int (*comp)(AlnRange *, AlnRange *))
+{
+ qsort_AlnRangeSet(obj->alr,0,obj->len-1,comp);
+ return;
+}
+
+
+/* Function: expand_AlnRangeSet(obj,len)
+ *
+ * Descrip: Really an internal function for add_AlnRangeSet
+ *
+ *
+ * Arg: obj [UNKN ] Object which contains the list [AlnRangeSet *]
+ * Arg: len [UNKN ] Length to add one [int]
+ *
+ * Return [UNKN ] Undocumented return value [boolean]
+ *
+ */
+boolean expand_AlnRangeSet(AlnRangeSet * obj,int len)
+{
+
+
+ if( obj->maxlen > obj->len ) {
+ warn("expand_AlnRangeSet called with no need");
+ return TRUE;
+ }
+
+
+ if( (obj->alr = (AlnRange ** ) ckrealloc (obj->alr,sizeof(AlnRange *)*len)) == NULL) {
+ warn("ckrealloc failed for expand_AlnRangeSet, returning FALSE");
+ return FALSE;
+ }
+ obj->maxlen = len;
+ return TRUE;
+}
+
+
+/* Function: add_AlnRangeSet(obj,add)
+ *
+ * Descrip: Adds another object to the list. It will expand the list if necessary
+ *
+ *
+ * Arg: obj [UNKN ] Object which contains the list [AlnRangeSet *]
+ * Arg: add [OWNER] Object to add to the list [AlnRange *]
+ *
+ * Return [UNKN ] Undocumented return value [boolean]
+ *
+ */
+/* will expand function if necessary */
+boolean add_AlnRangeSet(AlnRangeSet * obj,AlnRange * add)
+{
+ if( obj->len >= obj->maxlen) {
+ if( expand_AlnRangeSet(obj,obj->len + AlnRangeSetLISTLENGTH) == FALSE)
+ return FALSE;
+ }
+
+
+ obj->alr[obj->len++]=add;
+ return TRUE;
+}
+
+
+/* Function: flush_AlnRangeSet(obj)
+ *
+ * Descrip: Frees the list elements, sets length to 0
+ * If you want to save some elements, use hard_link_xxx
+ * to protect them from being actually destroyed in the free
+ *
+ *
+ * Arg: obj [UNKN ] Object which contains the list [AlnRangeSet *]
+ *
+ * Return [UNKN ] Undocumented return value [int]
+ *
+ */
+int flush_AlnRangeSet(AlnRangeSet * obj)
+{
+ int i;
+
+
+ for(i=0;i<obj->len;i++) {
+ if( obj->alr[i] != NULL) {
+ free_AlnRange(obj->alr[i]);
+ obj->alr[i] = NULL;
+ }
+ } /* end of for i over list length */
+
+
+ obj->len = 0;
+ return i;
+}
+
+
+/* Function: AlnRangeSet_alloc_std(void)
+ *
+ * Descrip: Equivalent to AlnRangeSet_alloc_len(AlnRangeSetLISTLENGTH)
+ *
+ *
+ *
+ * Return [UNKN ] Undocumented return value [AlnRangeSet *]
+ *
+ */
+AlnRangeSet * AlnRangeSet_alloc_std(void)
+{
+ return AlnRangeSet_alloc_len(AlnRangeSetLISTLENGTH);
+}
+
+
+/* Function: AlnRangeSet_alloc_len(len)
+ *
+ * Descrip: Allocates len length to all lists
+ *
+ *
+ * Arg: len [UNKN ] Length of lists to allocate [int]
+ *
+ * Return [UNKN ] Undocumented return value [AlnRangeSet *]
+ *
+ */
+AlnRangeSet * AlnRangeSet_alloc_len(int len)
+{
+ AlnRangeSet * out; /* out is exported at the end of function */
+
+
+ /* Call alloc function: return NULL if NULL */
+ /* Warning message alread in alloc function */
+ if((out = AlnRangeSet_alloc()) == NULL)
+ return NULL;
+
+
+ /* Calling ckcalloc for list elements */
+ if((out->alr = (AlnRange ** ) ckcalloc (len,sizeof(AlnRange *))) == NULL) {
+ warn("Warning, ckcalloc failed in AlnRangeSet_alloc_len");
+ return NULL;
+ }
+ out->len = 0;
+ out->maxlen = len;
+
+
+ return out;
+}
+
+
+/* Function: hard_link_AlnRangeSet(obj)
+ *
+ * Descrip: Bumps up the reference count of the object
+ * Meaning that multiple pointers can 'own' it
+ *
+ *
+ * Arg: obj [UNKN ] Object to be hard linked [AlnRangeSet *]
+ *
+ * Return [UNKN ] Undocumented return value [AlnRangeSet *]
+ *
+ */
+AlnRangeSet * hard_link_AlnRangeSet(AlnRangeSet * obj)
+{
+ if( obj == NULL ) {
+ warn("Trying to hard link to a AlnRangeSet object: passed a NULL object");
+ return NULL;
+ }
+ obj->dynamite_hard_link++;
+ return obj;
+}
+
+
+/* Function: AlnRangeSet_alloc(void)
+ *
+ * Descrip: Allocates structure: assigns defaults if given
+ *
+ *
+ *
+ * Return [UNKN ] Undocumented return value [AlnRangeSet *]
+ *
+ */
+AlnRangeSet * AlnRangeSet_alloc(void)
+{
+ AlnRangeSet * out; /* out is exported at end of function */
+
+
+ /* call ckalloc and see if NULL */
+ if((out=(AlnRangeSet *) ckalloc (sizeof(AlnRangeSet))) == NULL) {
+ warn("AlnRangeSet_alloc failed ");
+ return NULL; /* calling function should respond! */
+ }
+ out->dynamite_hard_link = 1;
+ out->score = 0;
+ out->alr = NULL;
+ out->len = out->maxlen = 0;
+
+
+ return out;
+}
+
+
+/* Function: free_AlnRangeSet(obj)
+ *
+ * Descrip: Free Function: removes the memory held by obj
+ * Will chain up to owned members and clear all lists
+ *
+ *
+ * Arg: obj [UNKN ] Object that is free'd [AlnRangeSet *]
+ *
+ * Return [UNKN ] Undocumented return value [AlnRangeSet *]
+ *
+ */
+AlnRangeSet * free_AlnRangeSet(AlnRangeSet * obj)
+{
+ int i;
+
+
+ if( obj == NULL) {
+ warn("Attempting to free a NULL pointer to a AlnRangeSet obj. Should be trappable");
+ return NULL;
+ }
+
+
+ if( obj->dynamite_hard_link > 1) {
+ obj->dynamite_hard_link--;
+ return NULL;
+ }
+ if( obj->alr != NULL) {
+ for(i=0;i<obj->len;i++) {
+ if( obj->alr[i] != NULL)
+ free_AlnRange(obj->alr[i]);
+ }
+ ckfree(obj->alr);
+ }
+
+
+ ckfree(obj);
+ return NULL;
+}
+
+
+/* Function: replace_score_AlnRangeSet(obj,score)
+ *
+ * Descrip: Replace member variable score
+ * For use principly by API functions
+ *
+ *
+ * Arg: obj [UNKN ] Object holding the variable [AlnRangeSet *]
+ * Arg: score [OWNER] New value of the variable [int]
+ *
+ * Return [SOFT ] member variable score [boolean]
+ *
+ */
+boolean replace_score_AlnRangeSet(AlnRangeSet * obj,int score)
+{
+ if( obj == NULL) {
+ warn("In replacement function score for object AlnRangeSet, got a NULL object");
+ return FALSE;
+ }
+ obj->score = score;
+ return TRUE;
+}
+
+
+/* Function: access_score_AlnRangeSet(obj)
+ *
+ * Descrip: Access member variable score
+ * For use principly by API functions
+ *
+ *
+ * Arg: obj [UNKN ] Object holding the variable [AlnRangeSet *]
+ *
+ * Return [SOFT ] member variable score [int]
+ *
+ */
+int access_score_AlnRangeSet(AlnRangeSet * obj)
+{
+ if( obj == NULL) {
+ warn("In accessor function score for object AlnRangeSet, got a NULL object");
+ return 0;
+ }
+ return obj->score;
+}
+
+
+/* Function: access_alr_AlnRangeSet(obj,i)
+ *
+ * Descrip: Access members stored in the alr list
+ * For use principly by API functions
+ *
+ *
+ * Arg: obj [UNKN ] Object holding the list [AlnRangeSet *]
+ * Arg: i [UNKN ] Position in the list [int]
+ *
+ * Return [SOFT ] Element of the list [AlnRange *]
+ *
+ */
+AlnRange * access_alr_AlnRangeSet(AlnRangeSet * obj,int i)
+{
+ if( obj == NULL) {
+ warn("In accessor function alr for object AlnRangeSet, got a NULL object");
+ return NULL;
+ }
+ if( obj->len <= i ) {
+ warn("In accessor function alr for object AlnRangeSet, index %%d is greater than list length %%d",i,obj->len);
+ return NULL;
+ }
+ return obj->alr[i];
+}
+
+
+/* Function: length_alr_AlnRangeSet(obj)
+ *
+ * Descrip: discover the length of the list
+ * For use principly by API functions
+ *
+ *
+ * Arg: obj [UNKN ] Object holding the list [AlnRangeSet *]
+ *
+ * Return [UNKN ] length of the list [int]
+ *
+ */
+int length_alr_AlnRangeSet(AlnRangeSet * obj)
+{
+ if( obj == NULL) {
+ warn("In length function alr for object AlnRangeSet, got a NULL object");
+ return -1;
+ }
+ return obj->len;
+}
+
+
+/* Function: replace_starti_AlnRange(obj,starti)
+ *
+ * Descrip: Replace member variable starti
+ * For use principly by API functions
+ *
+ *
+ * Arg: obj [UNKN ] Object holding the variable [AlnRange *]
+ * Arg: starti [OWNER] New value of the variable [int]
+ *
+ * Return [SOFT ] member variable starti [boolean]
+ *
+ */
+boolean replace_starti_AlnRange(AlnRange * obj,int starti)
+{
+ if( obj == NULL) {
+ warn("In replacement function starti for object AlnRange, got a NULL object");
+ return FALSE;
+ }
+ obj->starti = starti;
+ return TRUE;
+}
+
+
+/* Function: access_starti_AlnRange(obj)
+ *
+ * Descrip: Access member variable starti
+ * For use principly by API functions
+ *
+ *
+ * Arg: obj [UNKN ] Object holding the variable [AlnRange *]
+ *
+ * Return [SOFT ] member variable starti [int]
+ *
+ */
+int access_starti_AlnRange(AlnRange * obj)
+{
+ if( obj == NULL) {
+ warn("In accessor function starti for object AlnRange, got a NULL object");
+ return 0;
+ }
+ return obj->starti;
+}
+
+
+/* Function: replace_startj_AlnRange(obj,startj)
+ *
+ * Descrip: Replace member variable startj
+ * For use principly by API functions
+ *
+ *
+ * Arg: obj [UNKN ] Object holding the variable [AlnRange *]
+ * Arg: startj [OWNER] New value of the variable [int]
+ *
+ * Return [SOFT ] member variable startj [boolean]
+ *
+ */
+boolean replace_startj_AlnRange(AlnRange * obj,int startj)
+{
+ if( obj == NULL) {
+ warn("In replacement function startj for object AlnRange, got a NULL object");
+ return FALSE;
+ }
+ obj->startj = startj;
+ return TRUE;
+}
+
+
+/* Function: access_startj_AlnRange(obj)
+ *
+ * Descrip: Access member variable startj
+ * For use principly by API functions
+ *
+ *
+ * Arg: obj [UNKN ] Object holding the variable [AlnRange *]
+ *
+ * Return [SOFT ] member variable startj [int]
+ *
+ */
+int access_startj_AlnRange(AlnRange * obj)
+{
+ if( obj == NULL) {
+ warn("In accessor function startj for object AlnRange, got a NULL object");
+ return 0;
+ }
+ return obj->startj;
+}
+
+
+/* Function: replace_startstate_AlnRange(obj,startstate)
+ *
+ * Descrip: Replace member variable startstate
+ * For use principly by API functions
+ *
+ *
+ * Arg: obj [UNKN ] Object holding the variable [AlnRange *]
+ * Arg: startstate [OWNER] New value of the variable [int]
+ *
+ * Return [SOFT ] member variable startstate [boolean]
+ *
+ */