/* @source listor application ** ** Writes a list file of the logical OR of two sets of sequences ** ** @author Copyright (C) Gary Williams ** @@ ** ** This program is free software; you can redistribute it and/or ** modify it under the terms of the GNU General Public License ** as published by the Free Software Foundation; either version 2 ** of the License, or (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ******************************************************************************/ #include "emboss.h" static void listor_Output(AjPFile list, ajint Operator, const AjPSeqset seq1, const AjPSeqset seq2, const ajint *hits1, const ajint *hits2, ajint n1, ajint n2); static void listor_Write(AjPFile list, const AjPSeqset seqset, ajint i); enum {L_OR, L_AND, L_XOR, L_NOT}; /* @prog listor *************************************************************** ** ** Writes a list file of the logical OR of two sets of sequences ** ******************************************************************************/ int main(int argc, char **argv) { AjPSeqset seq1; AjPSeqset seq2; AjPFile list; ajint n1; ajint n2; ajint *lengths1; ajint *lengths2; ajuint *order1; ajuint *order2; ajint *hits1; ajint *hits2; ajint curr1; ajint curr2; ajint tmp1; ajint tmp2 = 0; ajint i; AjPStr operator; ajint OperatorCode=0; embInit("listor", argc, argv); seq1 = ajAcdGetSeqset("firstsequences"); seq2 = ajAcdGetSeqset("secondsequences"); list = ajAcdGetOutfile("outfile"); operator = ajAcdGetListSingle("operator"); /* get the operator value */ switch(ajStrGetCharFirst(operator)) { case 'O': OperatorCode = L_OR; break; case 'A': OperatorCode = L_AND; break; case 'X': OperatorCode = L_XOR; break; case 'N': OperatorCode = L_NOT; break; default: ajFatal("Invalid operator type: %S", operator); embExitBad(); } /* get the order of seqset 1 by length */ n1 = ajSeqsetGetSize(seq1); /* lengths of seq1 entries */ lengths1 = AJCALLOC0(n1, sizeof(ajint)); /* seq1 entries which match seq2 */ hits1 = AJCALLOC0(n1, sizeof(ajint)); /* seq1 entries in length order */ order1 = AJCALLOC0(n1, sizeof(ajint)); for(i=0; i lengths2[order2[curr2]]) /* seq2 is shorter - increment curr2 index */ curr2++; else { /* identical lengths - check all seq1/seq2 entries of this len */ for(tmp1=curr1; tmp1