1 /* @source ajseq **************************************************************
2 **
3 ** AJAX SEQ (sequence) functions
4 **
5 ** These functions control all aspects of AJAX sequence
6 ** reading and writing and include simple utilities.
7 **
8 ** @author Copyright (C) 1998 Peter Rice
9 ** @version $Revision: 1.183 $
10 ** @modified Jun 25 pmr First version
11 ** @modified $Date: 2013/07/15 20:56:02 $ by $Author: rice $
12 ** @@
13 **
14 ** This library is free software; you can redistribute it and/or
15 ** modify it under the terms of the GNU Lesser General Public
16 ** License as published by the Free Software Foundation; either
17 ** version 2.1 of the License, or (at your option) any later version.
18 **
19 ** This library is distributed in the hope that it will be useful,
20 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
21 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22 ** Lesser General Public License for more details.
23 **
24 ** You should have received a copy of the GNU Lesser General Public
25 ** License along with this library; if not, write to the Free Software
26 ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
27 ** MA  02110-1301,  USA.
28 **
29 ******************************************************************************/
30 
31 
32 #include "ajlib.h"
33 
34 #include "ajseq.h"
35 #include "ajseqread.h"
36 #include "ajseqwrite.h"
37 #include "ajseqtype.h"
38 #include "ajsys.h"
39 #include "ajlist.h"
40 #include "ajtable.h"
41 #include "ajtime.h"
42 #include "ajfeat.h"
43 #include "ajmath.h"
44 #include "ajsort.h"
45 #include "ajbase.h"
46 
47 #include <string.h>
48 #include <limits.h>
49 #include <float.h>
50 #include <math.h>
51 
52 static AjPStr seqVersionAccnum = NULL;
53 
54 static AjPStr seqTempUsa = NULL;
55 
56 
57 static void seqMakeUsa(const AjPSeq thys, AjPStr* usa);
58 static AjBool seqDateSet(AjPTime* date, const AjPStr datestr);
59 static int seqxrefSortDb(const void* refa, const void* refb);
60 static void seqxrefDel(void** Pxref, void *cl);
61 
62 static void seqclsInit(void);
63 static void seqdivInit(void);
64 static void seqmolInit(void);
65 
66 static AjPStr seqMoleculeDef = NULL;
67 static AjPTable seqTableMol = NULL;
68 static AjPTable seqTableMolEmbl = NULL;
69 static AjPTable seqTableMolDdbj = NULL;
70 static AjPTable seqTableMolGb = NULL;
71 
72 static AjPStr seqDivisionDef = NULL;
73 static AjPTable seqTableDiv = NULL;
74 static AjPTable seqTableDivEmbl = NULL;
75 static AjPTable seqTableDivDdbj = NULL;
76 static AjPTable seqTableDivGb = NULL;
77 
78 static AjPStr seqClassDef = NULL;
79 static AjPTable seqTableCls = NULL;
80 static AjPTable seqTableClsEmbl = NULL;
81 static AjPTable seqTableClsDdbj = NULL;
82 static AjPTable seqTableClsGb = NULL;
83 
84 /*static AjPTable seqTableXref = NULL;*/
85 
86 
87 
88 
89 /* @datastatic SeqOClass ******************************************************
90 **
91 ** Classes of entries in the sequence databases
92 **
93 ** Reference for this is
94 ** http://www.ncbi.nlm.nih.gov/HTGS/table1.html
95 **
96 ** @attr Name [const char*] Name used internally
97 ** @attr Embl [const char*] Name in EMBL
98 ** @attr Ddbj [const char*] Name in DDBJ
99 ** @attr Genbank [const char*] Name in Genbank
100 ** @attr Desc [const char*] Description
101 ******************************************************************************/
102 
103 typedef struct SeqSClass
104 {
105   const char* Name;
106   const char* Embl;
107   const char* Ddbj;
108   const char* Genbank;
109   const char* Desc;
110 } SeqOClass;
111 
112 static SeqOClass seqClass[] =
113 {
114 /*   Name      Embl   DDBJ   Genbank Description */
115     {"STD", "STD", "",    "",    "Standard (all other entries)"},
116     {"ANN", "ANN", "",    "",    "CON entries with own annotation"},
117     {"CON", "CON", "CON", "CON", "Constructed from segment sequences"},
118     {"EST", "EST", "EST", "EST", "Expressed Sequence Tag"},
119     {"GSS", "GSS", "GSS", "GSS", "Genome Survey Sequence"},
120     {"HTC", "HTC", "HTC", "",    "High Thoughput CDNA sequencing"},
121     {"HTG", "HTG", "HTG", "HTG", "High Thoughput Genome sequencing"},
122     {"MGA", "MGA", "",    "",    "Mass Genome Annotation"},
123     {"PAT", "PAT", "PAT", "PAT", "Patent"},
124     {"STS", "STS", "STS", "STS", "Sequence Tagged Site"},
125     {"TPA", "TPA", "TPA", "",    "Third Party Annotation"},  /* 2 DDBJ types */
126     {"TSA", "TSA", "TSA", "",    "Transcriptome shotgun assembly"},
127     {"WGS", "WGS", "",    "",    "Whole Genome Shotgun"},
128     {"", "", "", "", ""},
129     {NULL, NULL, NULL, NULL, NULL}
130 };
131 
132 
133 
134 
135 /* @datastatic SeqODivision ***************************************************
136 **
137 ** Taxonomic divisions in the sequence databases
138 **
139 ** Reference for this is
140 ** http://www.ncbi.nlm.nih.gov/HTGS/table1.html
141 **
142 ** @attr Name [const char*] Name used internally
143 ** @attr Embl [const char*] Name in EMBL
144 ** @attr Ddbj [const char*] Name in DDBJ
145 ** @attr Genbank [const char*] Name in Genbank
146 ** @attr Desc [const char*] Description
147 ******************************************************************************/
148 
149 typedef struct SeqSDivision
150 {
151   const char* Name;
152   const char* Embl;
153   const char* Ddbj;
154   const char* Genbank;
155   const char* Desc;
156 } SeqODivision;
157 
158 
159 static SeqODivision seqDivision[] =
160 {
161 /*   Name      Embl   DDBJ   Genbank Description */
162     {"default","UNC", "UNA", "UNA",  "Unclassified"},
163     {"CON",    "CON", "CON", "CON",  "Contig"},
164     {"ENV",    "ENV", "",    "",     "Environmental Sample"},
165     {"FUN",    "FUN", "",    "PLN",  "Fungal"},
166     {"HUM",    "HUM", "HUM", "PRI",  "Human"},
167     {"INV",    "INV", "INV", "INV",  "Invertebrate"},
168     {"MAM",    "MAM", "MAM", "MAM",  "Other Mammal"},
169     {"MAMPRI", "MAM", "",    "PRI",  "Primate"},
170     {"MUS",    "MUS", "ROD", "ROD",  "Mus musculus"},
171     {"PHG",    "PHG", "PHG", "PHG",  "Bacteriophage"},
172     {"PLN",    "PLN", "PLN", "PLN",  "Plant"},
173     {"PRO",    "PRO", "BCT", "BCT",  "Prokaryote"},
174     {"ROD",    "ROD", "ROD", "ROD",  "Other Rodent"},
175     {"SYN",    "SYN", "SYN", "SYN",  "Synthetic and chimeric"},
176     {"TGN",    "TGN", "",    "",     "Transgenic"},
177     {"UNC",    "UNC", "",    "",     "Unclassified"},
178     {"VRL",    "VRL", "VRL", "VRL",  "Viral"},
179     {"VRT",    "VRT", "VRT", "VRT",  "Other Vertebrate"},
180     {"UNA",    "UNC", "UNA", "UNA",  "Unannotated"},
181     {"UNCRNA", "UNC", "",    "RNA",  "Structural RNA"}, /* obsolete ? */
182     {"", "", "", "", ""},
183     {NULL, NULL, NULL, NULL, NULL}
184 };
185 
186 
187 
188 
189 /* @datastatic SeqOMolecule ***************************************************
190 **
191 ** Molecule types in the sequence databases
192 **
193 ** For EMBL and EMBOSS internal, see the
194 ** feature source qualifier /mol_type values in
195 ** http://www.ebi.ac.uk/embl/WebFeat/index.html
196 **
197 ** @attr Name [const char*] Name used internally
198 ** @attr Embl [const char*] Name in EMBL
199 ** @attr Ddbj [const char*] Name in DDBJ
200 ** @attr Genbank [const char*] Name in Genbank
201 ** @attr Desc [const char*] Description
202 ******************************************************************************/
203 
204 typedef struct SeqSMolecule
205 {
206   const char* Name;
207   const char* Embl;
208   const char* Ddbj;
209   const char* Genbank;
210   const char* Desc;
211 } SeqOMolecule;
212 
213 
214 static SeqOMolecule seqMolecule[] =
215 {
216 /*   Name      Embl   DDBJ   Genbank Description */
217     {"unassigned DNA", "unassigned DNA", "DNA", "DNA", "unassigned DNA"},
218     {"genomic DNA", "genomic DNA", "DNA", "DNA", "genomic DNA"},
219     {"genomic RNA", "genomic RNA", "DNA", "RNA", "genomic RNA"},
220     {"mRNA", "mRNA", "mRNA", "mRNA", "mRNA"},
221     {"tRNA", "tRNA", "RNA", "RNA", "tRNA"},
222     {"rRNA", "rRNA", "RNA", "RNA", "rRNA"},
223     {"snoRNA", "snoRNA", "RNA", "RNA", "snoRNA"},
224     {"snRNA", "snRNA", "RNA", "RNA", "snRNA"},
225     {"snRNA", "snRNA", "RNA", "RNA", "snRNA"},
226     {"scRNA", "scRNA", "RNA", "RNA", "scRNA"},
227     {"pre-RNA", "pre-RNA", "RNA", "RNA", "pre-RNA"},
228     {"viral cRNA", "viral cRNA", "RNA", "RNA", "viral cRNA"},
229     {"other RNA", "other RNA", "RNA", "RNA", "other RNA"},
230     {"other DNA", "other DNA", "DNA", "DNA", "other DNA"},
231     {"unassigned RNA", "unassigned RNA", "RNA", "RNA", "unassigned RNA"},
232     {NULL, NULL, NULL, NULL, NULL}
233 };
234 
235 
236 
237 
238 /* @datastatic SeqOTaxon ******************************************************
239 **
240 ** Known major taxa in the sequence databases
241 **
242 ** Reference for this is
243 ** http://www.ncbi.nlm.nih.gov/Taxonomy/
244 **
245 ** @attr Taxid [ajuint] NCBI taxon id
246 ** @attr Standard [AjBool] Standard known taxon
247 ** @attr Name [const char*] Common name
248 ******************************************************************************/
249 
250 typedef struct SeqSTaxon
251 {
252   ajuint Taxid;
253   AjBool Standard;
254   const char* Name;
255 } SeqOTaxon;
256 
257 static SeqOTaxon seqTaxon[] =
258 {
259     { 3702, AJTRUE, "Arabidopsis thaliana"},
260     { 1432, AJTRUE, "Bacillus subtilis"},
261     { 9913, AJTRUE, "Bos taurus"},
262     { 6239, AJTRUE, "Caenorhabditis elegans"},
263     { 3055, AJTRUE, "Chlamydomonas reinhardtii"},
264     { 7955, AJTRUE, "Danio rario"},
265     {44689, AJTRUE, "Dictyostelium discoideum"},
266     { 7227, AJTRUE, "Drosophila melanogaster"},
267     {  562, AJTRUE, "Escherichia coli"},
268     {11103, AJTRUE, "Hepatitis C virus"},
269     { 9606, AJTRUE, "Homo sapiens"},
270     { 2104, AJTRUE, "Mycoplasma pneumoniae"},
271     {10090, AJTRUE, "Mus musculus"},
272     { 4530, AJTRUE, "Oryza sativa"},
273     { 5833, AJTRUE, "Plasmodium falciparum"},
274     { 4754, AJTRUE, "Pneumocystis carinii"},
275     {10116, AJTRUE, "Rattus norvegicus"},
276     { 4932, AJTRUE, "Saccharomyces cerevisiae"},
277     { 4896, AJTRUE, "Schizosaccharomyces pombe"},
278     {31033, AJTRUE, "Takifugu rubripes"},
279     { 8355, AJTRUE, "Xenopus laevis"},
280     { 4577, AJTRUE, "Zea mays"},
281     {    0, AJFALSE, NULL}
282 
283 };
284 
285 
286 
287 
288 /* @filesection ajseq ********************************************************
289 **
290 ** @nam1rule aj Function belongs to the AJAX library.
291 **
292 ******************************************************************************/
293 
294 
295 
296 
297 /* @datasection [AjPSeq] Sequence ********************************************
298 **
299 ** Function is for manipulating sequence objects
300 **
301 ** @nam2rule Seq
302 **
303 ******************************************************************************/
304 
305 
306 
307 
308 /* @section constructors *********************************************
309 **
310 ** All constructors return a new sequence by pointer. It is the
311 ** responsibility of the user to first destroy any previous
312 ** sequence. The target pointer does not need to be initialised to
313 ** NULL, but it is good programming practice to do so anyway.
314 **
315 ** @fdata [AjPSeq]
316 ** @fcategory new
317 **
318 ** @nam3rule New Constructor
319 ** @nam4rule NewName Constructor with new name
320 ** @nam4rule NewRange Constructor with range and direction
321 ** @nam4rule NewRefseq Constructor from a reference sequence
322 ** @nam4rule NewSeq Constructor with all details in an existing sequence
323 **
324 ** @suffix Res [size_t] Reserved length
325 ** @suffix S [const AjPSeq] Source sequence
326 ** @suffix C [const char*] Source sequence
327 **
328 ** @argrule Res size [size_t] Reserved size including the terminating NULL
329 ** @argrule C txt [const char*] Source sequence
330 ** @argrule S str [const AjPStr] Source sequence
331 ** @argrule NewRefseq refseq [const AjPRefseq] Reference sequence to be copied
332 ** @argrule NewSeq seq [const AjPSeq] Source sequence to be copied
333 ** @argrule NameC name [const char*] Sequence name
334 ** @argrule NameS name [const AjPStr] Sequence name
335 ** @argrule Range offset [ajint] Offset at start
336 ** @argrule Range offend [ajint] Offset at end
337 ** @argrule Range rev [AjBool] True if sequence is to be reversed
338 **
339 ** @valrule * [AjPSeq]
340 **
341 ******************************************************************************/
342 
343 
344 
345 
346 /* @func ajSeqNew *************************************************************
347 **
348 ** Creates and initialises a sequence object.
349 **
350 ** @return [AjPSeq] New sequence object.
351 **
352 ** @release 1.0.0
353 ** @@
354 ******************************************************************************/
355 
ajSeqNew(void)356 AjPSeq ajSeqNew(void)
357 {
358     return ajSeqNewRes(0);
359 }
360 
361 
362 
363 
364 /* @func ajSeqNewNameC ********************************************************
365 **
366 ** Creates and initialises a sequence object with a specified existing
367 ** sequence as a char*
368 **
369 ** @param [r] txt[const char*] Sequence string
370 ** @param [r] name [const char*] Sequence name
371 ** @return [AjPSeq] New sequence object.
372 **
373 ** @release 4.0.0
374 ** @@
375 ******************************************************************************/
376 
ajSeqNewNameC(const char * txt,const char * name)377 AjPSeq ajSeqNewNameC(const char* txt, const char* name)
378 {
379     AjPSeq pthis;
380 
381     pthis = ajSeqNew();
382 
383     ajStrAssignC(&pthis->Name, name);
384     ajStrAssignC(&pthis->Seq, txt);
385 
386     return pthis;
387 }
388 
389 
390 
391 
392 /* @func ajSeqNewNameS ********************************************************
393 **
394 ** Creates and initialises a sequence object with a specified existing
395 ** sequence as a string
396 **
397 ** @param [r] str [const AjPStr] Sequence string
398 ** @param [r] name [const AjPStr] Sequence name
399 ** @return [AjPSeq] New sequence object.
400 **
401 ** @release 4.0.0
402 ** @@
403 ******************************************************************************/
404 
ajSeqNewNameS(const AjPStr str,const AjPStr name)405 AjPSeq ajSeqNewNameS(const AjPStr str, const AjPStr name)
406 {
407     AjPSeq pthis;
408 
409     pthis = ajSeqNew();
410 
411     pthis->Name = ajStrNewS(name);
412     ajStrAssignS(&pthis->Seq, str);
413 
414     return pthis;
415 }
416 
417 
418 
419 
420 /* @func ajSeqNewRangeC *******************************************************
421 **
422 ** Creates and initialises a sequence object with a specified existing
423 ** sequence as a string, and provides offsets and direction.
424 **
425 ** The sequence is set to be already trimmed and if necessary reversed.
426 **
427 ** Start and end positions are 0 (full sequence), as it is trimmed.
428 ** Any start and end are represented by the offsets.
429 **
430 ** @param [r] txt [const char*] Sequence string
431 ** @param [r] offset [ajint] Offset at start
432 ** @param [r] offend [ajint] Offset at end
433 ** @param [r] rev [AjBool] Reversed if true (reverses offsets)
434 ** @return [AjPSeq] New sequence object.
435 **
436 ** @release 4.0.0
437 ** @@
438 ******************************************************************************/
439 
ajSeqNewRangeC(const char * txt,ajint offset,ajint offend,AjBool rev)440 AjPSeq ajSeqNewRangeC(const char* txt,
441 		       ajint offset, ajint offend, AjBool rev)
442 {
443     AjPSeq pthis;
444 
445     pthis = ajSeqNew();
446 
447     ajDebug("ajSeqNewRangeC %d %d %B\n",
448 	    offset, offend, rev);
449 
450     ajStrAssignC(&pthis->Seq, txt);
451 
452     pthis->Rev      = ajFalse;
453     pthis->Reversed = rev;		/* we are setting everything here */
454     pthis->Trimmed  = ajTrue;		/* we are setting everything here */
455 
456     pthis->EType  = 0;
457     pthis->Format = 0;
458     pthis->Begin  = 0;
459     pthis->End    = 0;
460 
461     if (rev)
462     {
463 	pthis->Offset = offend;
464 	pthis->Offend = offset;
465     }
466     else
467     {
468 	pthis->Offset = offset;
469 	pthis->Offend = offend;
470     }
471 
472     pthis->Weight = 1.0;
473 
474     ajDebug("ajSeqNewRangeC rev:%B offset:%d/%d offend:%d/%d\n",
475 	    rev, offset, pthis->Offset, offend, pthis->Offend);
476 
477     return pthis;
478 }
479 
480 
481 
482 
483 /* @func ajSeqNewRangeS *******************************************************
484 **
485 ** Creates and initialises a sequence object with a specified existing
486 ** sequence as a string, and provides offsets and direction.
487 **
488 ** The sequence is set to be already trimmed and if necessary reversed.
489 **
490 ** Start and end positions are 0 (full sequence), as it is trimmed.
491 ** Any start and end are represented by the offsets.
492 **
493 ** @param [r] str [const AjPStr] Sequence string
494 ** @param [r] offset [ajint] Offset at start
495 ** @param [r] offend [ajint] Offset at end
496 ** @param [r] rev [AjBool] Reversed if true (reverses offsets)
497 ** @return [AjPSeq] New sequence object.
498 **
499 ** @release 4.0.0
500 ** @@
501 ******************************************************************************/
502 
ajSeqNewRangeS(const AjPStr str,ajint offset,ajint offend,AjBool rev)503 AjPSeq ajSeqNewRangeS(const AjPStr str,
504 			ajint offset, ajint offend, AjBool rev)
505 {
506     return ajSeqNewRangeC(ajStrGetPtr(str), offset, offend, rev);
507 }
508 
509 
510 
511 
512 /* @func ajSeqNewRefseq *******************************************************
513 **
514 ** Creates and initialises a sequence object with a specified existing
515 ** reference sequence.
516 **
517 ** @param [r] refseq [const AjPRefseq] Reference sequence object
518 ** @return [AjPSeq] New sequence object.
519 **
520 ** @release 4.0.0
521 ** @@
522 ******************************************************************************/
523 
ajSeqNewRefseq(const AjPRefseq refseq)524 AjPSeq ajSeqNewRefseq(const AjPRefseq refseq)
525 {
526     AjPSeq pthis;
527 
528     AJNEW0(pthis);
529 
530     if(refseq->Id)
531         ajStrAssignS(&pthis->Name, refseq->Id);
532 
533     if(refseq->Db)
534         ajStrAssignS(&pthis->Db, refseq->Db);
535     if(refseq->Desc)
536         ajStrAssignS(&pthis->Desc, refseq->Desc);
537 
538     if(refseq->Qry)
539         ajStrAssignS(&pthis->Usa, refseq->Qry);
540 
541     if(refseq->Filename)
542         ajStrAssignS(&pthis->Filename, refseq->Filename);
543 
544     ajStrAssignS(&pthis->Seq, refseq->Seq);
545 
546     return pthis;
547 }
548 
549 
550 
551 
552 /* @func ajSeqNewRes **********************************************************
553 **
554 ** Creates and initialises a sequence object with a specified sequence length.
555 **
556 ** @param [r] size [size_t] Reserved space for the sequence, including
557 **                          a trailing null character.
558 ** @return [AjPSeq] New sequence object.
559 **
560 ** @release 4.0.0
561 ** @@
562 ******************************************************************************/
563 
ajSeqNewRes(size_t size)564 AjPSeq ajSeqNewRes(size_t size)
565 {
566     AjPSeq pthis;
567 
568     AJNEW0(pthis);
569 
570     pthis->Name = ajStrNew();
571     pthis->Acc  = ajStrNew();
572 /*
573 //    pthis->Sv   = ajStrNew();
574 //    pthis->Gi   = ajStrNew();
575 //    pthis->Tax  = ajStrNew();
576 //    pthis->Taxcommon  = ajStrNew();
577 //    pthis->Taxid = ajStrNew();
578 //    pthis->Organelle = ajStrNew();
579 //    pthis->Type = ajStrNew();
580 //    pthis->Db   = ajStrNew();
581 //    pthis->Full = ajStrNew();
582 //    pthis->Desc = ajStrNew();
583 //    pthis->Doc  = ajStrNew();
584 //    pthis->Usa  = ajStrNew();
585 //    pthis->Ufo  = ajStrNew();
586 //
587 //    pthis->Formatstr = ajStrNew();
588 //    pthis->Filename  = ajStrNew();
589 //    pthis->Entryname = ajStrNew();
590 //    pthis->TextPtr   = ajStrNew();
591 */
592     if(size)
593 	pthis->Seq = ajStrNewRes(size);
594     else
595 	pthis->Seq = ajStrNew();
596 
597     pthis->Rev      = ajFalse;
598     pthis->Reversed = ajFalse;
599     pthis->Trimmed = ajFalse;
600 
601     pthis->EType   = 0;
602     pthis->Format  = 0;
603     pthis->Begin   = 0;
604     pthis->End     = 0;
605     pthis->Offset  = 0;
606     pthis->Offend  = 0;
607     pthis->Weight  = 1.0;
608 /*
609 //    pthis->Acclist = ajListstrNew();
610 //    pthis->Keylist = ajListstrNew();
611 //    pthis->Taxlist = ajListstrNew();
612 //    pthis->Genelist = ajListNew();
613 //    pthis->Cmtlist = ajListstrNew();
614 //    pthis->Xreflist = ajListNew();
615 //    pthis->Reflist = ajListNew();
616 //
617 //    pthis->Fulldesc = ajSeqdescNew();
618 */
619      return pthis;
620 }
621 
622 
623 
624 
625 /* @func ajSeqNewSeq **********************************************************
626 **
627 ** Creates and initialises a sequence object with a specified existing
628 ** sequence.
629 **
630 ** @param [r] seq [const AjPSeq] Old sequence object
631 ** @return [AjPSeq] New sequence object.
632 **
633 ** @release 4.0.0
634 ** @@
635 ******************************************************************************/
636 
ajSeqNewSeq(const AjPSeq seq)637 AjPSeq ajSeqNewSeq(const AjPSeq seq)
638 {
639     AjPSeq pthis;
640 
641     AJNEW0(pthis);
642 
643     if(seq->Name)
644         ajStrAssignS(&pthis->Name, seq->Name);
645     if(seq->Acc)
646         ajStrAssignS(&pthis->Acc, seq->Acc);
647     if(seq->Sv)
648         ajStrAssignS(&pthis->Sv, seq->Sv);
649     if(seq->Gi)
650         ajStrAssignS(&pthis->Gi, seq->Gi);
651     if(seq->Tax)
652         ajStrAssignS(&pthis->Tax, seq->Tax);
653     if(seq->Taxcommon)
654         ajStrAssignS(&pthis->Taxcommon, seq->Taxcommon);
655     if(seq->Taxid)
656         ajStrAssignS(&pthis->Taxid, seq->Taxid);
657     if(seq->Organelle)
658         ajStrAssignS(&pthis->Organelle, seq->Organelle);
659     if(seq->Type)
660         ajStrAssignS(&pthis->Type, seq->Type);
661 
662     pthis->EType  = seq->EType;
663 
664     if(seq->Db)
665         ajStrAssignS(&pthis->Db, seq->Db);
666     if(seq->Setdb)
667         ajStrAssignS(&pthis->Setdb, seq->Setdb);
668     if(seq->Full)
669         ajStrAssignS(&pthis->Full, seq->Full);
670     if(seq->Desc)
671         ajStrAssignS(&pthis->Desc, seq->Desc);
672     if(seq->Doc)
673         ajStrAssignS(&pthis->Doc, seq->Doc);
674 
675     pthis->Rev      = seq->Rev;
676     pthis->Reversed = seq->Reversed;
677     pthis->Trimmed  = seq->Trimmed;
678 
679     pthis->Begin  = seq->Begin;
680     pthis->End    = seq->End;
681     pthis->Offset = seq->Offset;
682     pthis->Offend = seq->Offend;
683     pthis->Weight = seq->Weight;
684     pthis->Fpos   = seq->Fpos;
685 
686     if(seq->Usa)
687         ajStrAssignS(&pthis->Usa, seq->Usa);
688     if(seq->Ufo)
689         ajStrAssignS(&pthis->Ufo, seq->Ufo);
690     if(seq->Formatstr)
691         ajStrAssignS(&pthis->Formatstr, seq->Formatstr);
692     pthis->Format = seq->Format;
693 
694     if(seq->Filename)
695         ajStrAssignS(&pthis->Filename, seq->Filename);
696     if(seq->Entryname)
697         ajStrAssignS(&pthis->Entryname, seq->Entryname);
698 
699     if(seq->TextPtr)
700 	ajStrAssignS(&pthis->TextPtr, seq->TextPtr);
701 
702     if(seq->Acclist)
703         pthis->Acclist = ajListstrNewList(seq->Acclist);
704     if(seq->Keylist)
705         pthis->Keylist = ajListstrNewList(seq->Keylist);
706     if(seq->Taxlist)
707         pthis->Taxlist = ajListstrNewList(seq->Taxlist);
708     if(seq->Cmtlist)
709         pthis->Cmtlist = ajListstrNewList(seq->Cmtlist);
710     if(seq->Hostlist)
711         pthis->Hostlist = ajListstrNewList(seq->Hostlist);
712 
713     if(seq->Xreflist)
714     {
715         pthis->Xreflist = ajListNew();
716         ajSeqxreflistClone(seq->Xreflist, pthis->Xreflist);
717     }
718 
719     if(seq->Genelist)
720     {
721         pthis->Genelist = ajListNew();
722         ajSeqgenelistClone(seq->Genelist, pthis->Genelist);
723     }
724 
725     if(seq->Reflist)
726     {
727         pthis->Reflist = ajListNew();
728         ajSeqreflistClone(seq->Reflist, pthis->Reflist);
729     }
730 
731     if(seq->Fulldesc)
732         pthis->Fulldesc = ajSeqdescNewDesc(seq->Fulldesc);
733 
734     ajStrAssignS(&pthis->Seq, seq->Seq);
735 
736     if (seq->Fttable)
737 	pthis->Fttable = ajFeattableNewFtable(seq->Fttable);
738 
739     if (seq->Accuracy && seq->Qualsize)
740     {
741         pthis->Qualsize = seq->Qualsize;
742     	AJCNEW0(pthis->Accuracy,pthis->Qualsize);
743     	memmove(pthis->Accuracy,seq->Accuracy,pthis->Qualsize*sizeof(float));
744     }
745 
746     return pthis;
747 }
748 
749 
750 
751 
752 /* @section destructors **********************************************
753 **
754 ** Destruction destroys all internal data structures and frees the
755 ** memory allocated for the sequence.
756 **
757 ** @fdata [AjPSeq]
758 ** @fcategory delete
759 **
760 ** @nam3rule Del Destroy (free) a sequence object
761 ** @nam3rule Delarray Array destructor
762 **
763 ** @argrule Del Pseq [AjPSeq*] Sequence object address
764 ** @argrule Delarray PPseq [AjPSeq**] Sequence object array
765 **
766 ** @valrule * [void]
767 **
768 ******************************************************************************/
769 
770 
771 
772 
773 /* @func ajSeqDel *************************************************************
774 **
775 ** Deletes a sequence object.
776 **
777 ** @param [d] Pseq [AjPSeq*] Sequence object
778 ** @return [void]
779 **
780 ** @release 1.0.0
781 ** @@
782 ******************************************************************************/
783 
ajSeqDel(AjPSeq * Pseq)784 void ajSeqDel(AjPSeq* Pseq)
785 {
786     AjPSeq seq;
787     AjPSeqRef  tmpref  = NULL;
788     AjPSeqXref tmpxref = NULL;
789     AjPSeqGene tmpgene = NULL;
790 
791     seq = Pseq ? *Pseq : 0;
792 
793     if(!Pseq)
794 	return;
795 
796     if(!*Pseq)
797 	return;
798 
799     ajStrDel(&seq->Name);
800     ajStrDel(&seq->Acc);
801     ajStrDel(&seq->Sv);
802     ajStrDel(&seq->Gi);
803     ajStrDel(&seq->Tax);
804     ajStrDel(&seq->Taxcommon);
805     ajStrDel(&seq->Taxid);
806     ajStrDel(&seq->Organelle);
807     ajStrDel(&seq->Type);
808     ajStrDel(&seq->Molecule);
809     ajStrDel(&seq->Class);
810     ajStrDel(&seq->Division);
811     ajStrDel(&seq->Evidence);
812     ajStrDel(&seq->Db);
813     ajStrDel(&seq->Setdb);
814     ajStrDel(&seq->Full);
815     ajStrDel(&seq->Desc);
816     ajStrDel(&seq->Doc);
817     ajStrDel(&seq->Usa);
818     ajStrDel(&seq->Ufo);
819     ajStrDel(&seq->Formatstr);
820     ajStrDel(&seq->Filename);
821     ajStrDel(&seq->Entryname);
822     ajStrDel(&seq->TextPtr);
823     ajStrDel(&seq->Seq);
824     AJFREE(seq->Accuracy);
825 
826     if(seq->Fttable)
827 	ajFeattableDel(&seq->Fttable);
828 
829     ajListstrFreeData(&seq->Acclist);
830 
831     ajListstrFreeData(&seq->Keylist);
832 
833     ajListstrFreeData(&seq->Taxlist);
834 
835     while(ajListPop(seq->Genelist,(void **)&tmpgene))
836 	ajSeqgeneDel(&tmpgene);
837 
838     ajListFree(&seq->Genelist);
839 
840     while(ajListPop(seq->Reflist,(void **)&tmpref))
841 	ajSeqrefDel(&tmpref);
842 
843     ajListFree(&seq->Reflist);
844 
845     ajListstrFreeData(&seq->Cmtlist);
846     ajListstrFreeData(&seq->Hostlist);
847 
848     while(ajListPop(seq->Xreflist,(void **)&tmpxref))
849 	ajSeqxrefDel(&tmpxref);
850 
851     ajListFree(&seq->Xreflist);
852 
853     ajSeqdateDel(&seq->Date);
854     ajSeqdescDel(&seq->Fulldesc);
855 
856     AJFREE(*Pseq);
857 
858     return;
859 }
860 
861 
862 
863 
864 /* @func ajSeqDelarray ********************************************************
865 **
866 ** Destructor for array of sequence objects
867 **
868 ** @param [d] PPseq [AjPSeq**] Sequence object array
869 ** @return [void]
870 **
871 ** @release 6.0.0
872 ** @@
873 ******************************************************************************/
874 
ajSeqDelarray(AjPSeq ** PPseq)875 void ajSeqDelarray(AjPSeq **PPseq)
876 {
877     ajuint i = 0;
878 
879     if(!PPseq || !*PPseq)
880 	return;
881 
882     while((*PPseq)[i])
883     {
884 	ajSeqDel(&(*PPseq)[i]);
885 	i++;
886     }
887 
888     ajDebug("ajSeqDelarray size: %d\n", i);
889 
890     AJFREE(*PPseq);
891 
892     return;
893 }
894 
895 
896 
897 
898 /* @section modifiers ************************************************
899 **
900 ** These functions update contents of a sequence object.
901 **
902 ** @fdata [AjPSeq]
903 ** @fcategory modify
904 **
905 ** @nam3rule Assign Assign one attribute of a sequence
906 ** @nam4rule AssignAcc Assign accession number
907 ** @nam4rule AssignDesc Assign description text
908 ** @nam4rule AssignEntry Assign entry name
909 ** @nam4rule AssignFile Assign file name
910 ** @nam4rule AssignFull Assign full name
911 ** @nam4rule AssignGi Assign GI number
912 ** @nam4rule AssignName Assign sequence name
913 ** @nam4rule AssignQual Assign quality scores
914 ** @nam4rule AssignSeq Assign sequence
915 ** @nam4rule AssignSv Assign sequence version number
916 ** @nam4rule AssignUfo Assign feature address
917 ** @nam4rule AssignUsa Assign sequence address
918 **
919 ** @nam3rule Clear     Clear all contents
920 **
921 ** @nam3rule Add     Add to a list of data
922 ** @nam4rule AddCmt Add to a gene list
923 ** @nam4rule AddGene Add to a gene list
924 ** @nam4rule AddHost Add to a virus host list
925 ** @nam4rule AddKey Add to a keyword list
926 ** @nam4rule AddRef  Add to a reference list
927 ** @nam4rule AddXref  Add to a cross-reference list
928 **
929 ** @nam3rule Set Set sequence properties
930 ** @nam4rule SetCircular Set sequence as circular
931 ** @nam4rule SetName Set sequence name
932 ** @nam5rule SetNameMulti Set sequence name, adding a number for later calls
933 ** @nam4rule SetOffsets Set sequence offsets as a subsequence of an original
934 ** @nam4rule SetRange Set start and end position within sequence
935 ** @nam5rule SetRangeRev Set start and end position and reverse direction
936 **                       of a sequence
937 ** @nam4rule SetUnique Make sure sequence is modifiable (no other pointer
938 **                     uses the same internal string)
939 ** @nam3rule Tag       Add tag to the sequence description
940 ** @nam4rule TagRev    Add 'Reversed' tag to the sequence description
941 **
942 ** @suffix Len [ajint] Length of character string
943 ** @suffix C [const char*] Character string
944 ** @suffix S [const AjPStr] String
945 **
946 ** @argrule * seq [AjPSeq] Sequence object
947 ** @argrule Qual qual [const float*] Array of quality scores
948 ** @argrule C txt [const char*] Character string to assign
949 ** @argrule Len len [ajuint] Character string length
950 ** @argrule S str [const AjPStr] String to assign
951 ** @argrule Offsets offset [ajint] Offset at start
952 ** @argrule Offsets origlen [ajint] Length of original sequence
953 ** @argrule Range pos1 [ajint] Start position
954 ** @argrule Range pos2 [ajint] End  position
955 ** @argrule SetName setname [const AjPStr] User-defined sequence name
956 ** @argrule Cmt str [AjPStr] Comment added to internal list
957 ** @argrule Gene gene [AjPSeqGene] Gene object added to internal list
958 ** @argrule Host str [AjPStr] Viral host added to internal list
959 ** @argrule Key str [AjPStr] Keyword added to internal list
960 ** @argrule Ref ref [AjPSeqRef] Citation object added to internal list
961 ** @argrule Xref xref [AjPSeqXref] Cross-reference object added to internal list
962 **
963 ** @valrule * [void]
964 **
965 ******************************************************************************/
966 
967 
968 
969 
970 /* @func ajSeqAddCmt **********************************************************
971 **
972 ** Adds a comment to a sequence object
973 **
974 ** @param [u] seq [AjPSeq] Sequence object.
975 ** @param [u] str [AjPStr] Comment.
976 ** @return [void]
977 **
978 ** @release 6.2.0
979 ** @@
980 ******************************************************************************/
981 
ajSeqAddCmt(AjPSeq seq,AjPStr str)982 void ajSeqAddCmt(AjPSeq seq,  AjPStr str)
983 {
984     if(!seq->Cmtlist)
985         seq->Cmtlist = ajListstrNew();
986 
987     ajListstrPushAppend(seq->Cmtlist, str);
988 
989     return;
990 }
991 
992 
993 
994 
995 /* @func ajSeqAddGene *********************************************************
996 **
997 ** Adds a gene to a sequence object
998 **
999 ** @param [u] seq [AjPSeq] Sequence object.
1000 ** @param [u] gene [AjPSeqGene] Gene object
1001 ** @return [void]
1002 **
1003 ** @release 6.2.0
1004 ** @@
1005 ******************************************************************************/
1006 
ajSeqAddGene(AjPSeq seq,AjPSeqGene gene)1007 void ajSeqAddGene(AjPSeq seq, AjPSeqGene gene)
1008 {
1009     if(!seq->Genelist)
1010         seq->Genelist = ajListNew();
1011 
1012     ajListPushAppend(seq->Genelist, gene);
1013 
1014     return;
1015 }
1016 
1017 
1018 
1019 
1020 /* @func ajSeqAddHost *********************************************************
1021 **
1022 ** Adds a host organism to a sequence object
1023 **
1024 ** @param [u] seq [AjPSeq] Sequence object.
1025 ** @param [u] str [AjPStr] Host organism swissprot formatted string
1026 ** @return [void]
1027 **
1028 ** @release 6.6.0
1029 ** @@
1030 ******************************************************************************/
1031 
ajSeqAddHost(AjPSeq seq,AjPStr str)1032 void ajSeqAddHost(AjPSeq seq,  AjPStr str)
1033 {
1034     if(!seq->Hostlist)
1035         seq->Hostlist = ajListstrNew();
1036 
1037     ajListstrPushAppend(seq->Hostlist, str);
1038 
1039     return;
1040 }
1041 
1042 
1043 
1044 
1045 /* @func ajSeqAddKey **********************************************************
1046 **
1047 ** Adds a keyword to a sequence object
1048 **
1049 ** @param [u] seq [AjPSeq] Sequence object.
1050 ** @param [u] str [AjPStr] Comment.
1051 ** @return [void]
1052 **
1053 ** @release 6.2.0
1054 ** @@
1055 ******************************************************************************/
1056 
ajSeqAddKey(AjPSeq seq,AjPStr str)1057 void ajSeqAddKey(AjPSeq seq, AjPStr str)
1058 {
1059     if(!seq->Keylist)
1060         seq->Keylist = ajListstrNew();
1061 
1062     ajListstrPushAppend(seq->Keylist, str);
1063 
1064     return;
1065 }
1066 
1067 
1068 
1069 
1070 /* @func ajSeqAddRef **********************************************************
1071 **
1072 ** Adds a literature reference to a sequence object
1073 **
1074 ** @param [u] seq [AjPSeq] Sequence object.
1075 ** @param [u] ref [AjPSeqRef] Literature reference.
1076 ** @return [void]
1077 **
1078 ** @release 6.2.0
1079 ** @@
1080 ******************************************************************************/
1081 
ajSeqAddRef(AjPSeq seq,AjPSeqRef ref)1082 void ajSeqAddRef(AjPSeq seq, AjPSeqRef ref)
1083 {
1084     if(!seq->Reflist)
1085         seq->Reflist = ajListNew();
1086 
1087     ajListPushAppend(seq->Reflist, ref);
1088 
1089     return;
1090 }
1091 
1092 
1093 
1094 
1095 /* @func ajSeqAddXref *********************************************************
1096 **
1097 ** Adds a cross-reference to a sequence object
1098 **
1099 ** @param [u] seq [AjPSeq] Sequence object.
1100 ** @param [u] xref [AjPSeqXref] Comment.
1101 ** @return [void]
1102 **
1103 ** @release 6.2.0
1104 ** @@
1105 ******************************************************************************/
1106 
ajSeqAddXref(AjPSeq seq,AjPSeqXref xref)1107 void ajSeqAddXref(AjPSeq seq, AjPSeqXref xref)
1108 {
1109     if(!seq->Xreflist)
1110         seq->Xreflist = ajListNew();
1111 
1112     ajListPushAppend(seq->Xreflist, xref);
1113 
1114     return;
1115 }
1116 
1117 
1118 
1119 
1120 /* @func ajSeqAssignAccC ******************************************************
1121 **
1122 ** Assigns the sequence accession number.
1123 **
1124 ** @param [u] seq [AjPSeq] Sequence object.
1125 ** @param [r] txt [const char*] Accession number as a C character string.
1126 ** @return [void]
1127 **
1128 ** @release 4.0.0
1129 ** @@
1130 ******************************************************************************/
1131 
ajSeqAssignAccC(AjPSeq seq,const char * txt)1132 void ajSeqAssignAccC(AjPSeq seq, const char* txt)
1133 {
1134     ajStrAssignC(&seq->Acc, txt);
1135 
1136     return;
1137 }
1138 
1139 
1140 
1141 
1142 /* @func ajSeqAssignAccS ******************************************************
1143 **
1144 ** Assigns the sequence accession number.
1145 **
1146 ** @param [u] seq [AjPSeq] Sequence object.
1147 ** @param [r] str [const AjPStr] Accession number as a string.
1148 ** @return [void]
1149 **
1150 ** @release 4.0.0
1151 ** @@
1152 ******************************************************************************/
1153 
ajSeqAssignAccS(AjPSeq seq,const AjPStr str)1154 void ajSeqAssignAccS(AjPSeq seq, const AjPStr str)
1155 {
1156     ajStrAssignS(&seq->Acc, str);
1157 
1158     return;
1159 }
1160 
1161 
1162 
1163 
1164 /* @func ajSeqAssignDescC *****************************************************
1165 **
1166 ** Assigns a modified description to an existing AjPSeq sequence.
1167 **
1168 ** @param [u] seq [AjPSeq] Sequence object.
1169 ** @param [r] txt [const char*] New description as a C character string.
1170 ** @return [void]
1171 **
1172 ** @release 4.0.0
1173 ** @@
1174 ******************************************************************************/
1175 
ajSeqAssignDescC(AjPSeq seq,const char * txt)1176 void ajSeqAssignDescC(AjPSeq seq, const char* txt)
1177 {
1178     ajStrAssignC(&seq->Desc, txt);
1179 
1180     return;
1181 }
1182 
1183 
1184 
1185 
1186 /* @func ajSeqAssignDescS *****************************************************
1187 **
1188 ** Assigns a modified description to an existing AjPSeq sequence.
1189 **
1190 ** @param [u] seq [AjPSeq] Sequence object.
1191 ** @param [r] str [const AjPStr] New description as a string.
1192 ** @return [void]
1193 **
1194 ** @release 4.0.0
1195 ** @@
1196 ******************************************************************************/
1197 
ajSeqAssignDescS(AjPSeq seq,const AjPStr str)1198 void ajSeqAssignDescS(AjPSeq seq, const AjPStr str)
1199 {
1200     ajStrAssignS(&seq->Desc, str);
1201 
1202     return;
1203 }
1204 
1205 
1206 
1207 
1208 /* @func ajSeqAssignEntryC ****************************************************
1209 **
1210 ** Assigns the sequence entryname.
1211 **
1212 ** @param [u] seq [AjPSeq] Sequence object.
1213 ** @param [r] txt [const char*] Entry name as a C character string.
1214 ** @return [void]
1215 **
1216 ** @release 4.0.0
1217 ** @@
1218 ******************************************************************************/
1219 
ajSeqAssignEntryC(AjPSeq seq,const char * txt)1220 void ajSeqAssignEntryC(AjPSeq seq, const char* txt)
1221 {
1222     ajStrAssignC(&seq->Entryname, txt);
1223 
1224     return;
1225 }
1226 
1227 
1228 
1229 
1230 /* @func ajSeqAssignEntryS ****************************************************
1231 **
1232 ** Assigns the sequence entryname.
1233 **
1234 ** @param [u] seq [AjPSeq] Sequence object.
1235 ** @param [r] str [const AjPStr] Entry name as a string.
1236 ** @return [void]
1237 **
1238 ** @release 4.0.0
1239 ** @@
1240 ******************************************************************************/
1241 
ajSeqAssignEntryS(AjPSeq seq,const AjPStr str)1242 void ajSeqAssignEntryS(AjPSeq seq, const AjPStr str)
1243 {
1244     ajStrAssignS(&seq->Entryname, str);
1245 
1246     return;
1247 }
1248 
1249 
1250 
1251 
1252 /* @func ajSeqAssignFileC *****************************************************
1253 **
1254 ** Assigns the sequence filename.
1255 **
1256 ** @param [u] seq [AjPSeq] Sequence object.
1257 ** @param [r] txt [const char*] File name as a C character string.
1258 ** @return [void]
1259 **
1260 ** @release 4.0.0
1261 ** @@
1262 ******************************************************************************/
1263 
ajSeqAssignFileC(AjPSeq seq,const char * txt)1264 void ajSeqAssignFileC(AjPSeq seq, const char* txt)
1265 {
1266     ajStrAssignC(&seq->Filename, txt);
1267 
1268     return;
1269 }
1270 
1271 
1272 
1273 
1274 /* @func ajSeqAssignFileS *****************************************************
1275 **
1276 ** Assigns the sequence file name.
1277 **
1278 ** @param [u] seq [AjPSeq] Sequence object.
1279 ** @param [r] str [const AjPStr] File name as a string.
1280 ** @return [void]
1281 **
1282 ** @release 4.0.0
1283 ** @@
1284 ******************************************************************************/
1285 
ajSeqAssignFileS(AjPSeq seq,const AjPStr str)1286 void ajSeqAssignFileS(AjPSeq seq, const AjPStr str)
1287 {
1288     ajStrAssignS(&seq->Filename, str);
1289 
1290     return;
1291 }
1292 
1293 
1294 
1295 
1296 /* @func ajSeqAssignFullC *****************************************************
1297 **
1298 ** Assigns the sequence name.
1299 **
1300 ** @param [u] seq [AjPSeq] Sequence object.
1301 ** @param [r] txt [const char*] Full name as a C character string.
1302 ** @return [void]
1303 **
1304 ** @release 4.0.0
1305 ** @@
1306 ******************************************************************************/
1307 
ajSeqAssignFullC(AjPSeq seq,const char * txt)1308 void ajSeqAssignFullC(AjPSeq seq, const char* txt)
1309 {
1310     ajStrAssignC(&seq->Full, txt);
1311 
1312     return;
1313 }
1314 
1315 
1316 
1317 
1318 /* @func ajSeqAssignFullS *****************************************************
1319 **
1320 ** Assigns the sequence full name.
1321 **
1322 ** @param [u] seq [AjPSeq] Sequence object.
1323 ** @param [r] str [const AjPStr] Full name as a string.
1324 ** @return [void]
1325 **
1326 ** @release 4.0.0
1327 ** @@
1328 ******************************************************************************/
1329 
ajSeqAssignFullS(AjPSeq seq,const AjPStr str)1330 void ajSeqAssignFullS(AjPSeq seq, const AjPStr str)
1331 {
1332     ajStrAssignS(&seq->Full, str);
1333 
1334     return;
1335 }
1336 
1337 
1338 
1339 
1340 
1341 /* @func ajSeqAssignGiC *******************************************************
1342 **
1343 ** Assigns the GI version number.
1344 **
1345 ** @param [u] seq [AjPSeq] Sequence object.
1346 ** @param [r] txt [const char*] GI number as a C character string.
1347 ** @return [void]
1348 **
1349 ** @release 4.0.0
1350 ** @@
1351 ******************************************************************************/
1352 
ajSeqAssignGiC(AjPSeq seq,const char * txt)1353 void ajSeqAssignGiC(AjPSeq seq, const char* txt)
1354 {
1355     ajStrAssignC(&seq->Gi, txt);
1356 
1357     return;
1358 }
1359 
1360 
1361 
1362 
1363 /* @func ajSeqAssignGiS *******************************************************
1364 **
1365 ** Assigns the GI version number.
1366 **
1367 ** @param [u] seq [AjPSeq] Sequence object.
1368 ** @param [r] str [const AjPStr] GI number as a string.
1369 ** @return [void]
1370 **
1371 ** @release 4.0.0
1372 ** @@
1373 ******************************************************************************/
1374 
ajSeqAssignGiS(AjPSeq seq,const AjPStr str)1375 void ajSeqAssignGiS(AjPSeq seq, const AjPStr str)
1376 {
1377     ajStrAssignS(&seq->Gi, str);
1378 
1379     return;
1380 }
1381 
1382 
1383 
1384 
1385 /* @func ajSeqAssignNameC *****************************************************
1386 **
1387 ** Assigns the sequence name.
1388 **
1389 ** @param [u] seq [AjPSeq] Sequence object.
1390 ** @param [r] txt [const char*] Name as a string.
1391 ** @return [void]
1392 **
1393 ** @release 4.0.0
1394 ** @@
1395 ******************************************************************************/
1396 
ajSeqAssignNameC(AjPSeq seq,const char * txt)1397 void ajSeqAssignNameC(AjPSeq seq, const char* txt)
1398 {
1399     ajStrAssignC(&seq->Name, txt);
1400 
1401     return;
1402 }
1403 
1404 
1405 
1406 
1407 /* @func ajSeqAssignNameS *****************************************************
1408 **
1409 ** Assigns the sequence name.
1410 **
1411 ** @param [u] seq [AjPSeq] Sequence object.
1412 ** @param [r] str [const AjPStr] Name as a string.
1413 ** @return [void]
1414 **
1415 ** @release 4.0.0
1416 ** @@
1417 ******************************************************************************/
1418 
ajSeqAssignNameS(AjPSeq seq,const AjPStr str)1419 void ajSeqAssignNameS(AjPSeq seq, const AjPStr str)
1420 {
1421     ajStrAssignS(&seq->Name, str);
1422 
1423     return;
1424 }
1425 
1426 
1427 
1428 
1429 /* @func ajSeqAssignQualLen ***************************************************
1430 **
1431 ** Assigns base quality scores to an existing sequence.
1432 **
1433 ** @param [u] seq [AjPSeq] Sequence object.
1434 ** @param [r] qual [const float*] Base quality scores.
1435 ** @param [r] len [ajuint] Number of quality scores to use
1436 ** @return [void]
1437 **
1438 ** @release 6.3.0
1439 ** @@
1440 ******************************************************************************/
1441 
ajSeqAssignQualLen(AjPSeq seq,const float * qual,ajuint len)1442 void ajSeqAssignQualLen(AjPSeq seq, const float* qual, ajuint len)
1443 {
1444     seq->Qualsize = len;
1445 
1446     AJCRESIZE(seq->Accuracy,seq->Qualsize);
1447 
1448     memmove(seq->Accuracy, qual, seq->Qualsize*sizeof(float));
1449 
1450     return;
1451 }
1452 
1453 
1454 
1455 
1456 /* @func ajSeqAssignSeqC ******************************************************
1457 **
1458 ** Assigns a modified sequence to an existing AjPSeq sequence.
1459 **
1460 ** @param [u] seq [AjPSeq] Sequence object.
1461 ** @param [r] txt [const char*] New sequence as a C character string.
1462 ** @return [void]
1463 **
1464 ** @release 4.0.0
1465 ** @@
1466 ******************************************************************************/
1467 
ajSeqAssignSeqC(AjPSeq seq,const char * txt)1468 void ajSeqAssignSeqC(AjPSeq seq, const char* txt)
1469 {
1470     ajint i = strlen(txt);
1471     ajSeqAssignSeqLenC(seq, txt, i);
1472 
1473     return;
1474 }
1475 
1476 
1477 
1478 
1479 /* @func ajSeqAssignSeqLenC ***************************************************
1480 **
1481 ** Assigns a modified sequence to an existing AjPSeq sequence.
1482 **
1483 ** @param [u] seq [AjPSeq] Sequence object.
1484 ** @param [r] txt [const char*] New sequence as a C character string.
1485 ** @param [r] len [ajuint] Number of characters to use
1486 ** @return [void]
1487 **
1488 ** @release 4.0.0
1489 ** @@
1490 ******************************************************************************/
1491 
ajSeqAssignSeqLenC(AjPSeq seq,const char * txt,ajuint len)1492 void ajSeqAssignSeqLenC(AjPSeq seq, const char* txt, ajuint len)
1493 {
1494     ajStrAssignLenC(&seq->Seq, txt, len);
1495 
1496     seq->Begin  = 0;
1497     seq->End    = 0;
1498     seq->Offset = 0;
1499     seq->Offend = 0;
1500     seq->Rev      = ajFalse;
1501     seq->Reversed = ajFalse;
1502     seq->Trimmed  = ajFalse;
1503 
1504     return;
1505 }
1506 
1507 
1508 
1509 
1510 /* @func ajSeqAssignSeqS ******************************************************
1511 **
1512 ** Assigns a modified sequence to an existing AjPSeq sequence.
1513 **
1514 ** @param [u] seq [AjPSeq] Sequence object.
1515 ** @param [r] str [const AjPStr] New sequence as a string.
1516 ** @return [void]
1517 **
1518 ** @release 4.0.0
1519 ** @@
1520 ******************************************************************************/
1521 
ajSeqAssignSeqS(AjPSeq seq,const AjPStr str)1522 void ajSeqAssignSeqS(AjPSeq seq, const AjPStr str)
1523 {
1524     ajSeqAssignSeqLenC(seq, ajStrGetPtr(str), ajStrGetLen(str));
1525 
1526     return;
1527 }
1528 
1529 
1530 
1531 
1532 /* @func ajSeqAssignSvC *******************************************************
1533 **
1534 ** Assigns the sequence version number.
1535 **
1536 ** @param [u] seq [AjPSeq] Sequence object.
1537 ** @param [r] txt [const char*] SeqVersion number as a C character string.
1538 ** @return [void]
1539 **
1540 ** @release 4.0.0
1541 ** @@
1542 ******************************************************************************/
1543 
ajSeqAssignSvC(AjPSeq seq,const char * txt)1544 void ajSeqAssignSvC(AjPSeq seq, const char* txt)
1545 {
1546     ajStrAssignC(&seq->Sv, txt);
1547 
1548     return;
1549 }
1550 
1551 
1552 
1553 
1554 /* @func ajSeqAssignSvS *******************************************************
1555 **
1556 ** Assigns the sequence version number.
1557 **
1558 ** @param [u] seq [AjPSeq] Sequence object.
1559 ** @param [r] str [const AjPStr] SeqVersion number as a string.
1560 ** @return [void]
1561 **
1562 ** @release 4.0.0
1563 ** @@
1564 ******************************************************************************/
1565 
ajSeqAssignSvS(AjPSeq seq,const AjPStr str)1566 void ajSeqAssignSvS(AjPSeq seq, const AjPStr str)
1567 {
1568     ajStrAssignS(&seq->Sv, str);
1569 
1570     return;
1571 }
1572 
1573 
1574 
1575 
1576 /* @func ajSeqAssignUfoC ******************************************************
1577 **
1578 ** Assigns the sequence feature file name.
1579 **
1580 ** @param [u] seq [AjPSeq] Sequence object.
1581 ** @param [r] txt [const char*] UFO as a C character string.
1582 ** @return [void]
1583 **
1584 ** @release 4.0.0
1585 ** @@
1586 ******************************************************************************/
1587 
ajSeqAssignUfoC(AjPSeq seq,const char * txt)1588 void ajSeqAssignUfoC(AjPSeq seq, const char* txt)
1589 {
1590     ajStrAssignC(&seq->Ufo, txt);
1591 
1592     return;
1593 }
1594 
1595 
1596 
1597 
1598 /* @func ajSeqAssignUfoS ******************************************************
1599 **
1600 ** Assigns the sequence feature file name.
1601 **
1602 ** @param [u] seq [AjPSeq] Sequence object.
1603 ** @param [r] str [const AjPStr] UFO as a string.
1604 ** @return [void]
1605 **
1606 ** @release 4.0.0
1607 ** @@
1608 ******************************************************************************/
1609 
ajSeqAssignUfoS(AjPSeq seq,const AjPStr str)1610 void ajSeqAssignUfoS(AjPSeq seq, const AjPStr str)
1611 {
1612     ajStrAssignS(&seq->Ufo, str);
1613 
1614     return;
1615 }
1616 
1617 
1618 
1619 
1620 /* @func ajSeqAssignUsaC ******************************************************
1621 **
1622 ** Assigns the sequence full name.
1623 **
1624 ** @param [u] seq [AjPSeq] Sequence object.
1625 ** @param [r] txt [const char*] USA as a C character string.
1626 ** @return [void]
1627 **
1628 ** @release 4.0.0
1629 ** @@
1630 ******************************************************************************/
1631 
ajSeqAssignUsaC(AjPSeq seq,const char * txt)1632 void ajSeqAssignUsaC(AjPSeq seq, const char* txt)
1633 {
1634     ajStrAssignC(&seq->Usa, txt);
1635 
1636     return;
1637 }
1638 
1639 
1640 
1641 
1642 /* @func ajSeqAssignUsaS ******************************************************
1643 **
1644 ** Assigns the sequence full name.
1645 **
1646 ** @param [u] seq [AjPSeq] Sequence object.
1647 ** @param [r] str [const AjPStr] USA as a string.
1648 ** @return [void]
1649 **
1650 ** @release 4.0.0
1651 ** @@
1652 ******************************************************************************/
1653 
ajSeqAssignUsaS(AjPSeq seq,const AjPStr str)1654 void ajSeqAssignUsaS(AjPSeq seq, const AjPStr str)
1655 {
1656     ajStrAssignS(&seq->Usa, str);
1657 
1658     return;
1659 }
1660 
1661 
1662 
1663 
1664 /* @func ajSeqClear ***********************************************************
1665 **
1666 ** Resets all data for a sequence object so that it can be reused.
1667 **
1668 ** @param [u] seq [AjPSeq] Sequence
1669 ** @return [void]
1670 **
1671 ** @release 1.0.0
1672 ** @@
1673 ******************************************************************************/
1674 
ajSeqClear(AjPSeq seq)1675 void ajSeqClear(AjPSeq seq)
1676 {
1677     AjPStr ptr = NULL;
1678     AjPSeqRef  tmpref  = NULL;
1679     AjPSeqXref tmpxref = NULL;
1680     AjPSeqGene tmpgene = NULL;
1681 
1682     if(!seq)
1683         return;
1684 
1685     if(MAJSTRGETLEN(seq->Name))
1686        ajStrSetClear(&seq->Name);
1687     if(MAJSTRGETLEN(seq->Acc))
1688        ajStrSetClear(&seq->Acc);
1689     if(MAJSTRGETLEN(seq->Sv))
1690        ajStrSetClear(&seq->Sv);
1691     if(MAJSTRGETLEN(seq->Gi))
1692        ajStrSetClear(&seq->Gi);
1693     if(MAJSTRGETLEN(seq->Tax))
1694        ajStrSetClear(&seq->Tax);
1695     if(MAJSTRGETLEN(seq->Taxcommon))
1696        ajStrSetClear(&seq->Taxcommon);
1697     if(MAJSTRGETLEN(seq->Taxid))
1698        ajStrSetClear(&seq->Taxid);
1699     if(MAJSTRGETLEN(seq->Organelle))
1700        ajStrSetClear(&seq->Organelle);
1701     if(MAJSTRGETLEN(seq->Type))
1702        ajStrSetClear(&seq->Type);
1703     if(MAJSTRGETLEN(seq->Molecule))
1704        ajStrSetClear(&seq->Molecule);
1705     if(MAJSTRGETLEN(seq->Class))
1706        ajStrSetClear(&seq->Class);
1707     if(MAJSTRGETLEN(seq->Division))
1708        ajStrSetClear(&seq->Division);
1709     if(MAJSTRGETLEN(seq->Evidence))
1710        ajStrSetClear(&seq->Evidence);
1711     if(MAJSTRGETLEN(seq->Db))
1712        ajStrSetClear(&seq->Db);
1713     if(MAJSTRGETLEN(seq->Full))
1714        ajStrSetClear(&seq->Full);
1715     if(MAJSTRGETLEN(seq->Desc))
1716        ajStrSetClear(&seq->Desc);
1717     if(MAJSTRGETLEN(seq->Doc))
1718        ajStrSetClear(&seq->Doc);
1719     if(MAJSTRGETLEN(seq->Usa))
1720        ajStrSetClear(&seq->Usa);
1721     if(MAJSTRGETLEN(seq->Ufo))
1722        ajStrSetClear(&seq->Ufo);
1723 
1724     if(MAJSTRGETLEN(seq->Formatstr))
1725        ajStrSetClear(&seq->Formatstr);
1726     if(MAJSTRGETLEN(seq->Filename))
1727        ajStrSetClear(&seq->Filename);
1728     if(MAJSTRGETLEN(seq->Entryname))
1729        ajStrSetClear(&seq->Entryname);
1730     if(MAJSTRGETLEN(seq->TextPtr))
1731        ajStrSetClear(&seq->TextPtr);
1732     if(MAJSTRGETLEN(seq->Seq))
1733        ajStrSetClear(&seq->Seq);
1734 
1735     if(seq->Accuracy && seq->Qualsize)
1736         AJCSET0(seq->Accuracy, seq->Qualsize);
1737 
1738     seq->Begin = 0;
1739     seq->End   = 0;
1740     seq->Rev      = ajFalse;
1741     seq->Reversed = ajFalse;
1742     seq->Trimmed  = ajFalse;
1743     seq->Circular = ajFalse;
1744 
1745     if(seq->Acclist)
1746         while(ajListstrPop(seq->Acclist,&ptr))
1747             ajStrDel(&ptr);
1748 
1749     if(seq->Keylist)
1750         while(ajListstrPop(seq->Keylist,&ptr))
1751             ajStrDel(&ptr);
1752 
1753     if(seq->Taxlist)
1754         while(ajListstrPop(seq->Taxlist,&ptr))
1755             ajStrDel(&ptr);
1756 
1757     if(seq->Genelist)
1758         while(ajListPop(seq->Genelist,(void **)&tmpgene))
1759             ajSeqgeneDel(&tmpgene);
1760 
1761     if(seq->Reflist)
1762         while(ajListPop(seq->Reflist,(void **)&tmpref))
1763             ajSeqrefDel(&tmpref);
1764 
1765     if(seq->Cmtlist)
1766         while(ajListPop(seq->Cmtlist,(void **)&ptr))
1767             ajStrDel(&ptr);
1768 
1769     if(seq->Hostlist)
1770         while(ajListPop(seq->Hostlist,(void **)&ptr))
1771             ajStrDel(&ptr);
1772 
1773     if(seq->Xreflist)
1774         while(ajListPop(seq->Xreflist,(void **)&tmpxref))
1775             ajSeqxrefDel(&tmpxref);
1776 
1777     if(seq->Date)
1778         ajSeqdateClear(seq->Date);
1779     if(seq->Fulldesc)
1780         ajSeqdescClear(seq->Fulldesc);
1781 
1782     if(seq->Fttable)
1783         ajFeattableDel(&seq->Fttable);
1784 
1785     return;
1786 }
1787 
1788 
1789 
1790 
1791 /* @func ajSeqSetCircular *****************************************************
1792 **
1793 ** Sets a sequence to be circular
1794 **
1795 ** @param [u] seq [AjPSeq] Sequence
1796 ** @return [void]
1797 **
1798 ** @release 6.5.0
1799 ** @@
1800 ******************************************************************************/
1801 
ajSeqSetCircular(AjPSeq seq)1802 void ajSeqSetCircular(AjPSeq seq)
1803 {
1804     seq->Circular = ajTrue;
1805 
1806     return;
1807 }
1808 
1809 
1810 
1811 
1812 /* @func ajSeqSetName *********************************************************
1813 **
1814 ** Provides a unique (for this program run) name for a sequence.
1815 **
1816 ** @param [w] seq [AjPSeq] Sequence object
1817 ** @param [r] setname [const AjPStr] Name set by caller
1818 ** @return [void]
1819 **
1820 ** @release 4.1.0
1821 ** @@
1822 ******************************************************************************/
1823 
ajSeqSetName(AjPSeq seq,const AjPStr setname)1824 void ajSeqSetName(AjPSeq seq, const AjPStr setname)
1825 {
1826     if(ajStrGetLen(seq->Name))
1827     {
1828 	ajDebug("ajSeqSetName already has a name '%S'\n", seq->Name);
1829 
1830 	return;
1831     }
1832 
1833     if (ajStrGetLen(setname))
1834     {
1835 	ajStrAssignS(&seq->Name, setname);
1836     }
1837     else
1838     {
1839 	ajStrAssignC(&seq->Name, "EMBOSS");
1840     }
1841 
1842     ajDebug("ajSeqSetName set to  '%S'\n", seq->Name);
1843 
1844     return;
1845 }
1846 
1847 
1848 
1849 
1850 /* @func ajSeqSetNameMulti ****************************************************
1851 **
1852 ** Provides a unique (for this program run) name for a sequence.
1853 ** If a name is generated, append a count
1854 **
1855 ** @param [w] seq [AjPSeq] Sequence object
1856 ** @param [r] setname [const AjPStr] Name set by caller
1857 ** @return [void]
1858 **
1859 ** @release 4.1.0
1860 ** @@
1861 ******************************************************************************/
1862 
ajSeqSetNameMulti(AjPSeq seq,const AjPStr setname)1863 void ajSeqSetNameMulti(AjPSeq seq, const AjPStr setname)
1864 {
1865     static ajint count = 0;
1866 
1867     if(ajStrGetLen(seq->Name))
1868     {
1869 	ajDebug("ajSeqSetNameMulti already has a name '%S'\n", seq->Name);
1870 
1871 	return;
1872     }
1873 
1874     if (ajStrGetLen(setname))
1875     {
1876 	if(count)
1877 	    ajFmtPrintS(&seq->Name, "%S_%3.3d", setname, ++count);
1878 	else
1879 	{
1880 	    ajStrAssignS(&seq->Name, setname);
1881 	    ++count;
1882 	}
1883     }
1884     else
1885     {
1886 	ajFmtPrintS(&seq->Name, "EMBOSS_%3.3d", ++count);
1887     }
1888 
1889     ajDebug("ajSeqSetNameMulti set to  '%S'\n", seq->Name);
1890 
1891     return;
1892 }
1893 
1894 
1895 
1896 
1897 /* @func ajSeqSetOffsets ******************************************************
1898 **
1899 ** Sets the offsets for each end of a subsequence.
1900 **
1901 ** Needed mainly for local alignments so the original sequence numbering
1902 ** can be preserved.
1903 **
1904 ** @param [u] seq [AjPSeq] Sequence object to be set.
1905 ** @param [r] offset [ajint] Offset from start of original sequence
1906 ** @param [r] origlen [ajint] Original length, used to calculate the offset
1907 **                             from the end.
1908 ** @return [void]
1909 **
1910 ** @release 3.0.0
1911 ** @@
1912 ******************************************************************************/
1913 
ajSeqSetOffsets(AjPSeq seq,ajint offset,ajint origlen)1914 void ajSeqSetOffsets(AjPSeq seq, ajint offset, ajint origlen)
1915 {
1916     ajDebug("ajSeqSetOffsets(len:%d gap:%d off:%d origlen:%d) "
1917 	    "Offset:%d Offend:%d\n",
1918 	    ajSeqGetLen(seq), ajSeqCountGaps(seq),
1919 	    offset, origlen, seq->Offset, seq->Offend);
1920 
1921     if(seq->Trimmed)
1922     {
1923 	ajWarn("Sequence '%S' already trimmed in ajSeqSetOffsets",
1924 	       ajSeqGetNameS(seq));
1925     }
1926 
1927     if(seq->Reversed)
1928     {
1929 	if(offset && !seq->Offend)
1930 	    seq->Offend = offset;
1931 
1932 	if(origlen && !seq->Offset)
1933 	{
1934 	    seq->Offset = origlen - offset - ajSeqGetLen(seq)
1935 		+ ajSeqCountGaps(seq);
1936 	}
1937     }
1938     else
1939     {
1940 	if(offset && !seq->Offset)
1941 	    seq->Offset = offset;
1942 
1943 	if(origlen && !seq->Offend)
1944 	{
1945 	    seq->Offend = origlen - offset - ajSeqGetLen(seq)
1946 		+ ajSeqCountGaps(seq);
1947 	}
1948     }
1949 
1950     ajDebug("      result: (len: %d truelen:%d Offset:%d Offend:%d)\n",
1951 	    ajSeqGetLen(seq), ajSeqGetLen(seq)-ajSeqCountGaps(seq),
1952 	    seq->Offset, seq->Offend);
1953 
1954     return;
1955 }
1956 
1957 
1958 
1959 
1960 /* @func ajSeqSetRange ********************************************************
1961 **
1962 ** Sets the start and end positions for a sequence (not for a sequence set).
1963 ** Trim the sequence to convert to the subsequence.
1964 **
1965 ** @param [u] seq [AjPSeq] Sequence object to be set.
1966 ** @param [r] pos1 [ajint] Start position. Negative values are from the end.
1967 ** @param [r] pos2 [ajint] End position. Negative values are from the end.
1968 ** @return [void]
1969 **
1970 ** @release 1.0.0
1971 ** @@
1972 ******************************************************************************/
1973 
ajSeqSetRange(AjPSeq seq,ajint pos1,ajint pos2)1974 void ajSeqSetRange(AjPSeq seq, ajint pos1, ajint pos2)
1975 {
1976     ajDebug("ajSeqSetRange (len: %d %d..%d old %d..%d) rev:%B reversed:%B\n",
1977 	    ajSeqGetLen(seq), pos1, pos2,
1978 	    seq->Begin, seq->End, seq->Rev, seq->Reversed);
1979 
1980     if(seq->Trimmed)
1981     {
1982 	ajWarn("Sequence '%S' already trimmed in ajSeqSetRange",
1983 	       ajSeqGetNameS(seq));
1984     }
1985 
1986     if(pos1 && !seq->Begin)
1987 	seq->Begin = pos1;
1988 
1989     if(pos2 && !seq->End)
1990 	seq->End = pos2;
1991 
1992     ajDebug("      result: (len: %d %d..%d)\n",
1993 	    ajSeqGetLen(seq), seq->Begin, seq->End);
1994 
1995     if(seq->Rev && !seq->Reversed)
1996 	ajSeqReverseDo(seq);
1997 
1998     return;
1999 }
2000 
2001 
2002 
2003 
2004 /* @func ajSeqSetRangeRev *****************************************************
2005 **
2006 ** Sets the start and end positions for a sequence (not for a sequence set),
2007 ** and set the sequence to be reversed.
2008 **
2009 ** @param [u] seq [AjPSeq] Sequence object to be set.
2010 ** @param [r] pos1 [ajint] Start position. Negative values are from the end.
2011 ** @param [r] pos2 [ajint] End position. Negative values are from the end.
2012 ** @return [void]
2013 **
2014 ** @release 4.0.0
2015 ** @@
2016 ******************************************************************************/
2017 
ajSeqSetRangeRev(AjPSeq seq,ajint pos1,ajint pos2)2018 void ajSeqSetRangeRev(AjPSeq seq, ajint pos1, ajint pos2)
2019 {
2020 
2021     ajDebug("ajSeqSetRange (len: %d %d..%d old %d..%d) rev:%B reversed:%B\n",
2022 	    ajSeqGetLen(seq), pos1, pos2,
2023 	    seq->Begin, seq->End, seq->Rev, seq->Reversed);
2024 
2025     if(seq->Trimmed)
2026 	ajWarn("Sequence '%S' already trimmed in ajSeqSetRangeRev",
2027 	       ajSeqGetNameS(seq));
2028 
2029     if(pos1 && !seq->Begin)
2030 	seq->Begin = pos1;
2031 
2032     if(pos2 && !seq->End)
2033 	seq->End = pos2;
2034 
2035     ajDebug("      result: (len: %d %d..%d)\n",
2036 	    ajSeqGetLen(seq), seq->Begin, seq->End);
2037 
2038     if(!seq->Rev)
2039     {
2040 	seq->Rev = ajTrue;
2041 	seq->Reversed = ajFalse;
2042     }
2043 
2044     ajSeqReverseDo(seq);
2045 
2046     return;
2047 }
2048 
2049 
2050 
2051 
2052 /* @func ajSeqSetUnique *******************************************************
2053 **
2054 ** Makes a sequence modifiable by making sure there is no duplicate
2055 ** copy of the sequence.
2056 **
2057 ** @param [u] seq [AjPSeq] Sequence
2058 ** @return [void]
2059 **
2060 ** @release 4.1.0
2061 ** @@
2062 ******************************************************************************/
2063 
ajSeqSetUnique(AjPSeq seq)2064 void ajSeqSetUnique(AjPSeq seq)
2065 {
2066     ajStrGetuniqueStr(&seq->Seq);
2067 
2068     return;
2069 }
2070 
2071 
2072 
2073 
2074 /* @func ajSeqTagRev **********************************************************
2075 **
2076 ** Adds a tag to the sequence description to note it has been reversed
2077 **
2078 ** @param [u] seq [AjPSeq] Sequence object to be set.
2079 ** @return [void]
2080 **
2081 ** @release 6.1.0
2082 ******************************************************************************/
2083 
ajSeqTagRev(AjPSeq seq)2084 void ajSeqTagRev(AjPSeq seq)
2085 {
2086     if(ajStrGetLen(seq->Desc))
2087         ajStrInsertC(&seq->Desc, 0, "Reversed: ");
2088     else
2089         ajStrAssignC(&seq->Desc, "Reversed:");
2090 
2091     return;
2092 }
2093 
2094 
2095 
2096 
2097 /* @funcstatic seqMakeUsa *****************************************************
2098 **
2099 ** Sets the USA for a sequence.
2100 **
2101 ** @param [r] thys [const AjPSeq] Sequence object
2102 ** @param [w] usa [AjPStr*] USA in full
2103 ** @return [void]
2104 **
2105 ** @release 4.0.0
2106 ** @@
2107 ******************************************************************************/
2108 
seqMakeUsa(const AjPSeq thys,AjPStr * usa)2109 static void seqMakeUsa(const AjPSeq thys, AjPStr* usa)
2110 {
2111     AjPStr tmpstr = NULL;
2112 
2113     ajDebug("seqMakeUsa (Name <%S> Formatstr <%S> Db <%S> "
2114 	    "Entryname <%S> Filename <%S>)\n",
2115 	    thys->Name, thys->Formatstr, thys->Db,
2116 	    thys->Entryname, thys->Filename);
2117 
2118     ajDebug("Begin:%d End:%d Rev:%B Reversed:%B\n",
2119 	    thys->Begin, thys->End, thys->Rev, thys->Reversed);
2120     /* ajSeqTrace(thys); */
2121 
2122     if(ajStrGetLen(thys->Db))
2123 	ajFmtPrintS(usa, "%S-id:%S", thys->Db, thys->Entryname);
2124     else
2125     {
2126 	/*ajFmtPrintS(&thys->Usa, "%S::%S (%S)",
2127 	  thys->Formatstr, thys->Filename, thys->Entryname);*/
2128 	if(ajStrMatchC(thys->Formatstr, "asis"))
2129         {
2130 	    if(thys->Reversed)
2131 	    {
2132 		ajStrAssignS(&tmpstr, thys->Seq);
2133 		ajSeqstrReverse(&tmpstr);
2134 		ajFmtPrintS(usa, "asis::%S", tmpstr);
2135 		ajStrDel(&tmpstr);
2136 	    }
2137 	    else
2138 		ajFmtPrintS(usa, "asis::%S", thys->Seq);
2139         }
2140 	else if(ajStrGetLen(thys->Entryname))
2141 	    ajFmtPrintS(usa, "%S::%S:%S", thys->Formatstr,
2142 			thys->Filename,thys->Entryname);
2143 	else
2144 	    ajFmtPrintS(usa, "%S::%S", thys->Formatstr,
2145 			thys->Filename);
2146 
2147     }
2148 
2149     ajFmtPrintS(&tmpstr, "[");
2150 
2151     if(thys->Reversed)
2152     {
2153 	if(thys->End)
2154 	    ajFmtPrintAppS(&tmpstr, "%d", -thys->End);
2155 
2156 	ajFmtPrintAppS(&tmpstr, ":");
2157 
2158 	if(thys->Begin)
2159 	    ajFmtPrintAppS(&tmpstr, "%d", -thys->Begin);
2160 
2161 	ajFmtPrintAppS(&tmpstr, ":r");
2162     }
2163     else
2164     {
2165 	if(thys->Begin)
2166 	    ajFmtPrintAppS(&tmpstr, "%d", thys->Begin);
2167 
2168 	ajFmtPrintAppS(&tmpstr, ":");
2169 
2170 	if(thys->End)
2171 	    ajFmtPrintAppS(&tmpstr, "%d", thys->End);
2172     }
2173 
2174     ajFmtPrintAppS(&tmpstr, "]");
2175 
2176     if(ajStrGetLen(tmpstr) > 3)
2177 	ajStrAppendS(usa, tmpstr);
2178 
2179     ajStrDel(&tmpstr);
2180     ajDebug("      result: <%S>\n",
2181 	    *usa);
2182 
2183     return;
2184 }
2185 
2186 
2187 
2188 
2189 /* @section process *******************************************************
2190 **
2191 ** These functions use the contents of a sequence object to produce a
2192 ** subsequence from the range, or to reverse a sequence whose direction
2193 ** has been set to be reversed.
2194 **
2195 ** @fdata [AjPSeq]
2196 ** @fcategory modify
2197 **
2198 ** @nam3rule Complement Complement the bases
2199 ** @nam3rule Fmt Format sequence characters
2200 ** @nam4rule FmtLower Format sequence characters to lower case
2201 ** @nam4rule FmtUpper Format sequence characters to upper case
2202 ** @nam3rule Gap Process gaps in sequence
2203 ** @nam4rule GapFill Fill sequence to a given length with end gaps
2204 ** @nam4rule GapStandard Make all gap characters use a given character
2205 ** @nam3rule Reverse Reverse the sequence
2206 ** @nam4rule ReverseDo Reverse if Rev attribute is set
2207 ** @nam4rule ReverseForce Reverse the sequence without testing the
2208 **                        Rev attribute
2209 ** @nam4rule ReverseOnly Reverse the sequence but do not complement the bases
2210 ** @nam3rule Trim Trim sequence using defined range
2211 **
2212 ** @argrule * seq [AjPSeq] Sequence to be processed
2213 ** @argrule GapFill len [ajuint] Padded sequence length
2214 ** @argrule GapStandard gapchar [char] Preferred gap character
2215 **
2216 ** @valrule * [void]
2217 ******************************************************************************/
2218 
2219 
2220 
2221 
2222 /* @func ajSeqComplement ******************************************************
2223 **
2224 ** Complements but does not reverse a nucleotide sequence.
2225 **
2226 ** @param [u] seq [AjPSeq] Sequence
2227 ** @return [void]
2228 **
2229 ** @release 4.1.0
2230 ** @@
2231 ******************************************************************************/
2232 
ajSeqComplement(AjPSeq seq)2233 void ajSeqComplement(AjPSeq seq)
2234 {
2235     ajSeqstrComplement(&seq->Seq);
2236 
2237     return;
2238 }
2239 
2240 
2241 
2242 
2243 /* @func ajSeqFmtLower ********************************************************
2244 **
2245 ** Converts a sequence to lower case.
2246 **
2247 ** @param [u] seq [AjPSeq] Sequence
2248 ** @return [void]
2249 **
2250 ** @release 4.0.0
2251 ** @@
2252 ******************************************************************************/
2253 
ajSeqFmtLower(AjPSeq seq)2254 void ajSeqFmtLower(AjPSeq seq)
2255 {
2256     ajStrFmtLower(&seq->Seq);
2257 
2258     return;
2259 }
2260 
2261 
2262 
2263 
2264 /* @func ajSeqFmtUpper ********************************************************
2265 **
2266 ** Converts a sequence to upper case.
2267 **
2268 ** @param [u] seq [AjPSeq] Sequence
2269 ** @return [void]
2270 **
2271 ** @release 4.0.0
2272 ** @@
2273 ******************************************************************************/
2274 
ajSeqFmtUpper(AjPSeq seq)2275 void ajSeqFmtUpper(AjPSeq seq)
2276 {
2277     ajStrFmtUpper(&seq->Seq);
2278 
2279     return;
2280 }
2281 
2282 
2283 
2284 
2285 /* @func ajSeqGapFill *********************************************************
2286 **
2287 ** Fills a single sequence with gaps up to a specified length.
2288 **
2289 ** @param [u] seq [AjPSeq] Sequence object to be set.
2290 ** @param [r] len [ajuint] Length to pad fill to.
2291 ** @return [void]
2292 **
2293 ** @release 4.1.0
2294 ** @@
2295 ******************************************************************************/
2296 
ajSeqGapFill(AjPSeq seq,ajuint len)2297 void ajSeqGapFill(AjPSeq seq, ajuint len)
2298 {
2299     ajuint ilen = 0;
2300 
2301     ajDebug("ajSeqGapFill(len: %d -> ilen:%d)\n", ajSeqGetLen(seq), ilen);
2302 
2303     if(ajSeqGetLen(seq) < len)
2304     {
2305 	ilen = len - ajSeqGetLen(seq);
2306 	ajStrAppendCountK(&seq->Seq, '-', ilen);
2307     }
2308 
2309     ajDebug("      result: (len: %d added: %d\n",
2310 	     ajSeqGetLen(seq), ilen);
2311 
2312     return;
2313 }
2314 
2315 
2316 
2317 
2318 /* @func ajSeqGapStandard *****************************************************
2319 **
2320 ** Makes all gaps in a string use a standard gap character
2321 **
2322 ** @param [w] seq [AjPSeq] Sequence object
2323 ** @param [r] gapchar [char] Gap character (or '-' if zero)
2324 ** @return [void]
2325 **
2326 ** @release 2.1.0
2327 ******************************************************************************/
2328 
ajSeqGapStandard(AjPSeq seq,char gapchar)2329 void ajSeqGapStandard(AjPSeq seq, char gapchar)
2330 {
2331     char newgap = '-';
2332     static char testchars[] = "-~.? "; /* all known gap characters */
2333     char *testgap;
2334 
2335     testgap = testchars;
2336 
2337     if(gapchar)
2338 	newgap = gapchar;
2339 
2340     /*ajDebug("ajSeqGapStandardS '%c'=>'%c' '%S'\n",
2341             gapch, newgap, seq->Seq);*/
2342 
2343     while(*testgap)
2344     {
2345 	if(newgap != *testgap)
2346 	{
2347 	    ajStrExchangeKK(&seq->Seq, *testgap, newgap);
2348 	    /*ajDebug(" ajSeqGapStandardS replaced         '%c'=>'%c' '%S'\n",
2349 		    *testgap, newgap, thys);*/
2350 	}
2351 
2352 	testgap++;
2353     }
2354 
2355     return;
2356 }
2357 
2358 
2359 
2360 
2361 /* @func ajSeqReverseDo *******************************************************
2362 **
2363 ** Reverses and complements a nucleotide sequence, unless it is already done.
2364 **
2365 ** If the sequence is not flagged for reversal, use ajSeqReverseForce instead.
2366 **
2367 ** @param [u] seq [AjPSeq] Sequence
2368 ** @return [void]
2369 **
2370 ** @release 4.0.0
2371 ** @@
2372 ******************************************************************************/
2373 
ajSeqReverseDo(AjPSeq seq)2374 void ajSeqReverseDo(AjPSeq seq)
2375 {
2376     ajint ibegin;
2377     ajint iend;
2378     ajint itemp;
2379     ajuint i;
2380     ajuint j;
2381     float atemp;
2382 
2383     ajDebug("ajSeqReverseDo len: %d Begin: %d End: %d Rev: %B Reversed: %B\n",
2384 	    ajSeqGetLen(seq), seq->Begin, seq->End,
2385 	    seq->Rev, seq->Reversed);
2386 
2387     if(!seq->Rev)			/* Not flagged for reversal */
2388 	return;
2389 
2390     ibegin = seq->Begin;
2391     iend   = seq->End;
2392 
2393     seq->End   = -(ibegin);
2394     seq->Begin = -(iend);
2395 
2396     itemp = seq->Offend;
2397     seq->Offend = seq->Offset;
2398     seq->Offset = itemp;
2399 
2400     seq->Rev = ajFalse;
2401 
2402     if(seq->Reversed)
2403 	seq->Reversed = ajFalse;
2404     else
2405 	seq->Reversed = ajTrue;
2406 
2407     ajSeqstrReverse(&seq->Seq);
2408 
2409     ajDebug("      result len: %d Begin: %d End: %d\n",
2410 	    ajSeqGetLen(seq), seq->Begin, seq->End);
2411 
2412     if(seq->Fttable)
2413     {
2414         ajFeattableSetReverse(seq->Fttable);
2415 	ajFeattableReverse(seq->Fttable);
2416     }
2417 
2418     if(seq->Accuracy)
2419     {
2420         j = seq->Qualsize;
2421         for(i=0;i<seq->Qualsize;i++)
2422         {
2423             if(--j <= i) break;
2424             atemp = seq->Accuracy[j];
2425             seq->Accuracy[j] = seq->Accuracy[i];
2426             seq->Accuracy[i] = atemp;
2427         }
2428     }
2429 
2430     return;
2431 }
2432 
2433 
2434 
2435 
2436 /* @func ajSeqReverseForce ****************************************************
2437 **
2438 ** Reverses and complements a nucleotide sequence.
2439 ** Forces reversal to be done even if the sequence is flagged
2440 ** as already reversed.
2441 **
2442 ** This happens, for example, where an input sequence has been reversed
2443 ** with -sreverse on the command line, but the application needs to reverse it
2444 ** in processing both directions.
2445 **
2446 ** @param [u] seq [AjPSeq] Sequence
2447 ** @return [void]
2448 **
2449 ** @release 2.7.0
2450 ** @@
2451 ******************************************************************************/
2452 
ajSeqReverseForce(AjPSeq seq)2453 void ajSeqReverseForce(AjPSeq seq)
2454 {
2455     ajDebug("ajSeqReverseForce len: %d Begin: %d End: %d Rev: %B "
2456 	    "Reversed: %B\n",
2457 	    ajSeqGetLen(seq), seq->Begin, seq->End,
2458 	    seq->Rev, seq->Reversed);
2459 
2460     seq->Rev = ajTrue;
2461     ajSeqReverseDo(seq);
2462 
2463     return;
2464 }
2465 
2466 
2467 
2468 
2469 /* @func ajSeqReverseOnly *****************************************************
2470 **
2471 ** Reverses but does not complement a nucleotide sequence.
2472 **
2473 ** Intended for sequence display, but can be used to fix incorrect
2474 ** sequence entries.
2475 **
2476 ** @param [u] seq [AjPSeq] Sequence
2477 ** @return [void]
2478 **
2479 ** @release 4.0.0
2480 ** @@
2481 ******************************************************************************/
2482 
ajSeqReverseOnly(AjPSeq seq)2483 void ajSeqReverseOnly(AjPSeq seq)
2484 {
2485     ajint ibegin;
2486     ajint iend;
2487 
2488     ajDebug("ajSeqRevOnly len: %d Begin: %d End: %d\n",
2489 	    ajSeqGetLen(seq), seq->Begin, seq->End);
2490 
2491     ibegin = seq->Begin;
2492     iend   = seq->End;
2493 
2494     if(ibegin)
2495 	seq->End   = -(ibegin);
2496 
2497     if(iend)
2498 	seq->Begin = -(iend);
2499 
2500     ajStrReverse(&seq->Seq);
2501 
2502     ajDebug(" only result len: %d Begin: %d End: %d\n",
2503 	    ajSeqGetLen(seq), seq->Begin, seq->End);
2504 
2505     return;
2506 }
2507 
2508 
2509 
2510 
2511 /* @func ajSeqTrim ************************************************************
2512 **
2513 ** Trim a sequence using the Begin and Ends.
2514 ** Also reverse complements a nucleotide sequence if required.
2515 **
2516 ** @param [u] seq [AjPSeq] Sequence to be trimmed.
2517 ** @return [void]
2518 **
2519 ** @release 1.0.0
2520 ** @@
2521 ******************************************************************************/
2522 
ajSeqTrim(AjPSeq seq)2523 void ajSeqTrim(AjPSeq seq)
2524 {
2525     AjBool okay = ajTrue;
2526     ajint begin;
2527     ajint end;
2528 
2529     ajint jbegin;
2530     ajint jend;
2531 
2532     /*ajDebug("ajSeqTrim '%S'\n", seq->Seq);*/
2533     ajDebug("ajSeqTrim '%S' Rev:%B Reversed:%B Begin:%d End:%d "
2534 	    "Offset:%d Offend:%d Len:%d\n",
2535 	    ajSeqGetNameS(seq), seq->Rev, seq->Reversed,
2536 	    seq->Begin, seq->End,
2537 	    seq->Offset, seq->Offend, seq->Seq->Len);
2538 
2539     if(seq->Trimmed)
2540     {
2541 	ajWarn("Sequence '%S' already trimmed", ajSeqGetNameS(seq));
2542 
2543 	return;
2544     }
2545 
2546     /*ajDebug("ajSeqTrim '%S'\n", seq->Seq);*/
2547     ajDebug("ajSeqTrim Rev:%B Reversed:%B Begin:%d End:%d "
2548 	   "Offset:%d Offend:%d Len:%d okay:%B\n",
2549 	    seq->Rev, seq->Reversed, seq->Begin, seq->End,
2550 	    seq->Offset, seq->Offend, seq->Seq->Len, okay);
2551 
2552     jbegin = seq->Begin;
2553 
2554     if(jbegin > 0)
2555 	jbegin--;
2556 
2557     jend = seq->End;
2558 
2559     if(jend > 0)
2560 	jend--;
2561 
2562 /*
2563     if(jbegin > (ajint) ajSeqGetLen(seq))
2564         ajWarn("sequence begin %d more than length %u",
2565                jbegin, ajSeqGetLen(seq));
2566     if(jend > (ajint) ajSeqGetLen(seq))
2567         ajWarn("sequence end %d more than length %u",
2568                jbegin, ajSeqGetLen(seq));
2569 */
2570 
2571     begin = 1 + ajCvtSposToPosStart(ajSeqGetLen(seq), 0, jbegin);
2572     end   = 1 + ajCvtSposToPosStart(ajSeqGetLen(seq), begin-1, jend);
2573 
2574     ajDebug("Trimming %d from %d (%d) to %d (%d) "
2575 	    "Rev: %B Reversed: %B Trimmed: %B\n",
2576 	    seq->Seq->Len,seq->Begin,begin, seq->End, end,
2577 	    seq->Rev, seq->Reversed, seq->Trimmed);
2578 
2579     if(seq->End)
2580     {
2581 	if(end < begin)
2582 	    return;
2583 
2584 	seq->Offend = seq->Seq->Len-(end);
2585 	okay = ajStrCutEnd(&(seq->Seq),seq->Seq->Len-(end));
2586 	seq->End    = 0;
2587     }
2588 
2589     if(seq->Begin)
2590     {
2591 	okay = ajStrCutStart(&seq->Seq,begin-1);
2592 	seq->Offset = begin-1;
2593 	seq->Begin = 0;
2594     }
2595 
2596     ajDebug("After Trimming len = %d off = %d offend = %d\n",
2597 	    seq->Seq->Len, seq->Offset, seq->Offend);
2598     /*ajDebug("After Trimming len = %d '%S'\n",thys->Seq->Len, thys->Seq);*/
2599 
2600 
2601     if(okay && seq->Fttable)
2602 	okay = ajFeattableTrimOff(seq->Fttable, seq->Offset, seq->Seq->Len);
2603 
2604     if(seq->Rev)
2605 	ajSeqReverseDo(seq);
2606 
2607     /*ajDebug("ajSeqTrim '%S'\n", seq->Seq);*/
2608     ajDebug("ajSeqTrim 'Rev:%B Reversed:%B Begin:%d End:%d "
2609 	    "Offset:%d Offend:%d Len:%d okay:%B\n",
2610 	    seq->Rev, seq->Reversed, seq->Begin, seq->End,
2611 	    seq->Offset, seq->Offend, seq->Seq->Len, okay);
2612 
2613     return;
2614 }
2615 
2616 
2617 
2618 
2619 /* @section element retrieval
2620 **
2621 ** These functions return the contents of a sequence object.
2622 **
2623 ** @fdata [AjPSeq]
2624 ** @fcategory use
2625 **
2626 ** @nam3rule Get Return sequence attribute(s)
2627 ** @nam4rule GetAcc Return sequence accession number
2628 ** @nam4rule GetBegin Return sequence begin
2629 ** @nam4rule GetDb Return database name
2630 ** @nam4rule GetDesc Return sequence description
2631 ** @nam4rule GetEnd Return sequence end
2632 ** @nam4rule GetEntry Return entry text
2633 ** @nam4rule GetFeat Return sequence feature table
2634 ** @nam4rule GetGi Return sequence GI number
2635 ** @nam4rule GetLen Return sequence length
2636 ** @nam4rule GetName Return sequence name
2637 ** @nam4rule GetOffend Return sequence end offset
2638 ** @nam4rule GetOffset Return sequence start offset
2639 ** @nam4rule GetQual Return quality scores
2640 ** @nam4rule GetRange Return sequence begin and end
2641 ** @nam4rule GetRev Return sequence reverse attribute (not yet reversed)
2642 ** @nam4rule GetSeq Return sequence
2643 ** @nam4rule GetSv Return sequence version
2644 ** @nam4rule GetTax Return taxonomy
2645 ** @nam4rule GetTaxid Return taxonomy id
2646 ** @nam4rule GetUsa Return sequence USA
2647 ** @nam4rule GetXrefs return cross-references
2648 **
2649 ** @suffix S Return a string
2650 ** @suffix C Return a character string
2651 ** @suffix Trimmed After trimming begin and end positions
2652 ** @suffix True True position in original sequence
2653 ** @suffix Ungapped Ignoring all gap characters
2654 ** @suffix Copy Editable copy
2655 **
2656 ** @argrule * seq [const AjPSeq] Sequence
2657 ** @argrule Range begin [ajint*] Start position
2658 ** @argrule Range end [ajint*] End position
2659 ** @argrule Xrefs list [AjPList] Cross-references
2660 **
2661 ** @valrule C [const char*]
2662 ** @valrule S [const AjPStr]
2663 ** @valrule Begin [ajuint] Sequence position
2664 ** @valrule End [ajuint] Sequence position
2665 ** @valrule Len [ajuint] Sequence length
2666 ** @valrule Offend [ajuint] Sequence end offset
2667 ** @valrule Offset [ajuint] Sequence start offset
2668 ** @valrule Qual [const float*] Sequence phred quality scores
2669 ** @valrule Range [ajuint] Sequence length
2670 ** @valrule Rev [AjBool] Reverse attribute
2671 ** @valrule Revtext [AjPStr] Reverse text
2672 ** @valrule *Feat [const AjPFeattable] Link to internal feature table
2673 ** @valrule *FeatCopy [AjPFeattable] New feature table with original contents
2674 ** @valrule *SeqCopyC [char*] New sequence with original contents
2675 ** @valrule *SeqCopyS [AjPStr] New sequence with original contents
2676 ** @valrule Taxid [ajuint] NCBI taxonomy ID
2677 ** @valrule Xrefs [ajuint] Number of cross-references
2678 ******************************************************************************/
2679 
2680 
2681 
2682 
2683 /* @func ajSeqGetAccC *********************************************************
2684 **
2685 ** Returns the sequence accession number.
2686 ** Because this is a pointer to the real internal string
2687 ** the caller must take care not to change the character string in any way.
2688 ** If the string is to be changed (case for example) then it must first
2689 ** be copied.
2690 **
2691 ** @param [r] seq [const AjPSeq] Sequence object.
2692 ** @return [const char*] Accession number as a character string.
2693 **
2694 ** @release 4.0.0
2695 ** @@
2696 ******************************************************************************/
2697 
ajSeqGetAccC(const AjPSeq seq)2698 const char* ajSeqGetAccC(const AjPSeq seq)
2699 {
2700     return MAJSTRGETPTR(seq->Acc);
2701 }
2702 
2703 
2704 
2705 
2706 /* @func ajSeqGetAccS *********************************************************
2707 **
2708 ** Returns the sequence accession number.
2709 ** Because this is a pointer to the real internal string
2710 ** the caller must take care not to change the character string in any way.
2711 ** If the string is to be changed (case for example) then it must first
2712 ** be copied.
2713 **
2714 ** @param [r] seq [const AjPSeq] Sequence object.
2715 ** @return [const AjPStr] Accession number as a string.
2716 **
2717 ** @release 4.0.0
2718 ** @@
2719 ******************************************************************************/
2720 
ajSeqGetAccS(const AjPSeq seq)2721 const AjPStr ajSeqGetAccS(const AjPSeq seq)
2722 {
2723     if(seq->Acc)
2724         return seq->Acc;
2725     return ajStrConstEmpty();
2726 }
2727 
2728 
2729 
2730 
2731 /* @func ajSeqGetBegin ********************************************************
2732 **
2733 ** Returns the sequence start position within the current stored sequence,
2734 ** or 1 if no start has been set.
2735 **
2736 ** To return the position within the original sequence, which may be different
2737 ** if the sequence has been trimmed, use ajSeqGetBeginTrue
2738 **
2739 ** @param [r] seq [const AjPSeq] Sequence object
2740 ** @return [ajuint] Start position.
2741 **
2742 ** @release 4.0.0
2743 ** @@
2744 ******************************************************************************/
2745 
ajSeqGetBegin(const AjPSeq seq)2746 ajuint ajSeqGetBegin(const AjPSeq seq)
2747 {
2748     ajint i;
2749     ajint j;
2750 
2751     if(!seq->Begin)
2752 	return 1;
2753 
2754     i = seq->Begin;
2755 
2756     if(seq->Begin > 0)
2757 	i = seq->Begin - 1;
2758 
2759     j =  1 + ajCvtSposToPosStart(ajSeqGetLen(seq), 0, i);
2760 
2761     return j;
2762 }
2763 
2764 
2765 
2766 
2767 /* @func ajSeqGetBeginTrue ****************************************************
2768 **
2769 ** Returns the sequence start position in the original sequence,
2770 ** which may have been trimmed.
2771 **
2772 ** To return the position within the current stored sequence,
2773 ** which may be different if the sequence has been trimmed, use ajSeqBegin
2774 **
2775 ** @param [r] seq [const AjPSeq] Sequence object
2776 ** @return [ajuint] Start position.
2777 **
2778 ** @release 4.0.0
2779 ** @@
2780 ******************************************************************************/
2781 
ajSeqGetBeginTrue(const AjPSeq seq)2782 ajuint ajSeqGetBeginTrue(const AjPSeq seq)
2783 {
2784     if(!seq->Begin)
2785 	return ajSeqCalcTruepos(seq, 1);
2786 
2787     return ajSeqCalcTruepos(seq, seq->Begin);
2788 }
2789 
2790 
2791 
2792 
2793 /* @func ajSeqGetDbC **********************************************************
2794 **
2795 ** Returns the sequence database name.
2796 ** Because this is a pointer to the real internal string
2797 ** the caller must take care not to change the character string in any way.
2798 ** If the string is to be changed (case for example) then it must first
2799 ** be copied.
2800 **
2801 ** @param [r] seq [const AjPSeq] Sequence object.
2802 ** @return [const char*] Database name as a character string.
2803 **
2804 ** @release 5.0.0
2805 ** @@
2806 ******************************************************************************/
2807 
ajSeqGetDbC(const AjPSeq seq)2808 const char* ajSeqGetDbC(const AjPSeq seq)
2809 {
2810     return MAJSTRGETPTR(seq->Db);
2811 }
2812 
2813 
2814 
2815 
2816 /* @func ajSeqGetDbS **********************************************************
2817 **
2818 ** Returns the sequence database name.
2819 ** Because this is a pointer to the real internal string
2820 ** the caller must take care not to change the character string in any way.
2821 ** If the string is to be changed (case for example) then it must first
2822 ** be copied.
2823 **
2824 ** @param [r] seq [const AjPSeq] Sequence object.
2825 ** @return [const AjPStr] Database name as a string.
2826 **
2827 ** @release 5.0.0
2828 ** @@
2829 ******************************************************************************/
2830 
ajSeqGetDbS(const AjPSeq seq)2831 const AjPStr ajSeqGetDbS(const AjPSeq seq)
2832 {
2833     if(seq->Db)
2834         return seq->Db;
2835     return ajStrConstEmpty();
2836 }
2837 
2838 
2839 
2840 
2841 /* @func ajSeqGetDescC ********************************************************
2842 **
2843 ** Returns the sequence description.
2844 ** Because this is a pointer to the real internal string
2845 ** the caller must take care not to change the character string in any way.
2846 ** If the string is to be changed (case for example) then it must first
2847 ** be copied.
2848 **
2849 ** @param [r] seq [const AjPSeq] Sequence object.
2850 ** @return [const char*] Description as a character string.
2851 **
2852 ** @release 4.0.0
2853 ** @@
2854 ******************************************************************************/
2855 
ajSeqGetDescC(const AjPSeq seq)2856 const char* ajSeqGetDescC(const AjPSeq seq)
2857 {
2858     return MAJSTRGETPTR(seq->Desc);
2859 }
2860 
2861 
2862 
2863 
2864 /* @func ajSeqGetDescS ********************************************************
2865 **
2866 ** Returns the sequence description.
2867 ** Because this is a pointer to the real internal string
2868 ** the caller must take care not to change the character string in any way.
2869 ** If the string is to be changed (case for example) then it must first
2870 ** be copied.
2871 **
2872 ** @param [r] seq [const AjPSeq] Sequence object.
2873 ** @return [const AjPStr] Description as a string.
2874 **
2875 ** @release 4.0.0
2876 ** @@
2877 ******************************************************************************/
2878 
ajSeqGetDescS(const AjPSeq seq)2879 const AjPStr ajSeqGetDescS(const AjPSeq seq)
2880 {
2881     if(seq->Desc)
2882         return seq->Desc;
2883     return ajStrConstEmpty();
2884 }
2885 
2886 
2887 
2888 
2889 /* @func ajSeqGetEnd **********************************************************
2890 **
2891 ** Returns the sequence end position, or the sequence length if no end
2892 ** has been set.
2893 **
2894 ** @param [r] seq [const AjPSeq] Sequence object
2895 ** @return [ajuint] End position.
2896 **
2897 ** @release 4.0.0
2898 ** @@
2899 ******************************************************************************/
2900 
ajSeqGetEnd(const AjPSeq seq)2901 ajuint ajSeqGetEnd(const AjPSeq seq)
2902 {
2903     ajint i;
2904 
2905     if(!seq->End)
2906 	return (ajSeqGetLen(seq));
2907 
2908     i = seq->End;
2909 
2910     if(seq->End > 0)
2911 	i--;
2912 
2913     i = 1 +ajCvtSposToPosStart(ajSeqGetLen(seq), ajSeqGetBegin(seq)-1, i);
2914 
2915     return i;
2916 }
2917 
2918 
2919 
2920 
2921 /* @func ajSeqGetEndTrue ******************************************************
2922 **
2923 ** Returns the sequence end position, or the sequence length if no end
2924 ** has been set.
2925 **
2926 ** @param [r] seq [const AjPSeq] Sequence object
2927 ** @return [ajuint] End position.
2928 **
2929 ** @release 4.0.0
2930 ** @@
2931 ******************************************************************************/
2932 
ajSeqGetEndTrue(const AjPSeq seq)2933 ajuint ajSeqGetEndTrue(const AjPSeq seq)
2934 {
2935     if(!seq->End)
2936     {
2937 	if(ajSeqIsReversed(seq))
2938 	    return seq->Offend + ajSeqGetLen(seq);
2939 	else
2940 	    return seq->Offset + ajSeqGetLen(seq);
2941     }
2942 
2943     return ajSeqCalcTrueposMin(seq, ajSeqGetBeginTrue(seq), seq->End);
2944 }
2945 
2946 
2947 
2948 
2949 /* @func ajSeqGetEntryC *******************************************************
2950 **
2951 ** Returns the sequence full text entry.
2952 ** Because this is a pointer to the real internal string
2953 ** the caller must take care not to change the character string in any way.
2954 ** If the string is to be changed (case for example) then it must first
2955 ** be copied.
2956 **
2957 ** @param [r] seq [const AjPSeq] Sequence object.
2958 ** @return [const char*] Entry as a character string.
2959 **
2960 ** @release 4.0.0
2961 ** @@
2962 ******************************************************************************/
2963 
ajSeqGetEntryC(const AjPSeq seq)2964 const char* ajSeqGetEntryC(const AjPSeq seq)
2965 {
2966     return MAJSTRGETPTR(seq->TextPtr);
2967 }
2968 
2969 
2970 
2971 
2972 /* @func ajSeqGetEntryS *******************************************************
2973 **
2974 ** Returns the sequence full text entry.
2975 ** Because this is a pointer to the real internal string
2976 ** the caller must take care not to change the character string in any way.
2977 ** If the string is to be changed (case for example) then it must first
2978 ** be copied.
2979 **
2980 ** @param [r] seq [const AjPSeq] Sequence object.
2981 ** @return [const AjPStr] Entry as a string.
2982 **
2983 ** @release 4.0.0
2984 ** @@
2985 ******************************************************************************/
2986 
ajSeqGetEntryS(const AjPSeq seq)2987 const AjPStr ajSeqGetEntryS(const AjPSeq seq)
2988 {
2989     if(seq->TextPtr)
2990         return seq->TextPtr;
2991     return ajStrConstEmpty();
2992 }
2993 
2994 
2995 
2996 
2997 /* @func ajSeqGetFeat *********************************************************
2998 **
2999 ** Returns the sequence feature table.
3000 ** Because this is a pointer to the real internal table
3001 ** the caller must take care not to change it in any way,
3002 ** or to delete it.
3003 **
3004 ** If the table is to be changed or deleted then it must first
3005 ** be copied with ajSeqCopyFeat
3006 **
3007 ** @param [r] seq [const AjPSeq] Sequence object.
3008 ** @return [const AjPFeattable] feature table (if any)
3009 **
3010 ** @release 1.0.0
3011 ** @@
3012 ******************************************************************************/
3013 
ajSeqGetFeat(const AjPSeq seq)3014 const AjPFeattable ajSeqGetFeat(const AjPSeq seq)
3015 {
3016     return seq->Fttable;
3017 }
3018 
3019 
3020 
3021 
3022 /* @func ajSeqGetFeatCopy *****************************************************
3023 **
3024 ** Returns a copy of the sequence feature table.
3025 ** Because this is a copy of all the data, the caller is responsible
3026 ** for deleting it after use.
3027 **
3028 ** If the table is not to be changed or deleted then ajSeqGetFeat
3029 ** can return a copy of the internal pointer.
3030 **
3031 ** @param [r] seq [const AjPSeq] Sequence object.
3032 ** @return [AjPFeattable] feature table (if any)
3033 **
3034 ** @release 4.0.0
3035 ** @@
3036 ******************************************************************************/
3037 
ajSeqGetFeatCopy(const AjPSeq seq)3038 AjPFeattable ajSeqGetFeatCopy(const AjPSeq seq)
3039 {
3040     return ajFeattableNewFtable(seq->Fttable);
3041 }
3042 
3043 
3044 
3045 
3046 /* @func ajSeqGetGiC **********************************************************
3047 **
3048 ** Returns the GI version number.
3049 ** Because this is a pointer to the real internal string
3050 ** the caller must take care not to change the character string in any way.
3051 ** If the string is to be changed (case for example) then it must first
3052 ** be copied.
3053 **
3054 ** @param [r] seq [const AjPSeq] Sequence object.
3055 ** @return [const char*] SeqVersion number as a character string.
3056 **
3057 ** @release 4.0.0
3058 ** @@
3059 ******************************************************************************/
3060 
ajSeqGetGiC(const AjPSeq seq)3061 const char* ajSeqGetGiC(const AjPSeq seq)
3062 {
3063     return MAJSTRGETPTR(seq->Gi);
3064 }
3065 
3066 
3067 
3068 
3069 /* @func ajSeqGetGiS **********************************************************
3070 **
3071 ** Returns the GI version number.
3072 ** Because this is a pointer to the real internal string
3073 ** the caller must take care not to change the character string in any way.
3074 ** If the string is to be changed (case for example) then it must first
3075 ** be copied.
3076 **
3077 ** @param [r] seq [const AjPSeq] Sequence object.
3078 ** @return [const AjPStr] SeqVersion number as a string.
3079 **
3080 ** @release 4.0.0
3081 ** @@
3082 ******************************************************************************/
3083 
ajSeqGetGiS(const AjPSeq seq)3084 const AjPStr ajSeqGetGiS(const AjPSeq seq)
3085 {
3086     if(seq->Gi)
3087         return seq->Gi;
3088     return ajStrConstEmpty();
3089 }
3090 
3091 
3092 
3093 
3094 /* @func ajSeqGetLen **********************************************************
3095 **
3096 ** Returns the sequence length.
3097 **
3098 ** @param [r] seq [const AjPSeq] Sequence object
3099 ** @return [ajuint] Sequence length.
3100 **
3101 ** @release 4.0.0
3102 ** @@
3103 ******************************************************************************/
3104 
ajSeqGetLen(const AjPSeq seq)3105 ajuint ajSeqGetLen(const AjPSeq seq)
3106 {
3107     return ajStrGetLen(seq->Seq);
3108 }
3109 
3110 
3111 
3112 
3113 /* @func ajSeqGetLenTrimmed ***************************************************
3114 **
3115 ** Returns the sequence length after trimming begin and end positions
3116 **
3117 ** @param [r] seq [const AjPSeq] Sequence object
3118 ** @return [ajuint] Sequence length.
3119 **
3120 ** @release 6.1.0
3121 ** @@
3122 ******************************************************************************/
3123 
ajSeqGetLenTrimmed(const AjPSeq seq)3124 ajuint ajSeqGetLenTrimmed(const AjPSeq seq)
3125 {
3126     return ajSeqGetEnd(seq) - ajSeqGetBegin(seq) + 1 ;
3127 }
3128 
3129 
3130 
3131 
3132 /* @func ajSeqGetLenTrue ******************************************************
3133 **
3134 ** Returns the length of the original sequence, including any gap characters.
3135 **
3136 ** @param [r] seq [const AjPSeq] Target sequence.
3137 ** @return [ajuint] string position between 1 and length.
3138 **
3139 ** @release 4.0.0
3140 ** @@
3141 ******************************************************************************/
3142 
ajSeqGetLenTrue(const AjPSeq seq)3143 ajuint ajSeqGetLenTrue(const AjPSeq seq)
3144 {
3145     return (ajStrGetLen(seq->Seq) + seq->Offset + seq->Offend);
3146 }
3147 
3148 
3149 
3150 
3151 /* @func ajSeqGetLenUngapped **************************************************
3152 **
3153 ** Returns the sequence length excluding all gap characters.
3154 **
3155 ** @param [r] seq [const AjPSeq] Sequence object
3156 ** @return [ajuint] Sequence length.
3157 **
3158 ** @release 6.1.0
3159 ** @@
3160 ******************************************************************************/
3161 
ajSeqGetLenUngapped(const AjPSeq seq)3162 ajuint ajSeqGetLenUngapped(const AjPSeq seq)
3163 {
3164     ajint ret = 0;
3165     const char *gapchars = "-.~";
3166     const char* cp;
3167     size_t i;
3168 
3169     cp = ajStrGetPtr(seq->Seq);
3170     i = strspn(cp, gapchars);
3171     cp += i;
3172 
3173     while (*cp)
3174     {
3175         i = strcspn(cp, gapchars);
3176         ret += i;
3177         cp += i;
3178         cp += strspn(cp, gapchars);
3179     }
3180 
3181     return ret;
3182 }
3183 
3184 
3185 
3186 
3187 /* @func ajSeqGetNameC ********************************************************
3188 **
3189 ** Returns the sequence name.
3190 ** Because this is a pointer to the real internal string
3191 ** the caller must take care not to change the character string in any way.
3192 ** If the string is to be changed (case for example) then it must first
3193 ** be copied.
3194 **
3195 ** @param [r] seq [const AjPSeq] Sequence object.
3196 ** @return [const char*] Name as a character string.
3197 **
3198 ** @release 4.0.0
3199 ** @@
3200 ******************************************************************************/
3201 
ajSeqGetNameC(const AjPSeq seq)3202 const char* ajSeqGetNameC(const AjPSeq seq)
3203 {
3204     if(!seq)
3205         return "";
3206 
3207     return MAJSTRGETPTR(seq->Name);
3208 }
3209 
3210 
3211 
3212 
3213 /* @func ajSeqGetNameS ********************************************************
3214 **
3215 ** Returns the sequence name.
3216 ** Because this is a pointer to the real internal string
3217 ** the caller must take care not to change the character string in any way.
3218 ** If the string is to be changed (case for example) then it must first
3219 ** be copied.
3220 **
3221 ** @param [r] seq [const AjPSeq] Sequence object.
3222 ** @return [const AjPStr] Name as a string.
3223 **
3224 ** @release 4.0.0
3225 ** @@
3226 ******************************************************************************/
3227 
ajSeqGetNameS(const AjPSeq seq)3228 const AjPStr ajSeqGetNameS(const AjPSeq seq)
3229 {
3230     if(!seq)
3231         return ajStrConstEmpty();
3232 
3233     if(seq->Name)
3234         return seq->Name;
3235 
3236     return ajStrConstEmpty();
3237 }
3238 
3239 
3240 
3241 
3242 /* @func ajSeqGetOffend *******************************************************
3243 **
3244 ** Returns the sequence offend value.
3245 ** This is the number of positions removed from the original end.
3246 **
3247 ** @param [r] seq [const AjPSeq] Sequence object
3248 ** @return [ajuint] Sequence offend.
3249 **
3250 ** @release 4.0.0
3251 ** @@
3252 ******************************************************************************/
3253 
ajSeqGetOffend(const AjPSeq seq)3254 ajuint ajSeqGetOffend(const AjPSeq seq)
3255 {
3256     return seq->Offend;
3257 }
3258 
3259 
3260 
3261 
3262 /* @func ajSeqGetOffset *******************************************************
3263 **
3264 ** Returns the sequence offset from -sbegin originally.
3265 **
3266 ** @param [r] seq [const AjPSeq] Sequence object
3267 ** @return [ajuint] Sequence offset.
3268 **
3269 ** @release 4.0.0
3270 ** @@
3271 ******************************************************************************/
3272 
ajSeqGetOffset(const AjPSeq seq)3273 ajuint ajSeqGetOffset(const AjPSeq seq)
3274 {
3275     return seq->Offset;
3276 }
3277 
3278 
3279 
3280 
3281 /* @func ajSeqGetQual *********************************************************
3282 **
3283 ** Returns the base quality scores as an array.
3284 ** Because this is a pointer to the real internal array
3285 ** the caller must take care not to change the array in any way.
3286 **
3287 ** @param [r] seq [const AjPSeq] Sequence.
3288 ** @return [const float*] Base quality scores.
3289 **
3290 ** @release 6.3.0
3291 ** @@
3292 ******************************************************************************/
3293 
ajSeqGetQual(const AjPSeq seq)3294 const float* ajSeqGetQual(const AjPSeq seq)
3295 {
3296     if(!seq)
3297 	return NULL;
3298 
3299     return seq->Accuracy;
3300 }
3301 
3302 
3303 
3304 
3305 /* @func ajSeqGetRange ********************************************************
3306 **
3307 ** Returns the sequence range for a sequence.
3308 **
3309 ** @param [r] seq [const AjPSeq] Sequence object.
3310 ** @param [w] begin [ajint*] Sequence range begin
3311 ** @param [w] end [ajint*] Sequence range end
3312 ** @return [ajuint] Sequence range length
3313 **
3314 ** @release 1.0.0
3315 ** @@
3316 ******************************************************************************/
3317 
ajSeqGetRange(const AjPSeq seq,ajint * begin,ajint * end)3318 ajuint ajSeqGetRange(const AjPSeq seq, ajint* begin, ajint* end)
3319 {
3320     ajint jbegin;
3321     ajint jend;
3322 
3323     jbegin = seq->Begin;
3324 
3325     if(seq->Begin > 0)
3326 	jbegin--;
3327 
3328     jend = seq->End;
3329 
3330     if(seq->End > 0)
3331 	jend--;
3332 
3333     ajDebug("ajSeqGetRange '%S'\n", seq->Name);
3334     *begin = ajCvtSposToPos(ajSeqGetLen(seq), jbegin); /* string position */
3335 
3336     if(seq->End)
3337 	*end = 1 + ajCvtSposToPosStart(ajSeqGetLen(seq), *begin, jend);
3338     else
3339 	*end = 1 + ajCvtSposToPosStart(ajSeqGetLen(seq),
3340                                        *begin, ajSeqGetLen(seq));
3341 
3342     (*begin)++;				/* sequence positions are 1..end */
3343 
3344     return (*end - *begin + 1);
3345 }
3346 
3347 
3348 
3349 
3350 /* @func ajSeqGetRev **********************************************************
3351 **
3352 ** Returns the sequence direction.
3353 **
3354 ** See ajSeqReversed for whether it has already been reverse-complemented
3355 **
3356 ** @param [r] seq [const AjPSeq] Sequence object
3357 ** @return [AjBool] Sequence Direction.
3358 **
3359 ** @release 4.0.0
3360 ** @@
3361 ******************************************************************************/
3362 
ajSeqGetRev(const AjPSeq seq)3363 AjBool ajSeqGetRev(const AjPSeq seq)
3364 {
3365     return seq->Rev;
3366 }
3367 
3368 
3369 
3370 
3371 /* @func ajSeqGetSeqC *********************************************************
3372 **
3373 ** Returns the sequence in a sequence object as a character string.
3374 ** Because this is a pointer to the real internal string
3375 ** the caller must take care not to change the character string in any way.
3376 ** If the string is to be changed (case for example) then it must first
3377 ** be copied.
3378 **
3379 ** @param [r] seq [const AjPSeq] Sequence.
3380 ** @return [const char*] Sequence as a character string.
3381 **
3382 ** @release 4.0.0
3383 ** @@
3384 ******************************************************************************/
3385 
ajSeqGetSeqC(const AjPSeq seq)3386 const char* ajSeqGetSeqC(const AjPSeq seq)
3387 {
3388     if(!seq)
3389 	return "";
3390 
3391     return MAJSTRGETPTR(seq->Seq);
3392 }
3393 
3394 
3395 
3396 
3397 /* @func ajSeqGetSeqS *********************************************************
3398 **
3399 ** Returns the sequence in a sequence object as a string.
3400 ** Because this is a pointer to the real internal string
3401 ** the caller must take care not to change the character string in any way.
3402 ** If the string is to be changed (case for example) then it must first
3403 ** be copied.
3404 **
3405 ** @param [r] seq [const AjPSeq] Sequence.
3406 ** @return [const AjPStr] Sequence as a string.
3407 **
3408 ** @release 4.0.0
3409 ** @@
3410 ******************************************************************************/
3411 
ajSeqGetSeqS(const AjPSeq seq)3412 const AjPStr ajSeqGetSeqS(const AjPSeq seq)
3413 {
3414     if(!seq)
3415 	return NULL;
3416     if(seq->Seq)
3417         return seq->Seq;
3418     return ajStrConstEmpty();
3419 }
3420 
3421 
3422 
3423 
3424 /* @func ajSeqGetSeqCopyC *****************************************************
3425 **
3426 ** Returns a sequence as a C character string. This is a copy of the string
3427 ** so the caller can do anything with it.
3428 ** It must be copied back
3429 ** to a sequence (e.g. with ajSeqReplace) before output.
3430 **
3431 ** @param [r] seq [const AjPSeq] Sequence object
3432 ** @return [char*] Sequence as a null terminated character string.
3433 **
3434 ** @release 4.0.0
3435 ** @@
3436 ******************************************************************************/
3437 
ajSeqGetSeqCopyC(const AjPSeq seq)3438 char* ajSeqGetSeqCopyC(const AjPSeq seq)
3439 {
3440     return ajCharNewS(seq->Seq);
3441 }
3442 
3443 
3444 
3445 
3446 /* @func ajSeqGetSeqCopyS *****************************************************
3447 **
3448 ** Returns the sequence in a sequence object as a string.
3449 ** Because this is a copy of the internal string
3450 ** the caller may change the string. It must be copied back
3451 ** to a sequence (e.g. with ajSeqReplace) before output.
3452 **
3453 ** @param [r] seq [const AjPSeq] Sequence.
3454 ** @return [AjPStr] Sequence as a string.
3455 **
3456 ** @release 4.0.0
3457 ** @@
3458 ******************************************************************************/
3459 
ajSeqGetSeqCopyS(const AjPSeq seq)3460 AjPStr ajSeqGetSeqCopyS(const AjPSeq seq)
3461 {
3462     static AjPStr str;
3463 
3464     str = ajStrNewS(seq->Seq);
3465 
3466     return str;
3467 }
3468 
3469 
3470 
3471 
3472 /* @func ajSeqGetSvC **********************************************************
3473 **
3474 ** Returns the sequence version number.
3475 ** Because this is a pointer to the real internal string
3476 ** the caller must take care not to change the character string in any way.
3477 ** If the string is to be changed (case for example) then it must first
3478 ** be copied.
3479 **
3480 ** @param [r] seq [const AjPSeq] Sequence object.
3481 ** @return [const char*] SeqVersion number as a character string.
3482 **
3483 ** @release 4.0.0
3484 ** @@
3485 ******************************************************************************/
3486 
ajSeqGetSvC(const AjPSeq seq)3487 const char* ajSeqGetSvC(const AjPSeq seq)
3488 {
3489     return MAJSTRGETPTR(seq->Sv);
3490 }
3491 
3492 
3493 
3494 
3495 /* @func ajSeqGetSvS **********************************************************
3496 **
3497 ** Returns the sequence version number.
3498 ** Because this is a pointer to the real internal string
3499 ** the caller must take care not to change the character string in any way.
3500 ** If the string is to be changed (case for example) then it must first
3501 ** be copied.
3502 **
3503 ** @param [r] seq [const AjPSeq] Sequence object.
3504 ** @return [const AjPStr] SeqVersion number as a string.
3505 **
3506 ** @release 4.0.0
3507 ** @@
3508 ******************************************************************************/
3509 
ajSeqGetSvS(const AjPSeq seq)3510 const AjPStr ajSeqGetSvS(const AjPSeq seq)
3511 {
3512     if(seq->Sv)
3513         return seq->Sv;
3514     return ajStrConstEmpty();
3515 }
3516 
3517 
3518 
3519 
3520 /* @func ajSeqGetTaxC *********************************************************
3521 **
3522 ** Returns the sequence primary taxon (species).
3523 ** Because this is a pointer to the real internal string
3524 ** the caller must take care not to change the character string in any way.
3525 ** If the string is to be changed (case for example) then it must first
3526 ** be copied.
3527 **
3528 ** @param [r] seq [const AjPSeq] Sequence object.
3529 ** @return [const char*] Description as a character string.
3530 **
3531 ** @release 4.0.0
3532 ** @@
3533 ******************************************************************************/
3534 
ajSeqGetTaxC(const AjPSeq seq)3535 const char* ajSeqGetTaxC(const AjPSeq seq)
3536 {
3537     return MAJSTRGETPTR(seq->Tax);
3538 }
3539 
3540 
3541 
3542 
3543 /* @func ajSeqGetTaxS *********************************************************
3544 **
3545 ** Returns the sequence primary taxon (species).
3546 ** Because this is a pointer to the real internal string
3547 ** the caller must take care not to change the character string in any way.
3548 ** If the string is to be changed (case for example) then it must first
3549 ** be copied.
3550 **
3551 ** @param [r] seq [const AjPSeq] Sequence object.
3552 ** @return [const AjPStr] Description as a string.
3553 **
3554 ** @release 4.0.0
3555 ** @@
3556 ******************************************************************************/
3557 
ajSeqGetTaxS(const AjPSeq seq)3558 const AjPStr ajSeqGetTaxS(const AjPSeq seq)
3559 {
3560     if(seq->Tax)
3561         return seq->Tax;
3562     return ajStrConstEmpty();
3563 }
3564 
3565 
3566 
3567 
3568 /* @func ajSeqGetTaxid ********************************************************
3569 **
3570 ** Returns the numeric identifier of the sequence primary taxon (species).
3571 ** This is an identifier from the NCBI taxonomy
3572 **
3573 ** @param [r] seq [const AjPSeq] Sequence object.
3574 ** @return [ajuint] Taxon ID.
3575 **
3576 ** @release 6.1.0
3577 ** @@
3578 ******************************************************************************/
3579 
ajSeqGetTaxid(const AjPSeq seq)3580 ajuint ajSeqGetTaxid(const AjPSeq seq)
3581 {
3582     ajuint ret = 0;
3583     ajuint i = 0;
3584 
3585     if(ajStrGetLen(seq->Taxid))
3586     {
3587         ajStrToUint(seq->Taxid, &ret);
3588 
3589         return ret;
3590     }
3591 
3592     while(seqTaxon[i].Name)
3593     {
3594         if(ajStrPrefixCaseC(seq->Tax, seqTaxon[i].Name))
3595         {
3596             return seqTaxon[i].Taxid;
3597         }
3598 
3599         i++;
3600     }
3601 
3602     return 0;
3603 }
3604 
3605 
3606 
3607 
3608 /* @func ajSeqGetUsaC *********************************************************
3609 **
3610 ** Returns the original USA of a sequence.
3611 ** Because this is a pointer to the real internal string
3612 ** the caller must take care not to change the character string in any way.
3613 ** If the string is to be changed (case for example) then it must first
3614 ** be copied.
3615 **
3616 ** @param [r] seq [const AjPSeq] Sequence object.
3617 ** @return [const char*] USA as a character string.
3618 **
3619 ** @release 4.0.0
3620 ** @@
3621 ******************************************************************************/
3622 
ajSeqGetUsaC(const AjPSeq seq)3623 const char* ajSeqGetUsaC(const AjPSeq seq)
3624 {
3625     return MAJSTRGETPTR(ajSeqGetUsaS(seq));
3626 }
3627 
3628 
3629 
3630 
3631 /* @func ajSeqGetUsaS *********************************************************
3632 **
3633 ** Returns the original USA of a sequence.
3634 ** Because this is a pointer to the real internal string
3635 ** the caller must take care not to change the character string in any way.
3636 ** If the string is to be changed (case for example) then it must first
3637 ** be copied.
3638 **
3639 ** @param [r] seq [const AjPSeq] Sequence object.
3640 ** @return [const AjPStr] USA as a string.
3641 **
3642 ** @release 4.0.0
3643 ** @@
3644 ******************************************************************************/
3645 
ajSeqGetUsaS(const AjPSeq seq)3646 const AjPStr ajSeqGetUsaS(const AjPSeq seq)
3647 {
3648     ajDebug("ajSeqGetUsa '%S'\n", seq->Usa);
3649 
3650     if(ajStrGetLen(seq->Usa))
3651 	return seq->Usa;
3652 
3653     seqMakeUsa(seq, &seqTempUsa);
3654 
3655     return seqTempUsa;
3656 }
3657 
3658 
3659 
3660 
3661 /* @func ajSeqGetXrefs ********************************************************
3662 **
3663 ** Returns the list of cross-references derived from the sequence
3664 **
3665 ** @param [r] seq [const AjPSeq] Sequence object.
3666 ** @param [u] list [AjPList] List of cross-reference objects
3667 ** @return [ajuint] Number of cross-references returned
3668 **
3669 ** @release 6.4.0
3670 ** @@
3671 ******************************************************************************/
3672 
ajSeqGetXrefs(const AjPSeq seq,AjPList list)3673 ajuint ajSeqGetXrefs(const AjPSeq seq, AjPList list)
3674 {
3675     ajDebug("ajSeqGetXrefs '%S'\n", seq->Usa);
3676 
3677     ajSeqxreflistClone(seq->Xreflist, list);
3678 
3679     return (ajuint) ajListGetLength(list);
3680 }
3681 
3682 
3683 
3684 
3685 /* @section testing properties ***********************************************
3686 **
3687 ** @fdata [AjPSeq]
3688 ** @fcategory use
3689 **
3690 ** @nam3rule Is Test sequence property
3691 ** @nam4rule IsCircular Sequence is circular
3692 ** @nam4rule IsNuc Sequence is nucleotide
3693 ** @nam4rule IsProt Sequence is protein
3694 ** @nam4rule IsReversed Sequence is reversed
3695 ** @nam4rule IsSpecies Sequence is annotated as from a particular species
3696 ** @nam5rule IsSpeciesBsubtilis Sequence is from B. subtilis
3697 ** @nam5rule IsSpeciesHuman Sequence is from H. sapiens
3698 ** @nam5rule IsSpeciesMouse Sequence is from M. musculus
3699 ** @nam5rule IsSpeciesYeast Sequence is from S. cerevisiae
3700 ** @nam4rule IsTaxon Sequence is annotated as from a particular taxon id
3701 ** @nam4rule IsTrimmed Sequence is trimmed to a subsequence
3702 **
3703 ** @suffix True Sequence properties relative to the original sequence
3704 **
3705 ** @argrule Is seq [const AjPSeq] Sequence
3706 ** @argrule IsTaxon taxid [ajuint] NCBI Taxonomy ID
3707 **
3708 ** @valrule * [AjBool] Sequence boolean property
3709 **
3710 ******************************************************************************/
3711 
3712 
3713 
3714 
3715 /* @func ajSeqIsCircular ******************************************************
3716 **
3717 ** Returns true if a sequence is circular
3718 **
3719 ** @param [r] seq [const AjPSeq] Sequence
3720 ** @return [AjBool] ajTrue for a circular sequence
3721 **
3722 ** @release 2.5.0
3723 ** @@
3724 ******************************************************************************/
3725 
ajSeqIsCircular(const AjPSeq seq)3726 AjBool ajSeqIsCircular(const AjPSeq seq)
3727 {
3728     return seq->Circular;
3729 }
3730 
3731 
3732 
3733 
3734 /* @func ajSeqIsNuc ***********************************************************
3735 **
3736 ** Tests whether a sequence is nucleotide.
3737 **
3738 ** @param [r] seq [const AjPSeq] Sequence
3739 ** @return [AjBool] ajTrue for a nucleotide sequence.
3740 **
3741 ** @release 1.0.0
3742 ** @@
3743 ******************************************************************************/
3744 
ajSeqIsNuc(const AjPSeq seq)3745 AjBool ajSeqIsNuc(const AjPSeq seq)
3746 {
3747     ajDebug("ajSeqIsNuc Type '%S'\n", seq->Type);
3748 
3749     if(ajStrMatchC(seq->Type, "N"))
3750 	return ajTrue;
3751 
3752     if(ajStrMatchC(seq->Type, "P"))
3753 	return ajFalse;
3754 
3755     if(ajSeqTypeGapnucS(seq->Seq)) /* returns char 0 on success */
3756     {
3757 	ajDebug ("ajSeqIsNuc failed\n", seq->Type);
3758 	return ajFalse;
3759     }
3760 
3761     return ajTrue;
3762 }
3763 
3764 
3765 
3766 
3767 /* @func ajSeqIsProt **********************************************************
3768 **
3769 ** Tests whether a sequence is protein.
3770 **
3771 ** @param [r] seq [const AjPSeq] Sequence
3772 ** @return [AjBool] ajTrue for a protein sequence.
3773 **
3774 ** @release 1.0.0
3775 ** @@
3776 ******************************************************************************/
3777 
ajSeqIsProt(const AjPSeq seq)3778 AjBool ajSeqIsProt(const AjPSeq seq)
3779 {
3780     ajDebug("ajSeqIsProt Type '%S'\n", seq->Type);
3781 
3782     if(ajStrMatchC(seq->Type, "P"))
3783 	return ajTrue;
3784 
3785     if(ajStrMatchC(seq->Type, "N"))
3786 	return ajFalse;
3787 
3788     if(ajSeqTypeAnyprotS(seq->Seq))	/* returns char 0 on success */
3789     {
3790 	ajDebug ("ajSeqIsProt failed\n", seq->Type);
3791 
3792 	return ajFalse;
3793     }
3794 
3795     return ajTrue;
3796 }
3797 
3798 
3799 
3800 
3801 /* @func ajSeqIsReversed ******************************************************
3802 **
3803 ** Returns whether the sequence has been reversed
3804 **
3805 ** @param [r] seq [const AjPSeq] Sequence object
3806 ** @return [AjBool] Sequence Direction.
3807 **
3808 ** @release 3.0.0
3809 ** @@
3810 ******************************************************************************/
3811 
ajSeqIsReversed(const AjPSeq seq)3812 AjBool ajSeqIsReversed(const AjPSeq seq)
3813 {
3814     return seq->Reversed;
3815 }
3816 
3817 
3818 
3819 
3820 /* @func ajSeqIsReversedTrue **************************************************
3821 **
3822 ** Returns ajTrue if the sequence is reversed relative to the original sequence
3823 **
3824 ** If the sequence has already been reversed, or is set to be reversed,
3825 ** the result will be true.
3826 **
3827 ** @param [r] seq [const AjPSeq] Sequence object
3828 ** @return [AjBool] ajTrue if sequence is set to be reversed
3829 **
3830 ** @release 4.0.0
3831 ** @@
3832 ******************************************************************************/
3833 
ajSeqIsReversedTrue(const AjPSeq seq)3834 AjBool ajSeqIsReversedTrue(const AjPSeq seq)
3835 {
3836     if (seq->Reversed)
3837     {
3838 	if (seq->Rev)
3839 	    return ajFalse;
3840 	else
3841 	    return ajTrue;
3842     }
3843 
3844     return seq->Rev;
3845 }
3846 
3847 
3848 
3849 
3850 /* @func ajSeqIsSpeciesBsubtilis **********************************************
3851 **
3852 ** Tests whether a sequence is annotated as B. subtilis
3853 **
3854 ** @param [r] seq [const AjPSeq] Sequence
3855 ** @return [AjBool] ajTrue for a nucleotide sequence.
3856 **
3857 ** @release 6.1.0
3858 ** @@
3859 ******************************************************************************/
3860 
ajSeqIsSpeciesBsubtilis(const AjPSeq seq)3861 AjBool ajSeqIsSpeciesBsubtilis(const AjPSeq seq)
3862 {
3863     return ajSeqIsTaxon(seq, 1432);
3864 }
3865 
3866 
3867 
3868 
3869 /* @func ajSeqIsSpeciesHuman **************************************************
3870 **
3871 ** Tests whether a sequence is annotated as human
3872 **
3873 ** @param [r] seq [const AjPSeq] Sequence
3874 ** @return [AjBool] ajTrue for a nucleotide sequence.
3875 **
3876 ** @release 6.1.0
3877 ** @@
3878 ******************************************************************************/
3879 
ajSeqIsSpeciesHuman(const AjPSeq seq)3880 AjBool ajSeqIsSpeciesHuman(const AjPSeq seq)
3881 {
3882     return ajSeqIsTaxon(seq, 9606);
3883 }
3884 
3885 
3886 
3887 
3888 /* @func ajSeqIsSpeciesMouse **************************************************
3889 **
3890 ** Tests whether a sequence is annotated as mouse
3891 **
3892 ** @param [r] seq [const AjPSeq] Sequence
3893 ** @return [AjBool] ajTrue for a nucleotide sequence.
3894 **
3895 ** @release 6.1.0
3896 ** @@
3897 ******************************************************************************/
3898 
ajSeqIsSpeciesMouse(const AjPSeq seq)3899 AjBool ajSeqIsSpeciesMouse(const AjPSeq seq)
3900 {
3901     return ajSeqIsTaxon(seq, 10090);
3902 }
3903 
3904 
3905 
3906 
3907 /* @func ajSeqIsSpeciesYeast **************************************************
3908 **
3909 ** Tests whether a sequence is annotated as yeast (S. cerevisiae)
3910 **
3911 ** @param [r] seq [const AjPSeq] Sequence
3912 ** @return [AjBool] ajTrue for a nucleotide sequence.
3913 **
3914 ** @release 6.1.0
3915 ** @@
3916 ******************************************************************************/
3917 
ajSeqIsSpeciesYeast(const AjPSeq seq)3918 AjBool ajSeqIsSpeciesYeast(const AjPSeq seq)
3919 {
3920     return ajSeqIsTaxon(seq, 4932);
3921 }
3922 
3923 
3924 
3925 
3926 /* @func ajSeqIsTaxon *********************************************************
3927 **
3928 ** Tests whether a sequence is annotated as from a specific taxon ID.
3929 **
3930 ** @param [r] seq [const AjPSeq] Sequence
3931 ** @param [r] taxid [ajuint] NCBI Taxonomy ID
3932 ** @return [AjBool] ajTrue for a nucleotide sequence.
3933 **
3934 ** @release 6.1.0
3935 ** @@
3936 ******************************************************************************/
3937 
ajSeqIsTaxon(const AjPSeq seq,ajuint taxid)3938 AjBool ajSeqIsTaxon(const AjPSeq seq, ajuint taxid)
3939 {
3940     ajuint itax;
3941 
3942     itax = ajSeqGetTaxid(seq);
3943     if(itax != taxid)
3944         return ajFalse;
3945 
3946     return ajTrue;
3947 }
3948 
3949 
3950 
3951 
3952 /* @func ajSeqIsTrimmed *******************************************************
3953 **
3954 ** Returns ajTrue if the sequence is already trimmed
3955 **
3956 ** @param [r] seq [const AjPSeq] Sequence object
3957 ** @return [AjBool] ajTrue if sequence is set to be reversed
3958 **
3959 ** @release 3.0.0
3960 ** @@
3961 ******************************************************************************/
3962 
ajSeqIsTrimmed(const AjPSeq seq)3963 AjBool ajSeqIsTrimmed(const AjPSeq seq)
3964 {
3965     return seq->Trimmed;
3966 }
3967 
3968 
3969 
3970 
3971 /* @section conversion *******************************************************
3972 **
3973 ** Convert sequence to numbers for efficient processing
3974 **
3975 ** @fdata [AjPSeq]
3976 ** @fcategory derive
3977 **
3978 ** @nam3rule Convert Convert sequence to some other datatype
3979 ** @nam4rule ConvertNum Convert to integers
3980 **
3981 ** @argrule * seq [const AjPSeq]
3982 ** @argrule ConvertNum cvt [const AjPSeqCvt] Conversion table
3983 ** @argrule Num Pnumseq [AjPStr*] Output numeric version of the sequence
3984 **
3985 ** @valrule * [AjBool] True on success
3986 ******************************************************************************/
3987 
3988 
3989 
3990 
3991 /* @func ajSeqConvertNum ******************************************************
3992 **
3993 ** Converts a string of sequence characters to numbers using
3994 ** a conversion table.
3995 **
3996 ** @param [r] seq [const AjPSeq] Sequence as a string
3997 ** @param [r] cvt [const AjPSeqCvt] Conversion table.
3998 ** @param [w] Pnumseq [AjPStr*] Output numeric version of the sequence.
3999 ** @return [AjBool] ajTrue on success.
4000 **
4001 ** @release 4.1.0
4002 ** @@
4003 ******************************************************************************/
4004 
ajSeqConvertNum(const AjPSeq seq,const AjPSeqCvt cvt,AjPStr * Pnumseq)4005 AjBool ajSeqConvertNum(const AjPSeq seq, const AjPSeqCvt cvt, AjPStr* Pnumseq)
4006 {
4007     const char *cp;
4008     char *ncp;
4009 
4010     cp = ajStrGetPtr(seq->Seq);
4011 
4012     ajStrAssignS(Pnumseq, seq->Seq);
4013     ncp = ajStrGetuniquePtr(Pnumseq);
4014 
4015     while(*cp)
4016     {
4017 	*ncp = cvt->table[(ajint)*cp];
4018 	cp++;
4019 	ncp++;
4020     }
4021 
4022     return ajTrue;
4023 }
4024 
4025 
4026 
4027 
4028 /* @section calculated properties
4029 **
4030 ** @fdata [AjPSeq]
4031 ** @fcategory use
4032 **
4033 ** @nam3rule Calc Calculate a value
4034 ** @nam4rule CalcCheckgcg Calculate GCG checksum
4035 ** @nam4rule CalcCount Count nucleotide bases
4036 ** @nam4rule CalcCrc Calculate cyclic redundancy checksum
4037 ** @nam4rule CalcMolwt Calculate molecular weight
4038 ** @nam4rule CalcTruepos Calculate sequence position
4039 ** @nam5rule CalcTrueposMin Calculate sequence position in range
4040 ** @nam3rule Count Count statistics over a sequence
4041 ** @nam4rule CountGaps Count gap characters
4042 **
4043 ** @argrule Seq seq [const AjPSeq] Sequence
4044 ** @argrule CalcCount b [ajint*] Nucleotide base count
4045 ** @argrule Min imin [ajint] Minimum relative position
4046 ** @argrule Truepos ipos [ajint] Relative position
4047 **
4048 ** @valrule CalcCheckgcg [ajint] GCG checksum
4049 ** @valrule CalcMolwt [float] Molecular weight
4050 ** @valrule CalcCrc [ajuint] Cyclic redundancy checksum
4051 ** @valrule CalcCount [void]
4052 ** @valrule CalcTruepos [ajint] Sequence position in original
4053 ** @valrule CountGaps [ajuint] Number of gap characters
4054 ******************************************************************************/
4055 
4056 
4057 
4058 
4059 /* @func ajSeqCalcCheckgcg ****************************************************
4060 **
4061 ** Calculates a GCG checksum for a sequence.
4062 **
4063 ** @param [r] seq [const AjPSeq] Sequence.
4064 ** @return [ajint] GCG checksum.
4065 **
4066 ** @release 4.0.0
4067 ** @@
4068 ******************************************************************************/
4069 
ajSeqCalcCheckgcg(const AjPSeq seq)4070 ajint ajSeqCalcCheckgcg(const AjPSeq seq)
4071 {
4072     register ajlong  i;
4073     register ajlong  check = 0;
4074     register ajlong  count = 0;
4075     const char *cp;
4076     ajint ilen;
4077 
4078     cp   = ajStrGetPtr(seq->Seq);
4079     ilen = ajStrGetLen(seq->Seq);
4080 
4081     for(i = 0; i < ilen; i++)
4082     {
4083 	count++;
4084 	check += count * toupper((ajint) cp[i]);
4085 	if(count == 57)
4086 	    count = 0;
4087     }
4088 
4089     check %= 10000;
4090 
4091     return (ajint) check;
4092 }
4093 
4094 
4095 
4096 
4097 /* @func ajSeqCalcCount *******************************************************
4098 **
4099 ** Counts the numbers of A, C, G and T in a nucleotide sequence.
4100 **
4101 ** @param [r] seq [const AjPSeq] Sequence object
4102 ** @param [w] b [ajint*] integer array, minimum size 5, to hold the results.
4103 ** @return [void]
4104 **
4105 ** @release 4.0.0
4106 ** @@
4107 ******************************************************************************/
4108 
ajSeqCalcCount(const AjPSeq seq,ajint * b)4109 void ajSeqCalcCount(const AjPSeq seq, ajint* b)
4110 {
4111     const char* cp;
4112 
4113     ajDebug("ajSeqCount %d bases\n", ajSeqGetLen(seq));
4114 
4115     b[0] = b[1] = b[2] = b[3] = b[4] = 0;
4116 
4117     cp = ajStrGetPtr(seq->Seq);
4118 
4119     while(*cp)
4120     {
4121 	switch (*cp)
4122 	{
4123             case 'A':
4124             case 'a':
4125                 b[0]++;
4126                 break;
4127             case 'C':
4128             case 'c':
4129                 b[1]++;
4130                 break;
4131             case 'G':
4132             case 'g':
4133                 b[2]++;
4134                 break;
4135             case 'T':
4136             case 't':
4137             case 'U':
4138             case 'u':
4139                 b[3]++;
4140                 break;
4141             default:
4142                 break;
4143 	}
4144 	cp++;
4145     }
4146 
4147     b[4] = ajSeqGetLen(seq) - b[0] - b[1] - b[2] - b[3];
4148 
4149     return;
4150 }
4151 
4152 
4153 
4154 
4155 /* @func ajSeqCalcMolwt *******************************************************
4156 **
4157 ** Calculates the molecular weight of a protein sequence.
4158 **
4159 ** @param [r] seq [const AjPSeq] Sequence
4160 ** @return [float] Molecular weight.
4161 **
4162 ** @release 4.0.0
4163 ** @@
4164 ******************************************************************************/
4165 
ajSeqCalcMolwt(const AjPSeq seq)4166 float ajSeqCalcMolwt(const AjPSeq seq)
4167 {
4168     return ajSeqstrCalcMolwt(seq->Seq);
4169 }
4170 
4171 
4172 
4173 
4174 /* @func ajSeqCalcTruepos *****************************************************
4175 **
4176 ** Converts a string position into a true position. If ipos is negative,
4177 ** it is counted from the end of the string rather than the beginning.
4178 **
4179 ** For strings, the result can go off the end to the terminating NULL.
4180 ** For sequences the maximum is the last base
4181 **
4182 ** @param [r] seq [const AjPSeq] Target sequence.
4183 ** @param [r] ipos [ajint] Position.
4184 ** @return [ajint] string position between 1 and length.
4185 **
4186 ** @release 4.0.0
4187 ** @@
4188 ******************************************************************************/
4189 
ajSeqCalcTruepos(const AjPSeq seq,ajint ipos)4190 ajint ajSeqCalcTruepos(const AjPSeq seq, ajint ipos)
4191 {
4192     ajint jpos;
4193 
4194     jpos = ipos;
4195 
4196     if (ipos > 0)
4197 	jpos = ipos - 1;
4198 
4199     if(ajSeqGetRev(seq))
4200 	return 1 + seq->Offend + ajCvtSposToPosStart(ajSeqGetLen(seq), 0, jpos);
4201 
4202     return 1 + seq->Offset + ajCvtSposToPosStart(ajSeqGetLen(seq), 0, jpos);
4203 }
4204 
4205 
4206 
4207 
4208 /* @func ajSeqCalcTrueposMin **************************************************
4209 **
4210 ** Converts a string position into a true position. If ipos is negative,
4211 ** it is counted from the end of the string rather than the beginning.
4212 **
4213 ** imin is a minimum relative position, also counted from the end
4214 ** if negative. Usually this is the start position when the end of a range
4215 ** is being tested.
4216 **
4217 ** @param [r] seq [const AjPSeq] Target sequence.
4218 ** @param [r] imin [ajint] Start position.
4219 ** @param [r] ipos [ajint] Position.
4220 ** @return [ajint] string position between 1 and length.
4221 **
4222 ** @release 4.0.0
4223 ** @@
4224 ******************************************************************************/
4225 
ajSeqCalcTrueposMin(const AjPSeq seq,ajint imin,ajint ipos)4226 ajint ajSeqCalcTrueposMin(const AjPSeq seq, ajint imin, ajint ipos)
4227 {
4228     ajint jmin;
4229     ajint jpos;
4230 
4231     jmin = imin;
4232 
4233     if (imin > 0)
4234 	jmin--;
4235 
4236     jpos = ipos;
4237 
4238     if(ipos > 0)
4239 	jpos--;
4240 
4241     if(ajSeqGetRev(seq))
4242 	return 1 + seq->Offend + ajCvtSposToPosStart(ajSeqGetLen(seq),
4243 			  jmin, jpos);
4244     else
4245 	return 1 + seq->Offset + ajCvtSposToPosStart(ajSeqGetLen(seq),
4246 			  jmin, jpos);
4247 }
4248 
4249 
4250 
4251 
4252 /* @func ajSeqCountGaps *******************************************************
4253 **
4254 ** Returns the number of gaps in a sequence (counting any possible
4255 ** gap character
4256 **
4257 ** @param [r] seq [const AjPSeq] Sequence object
4258 ** @return [ajuint] Number of gaps
4259 **
4260 ** @release 4.1.0
4261 ******************************************************************************/
4262 
ajSeqCountGaps(const AjPSeq seq)4263 ajuint ajSeqCountGaps(const AjPSeq seq)
4264 {
4265     ajuint ret = 0;
4266 
4267     static char testchars[] = "-~.? "; /* all known gap characters */
4268     const char *testgap;
4269 
4270     testgap = testchars;
4271 
4272     while(*testgap)
4273     {
4274       ret += (ajuint) ajStrCalcCountK(seq->Seq, *testgap);
4275 	testgap++;
4276     }
4277 
4278     return ret;
4279 }
4280 
4281 
4282 
4283 
4284 /* @section exit **************************************************************
4285 **
4286 ** Functions called on exit from the program by ajExit to do
4287 ** any necessary cleanup and to report internal statistics to the debug file
4288 **
4289 ** @fdata      [AjPSeq]
4290 ** @fnote     general exit functions, no arguments
4291 **
4292 ** @nam3rule Exit Cleanup and report on exit
4293 **
4294 ** @valrule * [void]
4295 **
4296 ** @fcategory misc
4297 ******************************************************************************/
4298 
4299 
4300 
4301 
4302 /* @func ajSeqExit ************************************************************
4303 **
4304 ** Cleans up sequence processing  internal memory
4305 **
4306 ** @return [void]
4307 **
4308 ** @release 4.0.0
4309 ** @@
4310 ******************************************************************************/
4311 
ajSeqExit(void)4312 void ajSeqExit(void)
4313 {
4314     ajSeqReadExit();
4315     ajSeqoutExit();
4316     ajSeqTypeExit();
4317 
4318     ajStrDel(&seqVersionAccnum);
4319     ajStrDel(&seqTempUsa);
4320 
4321     ajStrDel(&seqMoleculeDef);
4322     ajStrDel(&seqDivisionDef);
4323     ajStrDel(&seqClassDef);
4324 
4325     ajTableDel(&seqTableMol);
4326     ajTableDel(&seqTableMolEmbl);
4327     ajTableDel(&seqTableMolDdbj);
4328     ajTableDel(&seqTableMolGb);
4329 
4330     ajTableDel(&seqTableDiv);
4331     ajTableDel(&seqTableDivEmbl);
4332     ajTableDel(&seqTableDivDdbj);
4333     ajTableDel(&seqTableDivGb);
4334 
4335     ajTableDel(&seqTableCls);
4336     ajTableDel(&seqTableClsEmbl);
4337     ajTableDel(&seqTableClsDdbj);
4338     ajTableDel(&seqTableClsGb);
4339 
4340     return;
4341 }
4342 
4343 
4344 
4345 
4346 /* @section debug *************************************************************
4347 **
4348 ** Reports sequence contents for debugging purposes
4349 **
4350 ** @fdata [AjPSeq]
4351 ** @fcategory misc
4352 **
4353 ** @nam3rule Trace    Print report to debug file (if any)
4354 ** @nam4rule TraceTitle  Print report to debug file (if any) with title
4355 **
4356 ** @argrule * seq [const AjPSeq]
4357 ** @argrule Title title [const char*]
4358 **
4359 ** @valrule * [void]
4360 ******************************************************************************/
4361 
4362 
4363 
4364 
4365 /* @func ajSeqTrace ***********************************************************
4366 **
4367 ** Debug calls to trace the data in a sequence object.
4368 **
4369 ** @param [r] seq [const AjPSeq] Sequence.
4370 ** @return [void]
4371 **
4372 ** @release 1.0.0
4373 ** @@
4374 ******************************************************************************/
4375 
ajSeqTrace(const AjPSeq seq)4376 void ajSeqTrace(const AjPSeq seq)
4377 {
4378     AjIList it;
4379     AjPStr cur;
4380     ajint i;
4381 
4382     ajDebug("Sequence trace\n");
4383     ajDebug( "==============\n\n");
4384     ajDebug( "  Name: '%S'\n", seq->Name);
4385 
4386     if(ajStrGetLen(seq->Acc))
4387 	ajDebug( "  Accession: '%S'\n", seq->Acc);
4388 
4389     if(ajListGetLength(seq->Acclist))
4390     {
4391 	ajDebug( "  Acclist: (%Lu) ", ajListGetLength(seq->Acclist));
4392 	it = ajListIterNewread(seq->Acclist);
4393 
4394 	while((cur = (AjPStr) ajListIterGet(it)))
4395 	    ajDebug(" %S", cur);
4396 
4397 	ajListIterDel(&it);
4398 	ajDebug(" \n");
4399     }
4400 
4401     if(ajStrGetLen(seq->Sv))
4402 	ajDebug( "  SeqVersion: '%S'\n", seq->Sv);
4403 
4404     if(ajStrGetLen(seq->Gi))
4405 	ajDebug( "  GenInfo Id: '%S'\n", seq->Gi);
4406 
4407     if(ajStrGetLen(seq->Type))
4408 	ajDebug( "  Type: '%S' (%d)\n", seq->Type, seq->EType);
4409 
4410     if(ajStrGetLen(seq->Desc))
4411 	ajDebug( "  Description: '%S'\n", seq->Desc);
4412 
4413     if(ajStrGetLen(seq->Tax))
4414 	ajDebug( "  Taxonomy: '%S'\n", seq->Tax);
4415 
4416     if(ajStrGetLen(seq->Taxcommon))
4417 	ajDebug( "  Taxcommon: '%S'\n", seq->Taxcommon);
4418 
4419     if(ajStrGetLen(seq->Taxid))
4420 	ajDebug( "  Taxid: '%S'\n", seq->Taxid);
4421 
4422     if(ajStrGetLen(seq->Organelle))
4423 	ajDebug( "  Organelle: '%S'\n", seq->Organelle);
4424 
4425     if(ajListGetLength(seq->Taxlist))
4426     {
4427 	ajDebug( "  Taxlist: (%Lu)", ajListGetLength(seq->Taxlist));
4428 	it = ajListIterNewread(seq->Taxlist);
4429 
4430 	while((cur = (AjPStr) ajListIterGet(it)))
4431 	    ajDebug(" '%S'", cur);
4432 
4433 	ajListIterDel(&it);
4434 	ajDebug("\n");
4435     }
4436 
4437     if(ajListGetLength(seq->Keylist))
4438     {
4439 	ajDebug( "  Keywordlist: (%Lu)", ajListGetLength(seq->Keylist));
4440 	it = ajListIterNewread(seq->Keylist);
4441 
4442 	while((cur = (AjPStr) ajListIterGet(it)))
4443 	    ajDebug(" '%S'", cur);
4444 
4445 	ajListIterDel(&it);
4446 	ajDebug("\n");
4447     }
4448 
4449     if(ajSeqGetLen(seq))
4450 	ajDebug( "  Length: %d\n", ajSeqGetLen(seq));
4451 
4452     i = ajSeqCountGaps(seq);
4453 
4454     if(i)
4455 	ajDebug( "  Gap count: %d\n", i);
4456 
4457     if(seq->Rev)
4458 	ajDebug( "     Rev: %B\n", seq->Rev);
4459 
4460     if(seq->Reversed)
4461 	ajDebug( "Reversed: %B\n", seq->Reversed);
4462 
4463     if(seq->Begin)
4464 	ajDebug( "   Begin: %d\n", ajSeqGetBegin(seq));
4465 
4466     if(seq->End)
4467 	ajDebug( "     End: %d\n", ajSeqGetEnd(seq));
4468 
4469     if(seq->Offset)
4470 	ajDebug( "  Offset: %d\n", seq->Offset);
4471 
4472     if(seq->Offend)
4473 	ajDebug( "  Offend: %d\n", seq->Offend);
4474 
4475     if(ajStrGetRes(seq->Seq))
4476 	ajDebug( "  Reserved: %d\n", ajStrGetRes(seq->Seq));
4477 
4478     if(ajStrGetLen(seq->Db))
4479 	ajDebug( "  Database: '%S'\n", seq->Db);
4480 
4481     if(ajStrGetLen(seq->Full))
4482 	ajDebug( "  Full name: '%S'\n", seq->Full);
4483 
4484     if(ajStrGetLen(seq->Usa))
4485 	ajDebug( "  Usa: '%S'\n", seq->Usa);
4486 
4487     if(ajStrGetLen(seq->Ufo))
4488 	ajDebug( "  Ufo: '%S'\n", seq->Ufo);
4489 
4490     if(seq->Fttable)
4491 	ajDebug( "  Fttable: exists\n");
4492 
4493     if(ajStrGetLen(seq->Formatstr))
4494 	ajDebug( "  Input format: '%S' (%d)\n", seq->Formatstr, seq->Format);
4495 
4496     if(ajStrGetLen(seq->Filename))
4497 	ajDebug( "  Filename: '%S'\n", seq->Filename);
4498 
4499     if(ajStrGetLen(seq->Entryname))
4500 	ajDebug( "  Entryname: '%S'\n", seq->Entryname);
4501 
4502     if(!E_FPZERO(seq->Weight,U_FEPS))
4503 	ajDebug( "  Weight: %.3f\n", seq->Weight);
4504 
4505     if(ajStrGetLen(seq->Doc))
4506 	ajDebug( "  Documentation:...\n%S\n", seq->Doc);
4507 
4508 	ajDebug( "Sequence:...\n%S\n", seq->Seq);
4509     ajDebug( "\n");
4510 
4511     return;
4512 }
4513 
4514 
4515 
4516 
4517 /* @func ajSeqTraceTitle ******************************************************
4518 **
4519 ** Reports an AjPSeq object to debug output
4520 **
4521 ** @param [r] seq [const AjPSeq] alignment object
4522 ** @param [r] title [const char*] Trace report title
4523 ** @return [void]
4524 **
4525 ** @release 4.1.0
4526 ******************************************************************************/
4527 
ajSeqTraceTitle(const AjPSeq seq,const char * title)4528 void ajSeqTraceTitle(const AjPSeq seq, const char* title)
4529 {
4530     ajDebug("\n%s\n",title);
4531     ajSeqTrace(seq);
4532 
4533     return;
4534 }
4535 
4536 
4537 
4538 
4539 /* @datasection [AjPSeqall] Sequence stream************************************
4540 **
4541 ** Function is for manipulating sequence stream objects
4542 **
4543 ** @nam2rule Seqall
4544 **
4545 ******************************************************************************/
4546 
4547 
4548 
4549 
4550 /* @section Sequence Stream Constructors **************************************
4551 **
4552 ** @fdata [AjPSeqall]
4553 **
4554 ** All constructors return a new sequence stream object by pointer. It
4555 ** is the responsibility of the user to first destroy any previous
4556 ** sequence stream object. The target pointer does not need to be
4557 ** initialised to NULL, but it is good programming practice to do so
4558 ** anyway.
4559 **
4560 ** @nam3rule New Constructor
4561 **
4562 ** @valrule * [AjPSeqall]
4563 ** @fcategory new
4564 **
4565 ******************************************************************************/
4566 
4567 
4568 
4569 
4570 /* @func ajSeqallNew **********************************************************
4571 **
4572 ** Creates a new sequence stream object to hold one sequence at a time.
4573 **
4574 ** @return [AjPSeqall] New sequence stream object.
4575 **
4576 ** @release 1.0.0
4577 ** @@
4578 ******************************************************************************/
4579 
ajSeqallNew(void)4580 AjPSeqall ajSeqallNew(void)
4581 {
4582     AjPSeqall pthis;
4583 
4584     AJNEW0(pthis);
4585 
4586     pthis->Seq   = ajSeqNew();
4587     pthis->Seqin = ajSeqinNew();
4588     pthis->Count = 0;
4589     pthis->Totseqs = 0;
4590     pthis->Totlength = 0;
4591 
4592     return pthis;
4593 }
4594 
4595 
4596 
4597 
4598 /* @section  destructors ***************************************
4599 **
4600 ** Destruction destroys all internal data structures and frees the
4601 ** memory allocated for the sequence.
4602 **
4603 ** @fdata [AjPSeqall]
4604 **
4605 ** @nam3rule Del Destructor
4606 **
4607 ** @argrule Del Pseq [AjPSeqall*] Sequence stream object
4608 ** @valrule * [void]
4609 ** @fcategory delete
4610 **
4611 ******************************************************************************/
4612 
4613 
4614 
4615 
4616 /* @func ajSeqallDel **********************************************************
4617 **
4618 ** Destructor for sequence stream objects
4619 **
4620 ** @param [d] Pseq [AjPSeqall*] Sequence stream object reference
4621 ** @return [void]
4622 **
4623 ** @release 2.0.0
4624 ** @@
4625 ******************************************************************************/
4626 
ajSeqallDel(AjPSeqall * Pseq)4627 void ajSeqallDel(AjPSeqall *Pseq)
4628 {
4629     if(!*Pseq)
4630 	return;
4631 
4632     if(!(*Pseq)->Returned)
4633 	ajSeqDel(&(*Pseq)->Seq);
4634 
4635     ajDebug("ajSeqallDel\n");
4636     ajSeqinDel(&(*Pseq)->Seqin);
4637 
4638     AJFREE(*Pseq);
4639 
4640     return;
4641 }
4642 
4643 
4644 
4645 
4646 /* @section modifiers *****************************************
4647 **
4648 ** These functions use the contents of a sequence stream object and
4649 ** update them.
4650 **
4651 ** @fdata [AjPSeqall]
4652 ** @fcategory modify
4653 **
4654 ** @nam3rule Clear       Clear all sequence reading internals except statistics
4655 ** @nam4rule ClearStats  Clear all contents and reset statistics
4656 **
4657 ** @nam3rule Set      Set properties within sequence stream
4658 ** @nam4rule SetRange Set start and end position within sequence stream
4659 ** @nam5rule SetRangeRev Set start and end position and reverse direction
4660 **                       of a sequence stream
4661 **
4662 ** @argrule * seq [AjPSeqall] Sequence stream object
4663 ** @argrule Range pos1 [ajint] Start position
4664 ** @argrule Range pos2 [ajint] End  position
4665 **
4666 ** @valrule * [void]
4667 **
4668 ******************************************************************************/
4669 
4670 
4671 
4672 
4673 /* @func ajSeqallClear ********************************************************
4674 **
4675 ** Resets all data internals for a sequence stream object when
4676 ** input has been read, but leaves statistics for reporting.
4677 **
4678 ** @param [u] seq [AjPSeqall] Sequence stream
4679 ** @return [void]
4680 **
4681 ** @release 2.7.0
4682 ** @@
4683 ******************************************************************************/
4684 
ajSeqallClear(AjPSeqall seq)4685 void ajSeqallClear(AjPSeqall seq)
4686 {
4687     if(!seq)
4688         return;
4689 
4690     ajSeqClear(seq->Seq);
4691     ajSeqinClear(seq->Seqin);
4692     seq->Count = 0;
4693     seq->Begin = 0;
4694     seq->End   = 0;
4695     seq->Rev   = ajFalse;
4696     seq->Returned = ajFalse;
4697 
4698     return;
4699 }
4700 
4701 
4702 
4703 
4704 /* @func ajSeqallClearStats ***************************************************
4705 **
4706 ** Resets all data for a sequence stream object so that it can be reused,
4707 ** including statistics.
4708 **
4709 ** @param [u] seq [AjPSeqall] Sequence stream
4710 ** @return [void]
4711 **
4712 ** @release 6.1.0
4713 ** @@
4714 ******************************************************************************/
4715 
ajSeqallClearStats(AjPSeqall seq)4716 void ajSeqallClearStats(AjPSeqall seq)
4717 {
4718     ajSeqallClear(seq);
4719 
4720     seq->Totlength = 0;
4721     seq->Totseqs = 0;
4722 
4723     return;
4724 }
4725 
4726 
4727 
4728 
4729 /* @func ajSeqallSetRange *****************************************************
4730 **
4731 ** Sets the start and end positions for a sequence stream.
4732 **
4733 ** @param [u] seq [AjPSeqall] Sequence stream object to be set.
4734 ** @param [r] pos1 [ajint] Start position. Negative values are from the end.
4735 ** @param [r] pos2 [ajint] End position. Negative values are from the end.
4736 ** @return [void]
4737 **
4738 ** @release 1.0.0
4739 ** @@
4740 ******************************************************************************/
4741 
ajSeqallSetRange(AjPSeqall seq,ajint pos1,ajint pos2)4742 void ajSeqallSetRange(AjPSeqall seq, ajint pos1, ajint pos2)
4743 {
4744     ajDebug("ajSeqallSetRange (len: %d %d, %d)\n",
4745 	    ajSeqGetLen(seq->Seq), pos1, pos2);
4746 
4747     if(pos1)
4748 	seq->Begin = seq->Seq->Begin = pos1;
4749 
4750     if(pos2)
4751 	seq->End = seq->Seq->End = pos2;
4752 
4753     ajDebug("      result: (len: %d %d, %d)\n",
4754 	    ajSeqGetLen(seq->Seq), seq->Begin, seq->End);
4755 
4756     return;
4757 }
4758 
4759 
4760 
4761 
4762 /* @func ajSeqallSetRangeRev **************************************************
4763 **
4764 ** Sets the start and end positions for a sequence stream,
4765 ** and set the sequences to be reversed.
4766 **
4767 ** @param [u] seq [AjPSeqall] Sequence stream object to be set.
4768 ** @param [r] pos1 [ajint] Start position. Negative values are from the end.
4769 ** @param [r] pos2 [ajint] End position. Negative values are from the end.
4770 ** @return [void]
4771 **
4772 ** @release 4.0.0
4773 ** @@
4774 ******************************************************************************/
4775 
ajSeqallSetRangeRev(AjPSeqall seq,ajint pos1,ajint pos2)4776 void ajSeqallSetRangeRev(AjPSeqall seq, ajint pos1, ajint pos2)
4777 {
4778     ajDebug("ajSeqallSetRange (len: %d %d, %d)\n",
4779 	    ajSeqGetLen(seq->Seq), pos1, pos2);
4780 
4781     if(pos1)
4782 	seq->Begin = seq->Seq->Begin = pos1;
4783 
4784     if(pos2)
4785 	seq->End = seq->Seq->End = pos2;
4786 
4787     ajDebug("      result: (len: %d %d, %d)\n",
4788 	    ajSeqGetLen(seq->Seq), seq->Begin, seq->End);
4789 
4790     if(!seq->Rev)
4791     {
4792 	seq->Rev = ajTrue;
4793     }
4794 
4795     return;
4796 }
4797 
4798 
4799 
4800 
4801 /* @section casts *********************************************
4802 **
4803 ** These functions examine the contents of a sequence stream object
4804 ** and return some derived information. Some of them provide access to
4805 ** the internal components of a sequence stream object. They are
4806 ** provided for programming convenience but should be used with
4807 ** caution.
4808 **
4809 ** @fdata [AjPSeqall]
4810 ** @fcategory cast
4811 **
4812 ** @nam3rule Get Return properties of sequence stream
4813 ** @nam4rule GetCount Return number of sequences read
4814 ** @nam4rule GetFilename Return filename used for stream
4815 ** @nam4rule GetName Return name of sequence stream
4816 ** @nam4rule GetTotlength Return total length of sequences read
4817 ** @nam4rule GetUsa Return USA of sequence stream
4818 **
4819 ** @nam3rule Getseq Return properties of current sequence from stream
4820 ** @nam4rule GetseqBegin Return begin position set for stream
4821 ** @nam4rule GetseqEnd Return begin position set for stream
4822 ** @nam4rule GetseqLen Return length of current sequence from stream
4823 ** @nam4rule GetseqName Return name of current sequence from stream
4824 ** @nam4rule GetseqRange Return begin and end of sequence from stream
4825 **
4826 ** @argrule * seq [const AjPSeqall] Sequence stream object
4827 ** @argrule Range begin [ajint*] Returns begin position of range
4828 ** @argrule Range end [ajint*] Returns end position of range
4829 **
4830 ** @valrule Begin [ajint] Begin position
4831 ** @valrule Count [ajlong] Count of sequences read
4832 ** @valrule End [ajint] End position
4833 ** @valrule Filename [const AjPStr] Filename
4834 ** @valrule Name [const AjPStr] Sequence name
4835 ** @valrule Len [ajint] Sequence length
4836 ** @valrule Range [ajint] Sequence length
4837 ** @valrule Totlength [ajlong] Total length of sequences read
4838 ** @valrule Usa [const AjPStr] Sequence USA
4839 **
4840 ******************************************************************************/
4841 
4842 
4843 
4844 
4845 /* @func ajSeqallGetCount *****************************************************
4846 **
4847 ** Returns the number of sequences read by a seqall object
4848 **
4849 ** @param [r] seq [const AjPSeqall] Seqall object pointer.
4850 ** @return [ajlong] Number of sequences read.
4851 **
4852 ** @release 6.1.0
4853 ** @@
4854 ******************************************************************************/
4855 
ajSeqallGetCount(const AjPSeqall seq)4856 ajlong ajSeqallGetCount(const AjPSeqall seq)
4857 {
4858     if(!seq)
4859 	return 0;
4860 
4861     if(!seq->Seqin)
4862 	return 0;
4863 
4864     return seq->Totseqs;
4865 }
4866 
4867 
4868 
4869 
4870 /* @func ajSeqallGetFilename **************************************************
4871 **
4872 ** Returns the filename of a seqall object.
4873 ** Because this is a pointer to the real internal string
4874 ** the caller must take care not to change the character string in any way.
4875 ** If the string is to be changed (case for example) then it must first
4876 ** be copied.
4877 **
4878 ** @param [r] seq [const AjPSeqall] Seqall object pointer.
4879 ** @return [const AjPStr] Name as a string.
4880 **
4881 ** @release 4.0.0
4882 ** @@
4883 ******************************************************************************/
4884 
ajSeqallGetFilename(const AjPSeqall seq)4885 const AjPStr ajSeqallGetFilename(const AjPSeqall seq)
4886 {
4887     if(!seq)
4888 	return NULL;
4889 
4890     if(!seq->Seqin)
4891 	return NULL;
4892 
4893     ajDebug("ajSeqallGetFilename '%S' usa: '%S'\n",
4894 	    seq->Seqin->Name, seq->Seqin->Input->Qry);
4895 
4896 
4897 
4898     if(ajStrGetLen(seq->Seqin->Input->Filename))
4899 	return seq->Seqin->Input->Filename;
4900 
4901     return NULL;
4902 }
4903 
4904 
4905 
4906 
4907 /* @func ajSeqallGetName ******************************************************
4908 **
4909 ** Returns the sequence name of a sequence stream.
4910 ** Because this is a pointer to the real internal string
4911 ** the caller must take care not to change the character string in any way.
4912 ** If the string is to be changed (case for example) then it must first
4913 ** be copied.
4914 **
4915 ** @param [r] seq [const AjPSeqall] Sequence stream object.
4916 ** @return [const AjPStr] Name as a string.
4917 **
4918 ** @release 1.0.0
4919 ** @@
4920 ******************************************************************************/
4921 
ajSeqallGetName(const AjPSeqall seq)4922 const AjPStr ajSeqallGetName(const AjPSeqall seq)
4923 {
4924     ajDebug("ajSeqallGetName '%S'\n", seq->Seqin->Name);
4925 
4926     return seq->Seqin->Name;
4927 }
4928 
4929 
4930 
4931 
4932 /* @func ajSeqallGetTotlength *************************************************
4933 **
4934 ** Returns the total length of sequences read by a seqall object
4935 **
4936 ** @param [r] seq [const AjPSeqall] Seqall object pointer.
4937 ** @return [ajlong] Total length of sequences read.
4938 **
4939 ** @release 6.1.0
4940 ** @@
4941 ******************************************************************************/
4942 
ajSeqallGetTotlength(const AjPSeqall seq)4943 ajlong ajSeqallGetTotlength(const AjPSeqall seq)
4944 {
4945     if(!seq)
4946 	return 0;
4947 
4948     return seq->Totlength;
4949 }
4950 
4951 
4952 
4953 
4954 /* @func ajSeqallGetUsa *******************************************************
4955 **
4956 ** Returns the sequence name of a sequence stream.
4957 ** Because this is a pointer to the real internal string
4958 ** the caller must take care not to change the character string in any way.
4959 ** If the string is to be changed (case for example) then it must first
4960 ** be copied.
4961 **
4962 ** @param [r] seq [const AjPSeqall] Sequence object.
4963 ** @return [const AjPStr] Name as a string.
4964 **
4965 ** @release 1.8.0
4966 ** @@
4967 ******************************************************************************/
4968 
ajSeqallGetUsa(const AjPSeqall seq)4969 const AjPStr ajSeqallGetUsa(const AjPSeqall seq)
4970 {
4971     ajDebug("ajSeqallGetUsa '%S'\n", seq->Seqin->Input->Qry);
4972 
4973     return seq->Seqin->Input->Qry;
4974 }
4975 
4976 
4977 
4978 
4979 /* @func ajSeqallGetseqBegin **************************************************
4980 **
4981 ** Returns the sequence stream start position, or 1 if no start has been set.
4982 **
4983 ** @param [r] seq [const AjPSeqall] Sequence stream object
4984 ** @return [ajint] Start position.
4985 **
4986 ** @release 4.1.0
4987 ** @@
4988 ******************************************************************************/
4989 
ajSeqallGetseqBegin(const AjPSeqall seq)4990 ajint ajSeqallGetseqBegin(const AjPSeqall seq)
4991 {
4992     ajint jbegin;
4993 
4994     if (seq->Begin)
4995     {
4996 	jbegin = seq->Begin;
4997 
4998 	if(jbegin > 0)
4999 	    jbegin--;
5000 
5001 	return 1 + ajCvtSposToPosStart(ajSeqGetLen(seq->Seq), 0, jbegin);
5002     }
5003 
5004     if(seq->Seq->Begin)
5005     {
5006 	jbegin = seq->Seq->Begin;
5007 
5008 	if(jbegin > 0)
5009 	    jbegin--;
5010 
5011 	return 1 + ajCvtSposToPosStart(ajSeqGetLen(seq->Seq), 0, jbegin);
5012     }
5013 
5014     return 1;
5015 }
5016 
5017 
5018 
5019 
5020 /* @func ajSeqallGetseqEnd ****************************************************
5021 **
5022 ** Returns the sequence stream end position, or the sequence length if no end
5023 ** has been set.
5024 **
5025 ** @param [r] seq [const AjPSeqall] Sequence stream object
5026 ** @return [ajint] Start position.
5027 **
5028 ** @release 4.1.0
5029 ** @@
5030 ******************************************************************************/
5031 
ajSeqallGetseqEnd(const AjPSeqall seq)5032 ajint ajSeqallGetseqEnd(const AjPSeqall seq)
5033 {
5034     ajint jend;
5035 
5036     if (seq->End)
5037     {
5038 	jend = seq->End;
5039 
5040 	if(jend > 0)
5041 	    jend--;
5042 
5043 	return 1 + ajCvtSposToPosStart(ajSeqGetLen(seq->Seq),
5044                                        ajSeqallGetseqBegin(seq)-1, jend);
5045     }
5046 
5047     if(seq->Seq->End)
5048     {
5049 	jend = seq->Seq->End;
5050 
5051 	if(jend > 0)
5052 	    jend--;
5053 
5054 	return 1 + ajCvtSposToPosStart(ajSeqGetLen(seq->Seq),
5055                                        ajSeqallGetseqBegin(seq)-1, jend);
5056     }
5057 
5058     return ajSeqGetLen(seq->Seq);
5059 }
5060 
5061 
5062 
5063 
5064 /* @func ajSeqallGetseqLen ****************************************************
5065 **
5066 ** Returns the length of a sequence stream, which is the length of the
5067 ** latest sequence read.
5068 **
5069 ** @param [r] seq [const AjPSeqall] Sequence stream object
5070 ** @return [ajint] sequence length.
5071 **
5072 ** @release 4.1.0
5073 ** @@
5074 ******************************************************************************/
5075 
ajSeqallGetseqLen(const AjPSeqall seq)5076 ajint ajSeqallGetseqLen(const AjPSeqall seq)
5077 {
5078     return ajSeqGetLen(seq->Seq);
5079 }
5080 
5081 
5082 
5083 
5084 /* @func ajSeqallGetseqName ***************************************************
5085 **
5086 ** Returns the sequence name of a sequence stream.
5087 ** Because this is a pointer to the real internal string
5088 ** the caller must take care not to change the character string in any way.
5089 ** If the string is to be changed (case for example) then it must first
5090 ** be copied.
5091 **
5092 ** @param [r] seq [const AjPSeqall] Sequence stream object.
5093 ** @return [const AjPStr] Name as a string.
5094 **
5095 ** @release 4.1.0
5096 ** @@
5097 ******************************************************************************/
5098 
ajSeqallGetseqName(const AjPSeqall seq)5099 const AjPStr ajSeqallGetseqName(const AjPSeqall seq)
5100 {
5101     if(!seq)
5102         return ajStrConstEmpty();
5103 
5104     ajDebug("ajSeqallGetseqName '%S'\n", seq->Seq->Name);
5105 
5106     return ajSeqGetNameS(seq->Seq);
5107 }
5108 
5109 
5110 
5111 
5112 /* @func ajSeqallGetseqRange **************************************************
5113 **
5114 ** Returns the sequence range for a sequence stream
5115 **
5116 ** @param [r] seq [const AjPSeqall] Sequence stream object.
5117 ** @param [w] begin [ajint*] Sequence range begin
5118 ** @param [w] end [ajint*] Sequence range end
5119 ** @return [ajint] Sequence range length
5120 **
5121 ** @release 4.1.0
5122 ** @@
5123 ******************************************************************************/
5124 
ajSeqallGetseqRange(const AjPSeqall seq,ajint * begin,ajint * end)5125 ajint ajSeqallGetseqRange(const AjPSeqall seq, ajint* begin, ajint* end)
5126 {
5127     ajDebug("ajSeqallGetRange '%S'\n", seq->Seq->Name);
5128 
5129     return ajSeqGetRange(seq->Seq, begin, end);
5130 }
5131 
5132 
5133 
5134 
5135 /* @datasection [AjPSeqset] Sequence set **************************************
5136 **
5137 ** Function is for manipulating sequence set objects
5138 **
5139 ** @nam2rule Seqset
5140 **
5141 ******************************************************************************/
5142 
5143 
5144 
5145 
5146 /* @section constructors *****************************************
5147 **
5148 ** All constructors return a new sequence set object by pointer. It is the
5149 ** responsibility of the user to first destroy any previous
5150 ** sequence. The target pointer does not need to be initialised to
5151 ** NULL, but it is good programming practice to do so anyway.
5152 **
5153 ** @fdata [AjPSeqset]
5154 ** @fcategory new
5155 **
5156 ** @nam3rule New Constructor
5157 **
5158 ** @valrule * [AjPSeqset]
5159 **
5160 ******************************************************************************/
5161 
5162 
5163 
5164 
5165 /* @func ajSeqsetNew **********************************************************
5166 **
5167 ** Creates a new sequence set object to hold all sequences in memory.
5168 **
5169 ** @return [AjPSeqset] New sequence set object.
5170 **
5171 ** @release 1.0.0
5172 ** @@
5173 ******************************************************************************/
5174 
ajSeqsetNew(void)5175 AjPSeqset ajSeqsetNew(void)
5176 {
5177     AjPSeqset pthis;
5178 
5179     AJNEW0(pthis);
5180 
5181     pthis->Size      = 0;
5182     pthis->Len       = 0;
5183     pthis->Begin     = 0;
5184     pthis->End       = 0;
5185     pthis->Totweight = 0.0;
5186 
5187     pthis->Name = ajStrNew();
5188     pthis->Type = ajStrNew();
5189     pthis->Full = ajStrNew();
5190     pthis->Usa  = ajStrNew();
5191     pthis->Ufo  = ajStrNew();
5192 
5193     pthis->Formatstr = ajStrNew();
5194     pthis->Filename  = ajStrNew();
5195 
5196     pthis->Seq       = NULL;
5197     pthis->Seqweight = NULL;
5198 
5199     pthis->EType  = 0;
5200     pthis->Format = 0;
5201 
5202     return pthis;
5203 }
5204 
5205 
5206 
5207 
5208 /* @section  destructors ***************************************
5209 **
5210 ** Destruction destroys all internal data structures and frees the
5211 ** memory allocated for the sequence.
5212 **
5213 ** @fdata [AjPSeqset]
5214 **
5215 ** @nam3rule Del Destructor
5216 ** @nam3rule Delarray Array destructor
5217 **
5218 ** @argrule Del Pseq [AjPSeqset*] Sequence set object
5219 ** @argrule Delarray PPseq [AjPSeqset**] Sequence set object array
5220 ** @valrule * [void]
5221 ** @fcategory delete
5222 **
5223 ******************************************************************************/
5224 
5225 
5226 
5227 
5228 /* @func ajSeqsetDel **********************************************************
5229 **
5230 ** Destructor for sequence set objects
5231 **
5232 ** @param [d] Pseq [AjPSeqset*] Sequence set object reference
5233 ** @return [void]
5234 **
5235 ** @release 2.1.0
5236 ** @@
5237 ******************************************************************************/
5238 
ajSeqsetDel(AjPSeqset * Pseq)5239 void ajSeqsetDel(AjPSeqset *Pseq)
5240 {
5241     ajuint i;
5242     AjPSeqset seq = NULL;
5243 
5244     if(!Pseq || !*Pseq)
5245 	return;
5246 
5247     seq = *Pseq;
5248 
5249     ajDebug("ajSeqsetDel size: %d\n", seq->Size);
5250 
5251     ajStrDel(&seq->Type);
5252     ajStrDel(&seq->Formatstr);
5253     ajStrDel(&seq->Filename);
5254     ajStrDel(&seq->Full);
5255     ajStrDel(&seq->Name);
5256     ajStrDel(&seq->Usa);
5257     ajStrDel(&seq->Ufo);
5258 
5259     for(i=0; i<seq->Size; ++i)
5260 	ajSeqDel(&seq->Seq[i]);
5261 
5262     AJFREE(seq->Seq);
5263     AJFREE(seq->Seqweight);
5264 
5265     AJFREE(*Pseq);
5266 
5267     return;
5268 }
5269 
5270 
5271 
5272 
5273 /* @func ajSeqsetDelarray *****************************************************
5274 **
5275 ** Destructor for array of sequence set objects
5276 **
5277 ** @param [d] PPseq [AjPSeqset**] Sequence set object array
5278 ** @return [void]
5279 **
5280 ** @release 4.0.0
5281 ** @@
5282 ******************************************************************************/
5283 
ajSeqsetDelarray(AjPSeqset ** PPseq)5284 void ajSeqsetDelarray(AjPSeqset **PPseq)
5285 {
5286     ajuint i = 0;
5287 
5288     if(!PPseq || !*PPseq)
5289 	return;
5290 
5291     while((*PPseq)[i])
5292     {
5293 	ajSeqsetDel(&(*PPseq)[i]);
5294 	i++;
5295     }
5296 
5297     ajDebug("ajSeqsetDelarray size: %d\n", i);
5298 
5299     AJFREE(*PPseq);
5300 
5301     return;
5302 }
5303 
5304 
5305 
5306 
5307 /* @section casts *************************************************************
5308 **
5309 ** These functions examine the contents of a sequence set object
5310 ** and return some derived information. Some of them provide access to
5311 ** the internal components of a sequence stream object. They are
5312 ** provided for programming convenience but should be used with
5313 ** caution.
5314 **
5315 ** @fdata [AjPSeqset]
5316 ** @fcategory cast
5317 **
5318 ** @nam3rule Get         Return element value
5319 ** @nam4rule GetFilename Return filename
5320 ** @nam4rule GetFormat   Return input sequence format
5321 ** @nam4rule GetOffend   Return end offset
5322 ** @nam4rule GetOffset   Return start offset
5323 ** @nam4rule GetRange    Return start and end
5324 ** @nam4rule GetTotlength Return total sequence length
5325 ** @nam4rule GetUsa      Return input USA
5326 **
5327 ** @argrule * seq [const AjPSeqset] Sequence object
5328 ** @argrule GetRange begin [ajint*] Sequence start position
5329 ** @argrule GetRange end   [ajint*] Sequence end position
5330 **
5331 ** @valrule GetFilename [const AjPStr] Filename
5332 ** @valrule GetFormat [const AjPStr] Input sequence format
5333 ** @valrule GetOffend [ajint] End offset
5334 ** @valrule GetOffset [ajint] Start offset
5335 ** @valrule GetRange [ajint] Sequence length
5336 ** @valrule GetUsa [const AjPStr] Input sequence USA
5337 ** @valrule GetTotlength [ajint] Total ungapped sequence length
5338 **
5339 ******************************************************************************/
5340 
5341 
5342 
5343 
5344 /* @func ajSeqsetGetFilename **************************************************
5345 **
5346 ** Returns the filename of a sequence set.
5347 ** Because this is a pointer to the real internal string
5348 ** the caller must take care not to change the character string in any way.
5349 ** If the string is to be changed (case for example) then it must first
5350 ** be copied.
5351 **
5352 ** @param [r] seq [const AjPSeqset] Sequence set object.
5353 ** @return [const AjPStr] Name as a string.
5354 **
5355 ** @release 4.0.0
5356 ** @@
5357 ******************************************************************************/
5358 
ajSeqsetGetFilename(const AjPSeqset seq)5359 const AjPStr ajSeqsetGetFilename(const AjPSeqset seq)
5360 {
5361     ajDebug("ajSeqsetGetFilename '%S' usa: '%S'\n", seq->Name, seq->Usa);
5362 
5363     if(!seq)
5364 	return NULL;
5365 
5366     if(ajStrGetLen(seq->Filename))
5367 	return seq->Filename;
5368 
5369     return NULL;
5370 }
5371 
5372 
5373 
5374 
5375 /* @func ajSeqsetGetFormat ****************************************************
5376 **
5377 ** Returns the sequence format for a sequence set
5378 **
5379 ** @param [r] seq [const AjPSeqset] Sequence set object.
5380 ** @return [const AjPStr] Sequence format
5381 **
5382 ** @release 2.0.1
5383 ** @@
5384 ******************************************************************************/
5385 
ajSeqsetGetFormat(const AjPSeqset seq)5386 const AjPStr ajSeqsetGetFormat(const AjPSeqset seq)
5387 {
5388     return seq->Formatstr;
5389 }
5390 
5391 
5392 
5393 
5394 /* @func ajSeqsetGetOffend ****************************************************
5395 **
5396 ** Returns the sequence set offend value.
5397 ** This is the number of positions removed from the original end.
5398 **
5399 ** @param [r] seq [const AjPSeqset] Sequence set object
5400 ** @return [ajint] Sequence offend.
5401 **
5402 ** @release 4.1.0
5403 ** @@
5404 ******************************************************************************/
5405 
ajSeqsetGetOffend(const AjPSeqset seq)5406 ajint ajSeqsetGetOffend(const AjPSeqset seq)
5407 {
5408     return seq->Offend;
5409 }
5410 
5411 
5412 
5413 
5414 /* @func ajSeqsetGetOffset ****************************************************
5415 **
5416 ** Returns the sequence set offset value.
5417 ** This is the number of positions removed from the original end.
5418 **
5419 ** @param [r] seq [const AjPSeqset] Sequence set object
5420 ** @return [ajint] Sequence offset.
5421 **
5422 ** @release 4.1.0
5423 ** @@
5424 ******************************************************************************/
5425 
ajSeqsetGetOffset(const AjPSeqset seq)5426 ajint ajSeqsetGetOffset(const AjPSeqset seq)
5427 {
5428     return seq->Offset;
5429 }
5430 
5431 
5432 
5433 
5434 /* @func ajSeqsetGetRange *****************************************************
5435 **
5436 ** Returns the sequence range for a sequence set
5437 **
5438 ** @param [r] seq [const AjPSeqset] Sequence set object.
5439 ** @param [w] begin [ajint*] Sequence range begin
5440 ** @param [w] end [ajint*] Sequence range end
5441 ** @return [ajint] Sequence range length
5442 **
5443 ** @release 1.0.0
5444 ** @@
5445 ******************************************************************************/
5446 
ajSeqsetGetRange(const AjPSeqset seq,ajint * begin,ajint * end)5447 ajint ajSeqsetGetRange(const AjPSeqset seq, ajint* begin, ajint* end)
5448 {
5449     ajint jbegin;
5450     ajint jend;
5451 
5452     jbegin = seq->Begin;
5453 
5454     if(jbegin > 0)
5455 	jbegin--;
5456 
5457     jend = seq->End;
5458 
5459     if(jend > 0)
5460 	jend--;
5461 
5462     ajDebug("ajSeqsetGetRange '%S' begin %d end %d len: %d\n",
5463 	    seq->Name, seq->Begin, seq->End, seq->Len);
5464     *begin = ajCvtSposToPosStart(seq->Len, 0, jbegin);
5465 
5466     if(seq->End)
5467 	*end = 1 + ajCvtSposToPosStart(seq->Len, *begin, jend);
5468     else
5469 	*end = 1 + ajCvtSposToPosStart(seq->Len, *begin, seq->Len);
5470 
5471     (*begin)++;
5472 
5473     return (*end - *begin + 1);
5474 }
5475 
5476 
5477 
5478 
5479 /* @func ajSeqsetGetTotlength *************************************************
5480 **
5481 ** Returns the total number of bases or residues in a sequence set,
5482 ** ignoring any gap characters in aligned sequences.
5483 **
5484 ** @param [r] seq [const AjPSeqset] Sequence set object.
5485 ** @return [ajint] Total ungapped length
5486 **
5487 ** @release 6.1.0
5488 ** @@
5489 ******************************************************************************/
5490 
ajSeqsetGetTotlength(const AjPSeqset seq)5491 ajint ajSeqsetGetTotlength(const AjPSeqset seq)
5492 {
5493     ajuint n;
5494     ajuint i;
5495     ajint ret = 0;
5496 
5497     n = seq->Size;
5498 
5499     for(i=0; i < n; i++)
5500         ret += ajSeqGetLenUngapped(seq->Seq[i]);
5501 
5502     return ret;
5503 }
5504 
5505 
5506 
5507 
5508 /* @func ajSeqsetGetUsa *******************************************************
5509 **
5510 ** Returns the sequence name of a sequence set.
5511 ** Because this is a pointer to the real internal string
5512 ** the caller must take care not to change the character string in any way.
5513 ** If the string is to be changed (case for example) then it must first
5514 ** be copied.
5515 **
5516 ** @param [r] seq [const AjPSeqset] Sequence set object.
5517 ** @return [const AjPStr] Name as a string.
5518 **
5519 ** @release 2.1.0
5520 ** @@
5521 ******************************************************************************/
5522 
ajSeqsetGetUsa(const AjPSeqset seq)5523 const AjPStr ajSeqsetGetUsa(const AjPSeqset seq)
5524 {
5525     ajDebug("ajSeqetGetUsa '%S'\n", seq->Usa);
5526 
5527     return seq->Usa;
5528 }
5529 
5530 
5531 
5532 
5533 /* @section modifiers ********************************************
5534 **
5535 ** These functions use the contents of a sequence set object and
5536 ** update them.
5537 **
5538 **
5539 ** @fdata [AjPSeqset]
5540 ** @fcategory modify
5541 **
5542 ** @nam3rule Clear Reset object
5543 ** @nam3rule Fill Fills shorter sequences with gaps at end
5544 ** @nam3rule Fmt Reformats sequence
5545 ** @nam4rule FmtLower reformats sequence to lower case
5546 ** @nam4rule FmtUpper reformats sequence to upper case
5547 ** @nam3rule Sort Reorders sequences
5548 ** @nam4rule SortLen Reorders sequences by length
5549 **
5550 ** @nam3rule Reverse Reverse complements all sequences
5551 ** @nam3rule Trim    Trim sequences to defined range
5552 **
5553 ** @argrule * seq [AjPSeqset] Sequence set
5554 **
5555 ** @valrule * [void]
5556 ** @valrule *Fill [ajint] Maximum number of gaps inserted
5557 **
5558 ******************************************************************************/
5559 
5560 
5561 
5562 
5563 /* @func ajSeqsetClear ********************************************************
5564 **
5565 ** Reset a sequence set object
5566 **
5567 ** @param [u] seq [AjPSeqset] Sequence set object reference
5568 ** @return [void]
5569 **
5570 ** @release 6.5.0
5571 ** @@
5572 ******************************************************************************/
5573 
ajSeqsetClear(AjPSeqset seq)5574 void ajSeqsetClear(AjPSeqset seq)
5575 {
5576     ajuint i;
5577 
5578     if(!seq)
5579 	return;
5580 
5581     ajDebug("ajSeqsetDel size: %d\n", seq->Size);
5582 
5583     if(MAJSTRGETLEN(seq->Type))
5584        ajStrSetClear(&seq->Type);
5585     if(MAJSTRGETLEN(seq->Formatstr))
5586        ajStrSetClear(&seq->Formatstr);
5587     if(MAJSTRGETLEN(seq->Filename))
5588        ajStrSetClear(&seq->Filename);
5589     if(MAJSTRGETLEN(seq->Full))
5590        ajStrSetClear(&seq->Full);
5591     if(MAJSTRGETLEN(seq->Name))
5592        ajStrSetClear(&seq->Name);
5593     if(MAJSTRGETLEN(seq->Usa))
5594        ajStrSetClear(&seq->Usa);
5595     if(MAJSTRGETLEN(seq->Ufo))
5596        ajStrSetClear(&seq->Ufo);
5597 
5598     for(i=0; i<seq->Size; ++i)
5599 	ajSeqDel(&seq->Seq[i]);
5600 
5601     AJFREE(seq->Seq);
5602     AJFREE(seq->Seqweight);
5603 
5604     seq->Size = 0;
5605     seq->Begin = 0;
5606     seq->End = 0;
5607     seq->Len = 0;
5608     seq->Offset = 0;
5609     seq->Offend = 0;
5610 
5611     seq->Rev = ajTrue;
5612     seq->Trimmed = ajTrue;
5613 
5614     return;
5615 }
5616 
5617 
5618 
5619 
5620 /* @func ajSeqsetFill *********************************************************
5621 **
5622 ** Fills a sequence set with gaps at the ends of any shorter sequences.
5623 **
5624 ** @param [u] seq [AjPSeqset] Sequence set object to be set.
5625 ** @return [ajint] Number of gaps inserted
5626 **
5627 ** @release 1.0.0
5628 ** @@
5629 ******************************************************************************/
5630 
ajSeqsetFill(AjPSeqset seq)5631 ajint ajSeqsetFill(AjPSeqset seq)
5632 {
5633     ajuint i;
5634     ajuint ifix = 0;
5635     ajuint nfix = 0;
5636     ajuint ilen;
5637 
5638     ajDebug("ajSeqsetFill(len: %d)\n", seq->Len);
5639 
5640     for(i=0; i< seq->Size; i++)
5641 	if(ajSeqGetLen(seq->Seq[i]) < seq->Len)
5642 	{
5643 	    nfix++;
5644 	    ilen = seq->Len - ajSeqGetLen(seq->Seq[i]);
5645 
5646 	    if(ilen > ifix)
5647 		ifix = ilen;
5648 
5649 	    ajStrAppendCountK(&seq->Seq[i]->Seq, '-', ilen);
5650 	}
5651 
5652     ajDebug("      result: (len: %d added: %u number of seqs fixed: %u\n",
5653 	    seq->Len, ifix, nfix);
5654 
5655     return ifix;
5656 }
5657 
5658 
5659 
5660 
5661 /* @func ajSeqsetFmtLower *****************************************************
5662 **
5663 ** Converts all sequences in a set to lower case.
5664 **
5665 ** @param [u] seq [AjPSeqset] Sequence set object
5666 ** @return [void]
5667 **
5668 ** @release 4.1.0
5669 ** @@
5670 ******************************************************************************/
5671 
ajSeqsetFmtLower(AjPSeqset seq)5672 void ajSeqsetFmtLower(AjPSeqset seq)
5673 {
5674     ajuint i;
5675 
5676     for(i=0; i < seq->Size; i++)
5677 	ajSeqFmtLower(seq->Seq[i]);
5678 
5679     return;
5680 }
5681 
5682 
5683 
5684 
5685 /* @func ajSeqsetFmtUpper *****************************************************
5686 **
5687 ** Converts all sequences in a set to upper case.
5688 **
5689 ** @param [u] seq [AjPSeqset] Sequence set object
5690 ** @return [void]
5691 **
5692 ** @release 4.1.0
5693 ** @@
5694 ******************************************************************************/
5695 
ajSeqsetFmtUpper(AjPSeqset seq)5696 void ajSeqsetFmtUpper(AjPSeqset seq)
5697 {
5698     ajuint i;
5699 
5700     for(i=0; i < seq->Size; i++)
5701 	ajSeqFmtUpper(seq->Seq[i]);
5702 
5703     return;
5704 }
5705 
5706 
5707 
5708 
5709 /* @func ajSeqsetReverse ******************************************************
5710 **
5711 ** Reverse complements all sequences in a sequence set.
5712 **
5713 ** @param [u] seq [AjPSeqset] Sequence set object
5714 ** @return [void]
5715 **
5716 ** @release 1.0.0
5717 ** @@
5718 ******************************************************************************/
5719 
ajSeqsetReverse(AjPSeqset seq)5720 void ajSeqsetReverse(AjPSeqset seq)
5721 {
5722     ajuint i;
5723     ajint ibegin;
5724     ajint iend;
5725 
5726     ajDebug("ajSeqsetReverse len: %d Begin: %d End: %d\n",
5727 	    ajSeqsetGetLen(seq), seq->Begin, seq->End);
5728 
5729     ibegin = seq->Begin;
5730     iend   = seq->End;
5731 
5732     if(ibegin)
5733 	seq->End = -(ibegin);
5734 
5735     if(iend)
5736 	seq->Begin = -(iend);
5737 
5738     for(i=0; i < seq->Size; i++)
5739     {
5740         seq->Seq[i]->Rev = ajTrue;
5741 	ajSeqReverseDo(seq->Seq[i]);
5742     }
5743 
5744     ajDebug("  set result len: %d Begin: %d End: %d\n",
5745 	    ajSeqsetGetLen(seq), seq->Begin, seq->End);
5746 
5747     return;
5748 }
5749 
5750 
5751 
5752 
5753 /* @func ajSeqsetSortLen ******************************************************
5754 **
5755 ** Sorts a sequence set by sequence length
5756 **
5757 ** @param [u] seq [AjPSeqset] Sequence set object
5758 ** @return [void]
5759 **
5760 ** @release 6.1.0
5761 ** @@
5762 ******************************************************************************/
5763 
ajSeqsetSortLen(AjPSeqset seq)5764 void ajSeqsetSortLen(AjPSeqset seq)
5765 {
5766     ajuint i;
5767     ajuint j;
5768     ajuint k;
5769     ajuint * lengths;
5770     ajuint * seqnum;
5771     AjPSeq tmp;
5772 
5773     AJCNEW0(lengths,seq->Size);
5774     AJCNEW0(seqnum,seq->Size);
5775 
5776     for(i=0;i<seq->Size;i++)
5777     {
5778         lengths[i] = ajSeqGetLenUngapped(seq->Seq[i]);
5779         seqnum[i] = i;
5780     }
5781 
5782     ajSortUintIncI(lengths,seqnum,seq->Size);
5783 
5784     j = 0;
5785 
5786     for(i=0;i<seq->Size;i++)
5787     {
5788         tmp = seq->Seq[i];
5789 
5790         for(k=i; seqnum[k] != i; k=seqnum[j], seqnum[j]=j)
5791         {
5792             j = k;
5793             seq->Seq[k] = seq->Seq[seqnum[k]];
5794         }
5795 
5796         seq->Seq[k] = tmp;
5797         seqnum[k] = k;
5798     }
5799 
5800     AJFREE(lengths);
5801     AJFREE(seqnum);
5802 
5803     return;
5804 }
5805 
5806 
5807 
5808 
5809 /* @func ajSeqsetTrim *********************************************************
5810 **
5811 ** Trims a sequence set to start and end positions
5812 **
5813 ** @param [u] seq [AjPSeqset] Sequence set object
5814 ** @return [void]
5815 **
5816 ** @release 2.9.0
5817 ** @@
5818 ******************************************************************************/
5819 
ajSeqsetTrim(AjPSeqset seq)5820 void ajSeqsetTrim(AjPSeqset seq)
5821 {
5822     ajuint i;
5823 
5824     ajint begin;
5825     ajint end;
5826     ajint jbegin;
5827     ajint jend;
5828 
5829     if(seq->Trimmed)
5830     {
5831 	ajWarn("Sequence set '%S' already trimmed", ajSeqsetGetNameS(seq));
5832 
5833 	return;
5834     }
5835 
5836     ajDebug("ajSeqsetTrim len: %d begin: %d end: %d\n",
5837 	    seq->Len, seq->Begin, seq->End);
5838 
5839     for(i=0; i < seq->Size; i++)
5840 	ajSeqTrim(seq->Seq[i]);
5841 
5842     jbegin = seq->Begin;
5843 
5844     if(jbegin > 0)
5845 	jbegin--;
5846 
5847     jend = seq->End;
5848 
5849     if(jend > 0)
5850 	jend--;
5851 
5852     begin = 1 + ajCvtSposToPosStart(seq->Len, 0, jbegin);
5853     end   = 1 + ajCvtSposToPosStart(seq->Len, begin-1, jend);
5854 
5855     if(seq->End)
5856     {
5857 	if(end < begin)
5858 	    return;
5859 
5860 	seq->Offend = seq->Len - end;
5861 	seq->End    = 0;
5862 	seq->Len = end;
5863     }
5864 
5865     if(seq->Begin)
5866     {
5867 	seq->Offset = begin-1;
5868 	seq->Begin = 0;
5869 	seq->Len -= begin;
5870     }
5871 
5872     ajDebug("ajSeqsetTrim result len: %d begin: %d end: %d\n",
5873 	    seq->Len, seq->Begin, seq->End);
5874 
5875     return;
5876 }
5877 
5878 
5879 
5880 
5881 /* @section element assignment ************************************************
5882 **
5883 ** Functions for assigning elements of a sequence set object.
5884 **
5885 ** @fdata       [AjPSeqset]
5886 ** @fcategory modify
5887 **
5888 ** @nam3rule Set Assigns value to an element
5889 ** @nam4rule SetRange Assigns begin and end values for whole set
5890 **
5891 ** @argrule * seq [AjPSeqset] Sequence set
5892 ** @argrule Range pos1 [ajint] Start position
5893 ** @argrule Range pos2 [ajint] End position
5894 **
5895 ** @valrule * [void]
5896 ******************************************************************************/
5897 
5898 
5899 
5900 
5901 /* @func ajSeqsetSetRange *****************************************************
5902 **
5903 ** Sets the start and end positions for a sequence set.
5904 **
5905 ** @param [u] seq [AjPSeqset] Sequence set object to be set.
5906 ** @param [r] pos1 [ajint] Start position. Negative values are from the end.
5907 ** @param [r] pos2 [ajint] End position. Negative values are from the end.
5908 ** @return [void]
5909 **
5910 ** @release 1.0.0
5911 ** @@
5912 ******************************************************************************/
5913 
ajSeqsetSetRange(AjPSeqset seq,ajint pos1,ajint pos2)5914 void ajSeqsetSetRange(AjPSeqset seq, ajint pos1, ajint pos2)
5915 {
5916     ajuint i;
5917 
5918     ajDebug("ajSeqsetSetRange(len: %d %d, %d)\n", seq->Len, pos1, pos2);
5919 
5920     if(pos1)
5921 	seq->Begin = pos1;
5922 
5923     if(pos2)
5924 	seq->End = pos2;
5925 
5926     for(i=0; i< seq->Size; i++)
5927     {
5928 	if(pos1)
5929 	    seq->Seq[i]->Begin = pos1;
5930 	if(pos2)
5931 	    seq->Seq[i]->End   = pos2;
5932     }
5933 
5934     ajDebug("      result: (len: %u %d, %d)\n",
5935 	    seq->Len, seq->Begin, seq->End);
5936 
5937     return;
5938 }
5939 
5940 
5941 
5942 
5943 /* @section casts ************************************************
5944 **
5945 ** These functions examine the contents of a sequence set object and
5946 ** return some derived information. Some of them provide access to the
5947 ** internal components of a sequence set object. They are provided for
5948 ** programming convenience but should be used with caution.
5949 **
5950 ** @fdata [AjPSeqset]
5951 ** @fcategory cast
5952 **
5953 ** @nam3rule Get          Return sequence set attribute(s)
5954 ** @nam4rule GetBegin     Return sequence set end
5955 ** @nam4rule GetEnd       Return sequence set end
5956 ** @nam4rule GetLen       Return sequence set length
5957 ** @nam4rule GetName      Return sequence set name
5958 ** @nam4rule GetSeqarray  Return array of sequence objects
5959 ** @nam4rule GetSize      Return sequence set size (number of sequences)
5960 ** @nam4rule GetTotweight  Return total weighting for sequence set
5961 ** @nam3rule Getseq       Return attribute(s) from one sequence
5962 ** @nam4rule GetseqAcc    Return sequence accession number
5963 ** @nam4rule GetseqName   Return sequence name
5964 ** @nam4rule GetseqSeq    Return sequence object
5965 ** @nam4rule GetseqWeight Return sequence weight
5966 **
5967 ** @suffix S Return a string
5968 ** @suffix C Return a character string
5969 **
5970 ** @argrule * seq [const AjPSeqset] Sequence set object
5971 ** @argrule Getseq i [ajuint] Number of sequence in set
5972 **
5973 ** @valrule Begin    [ajuint]        Sequence set start
5974 ** @valrule End      [ajuint]        Sequence set end
5975 ** @valrule Len      [ajuint]        Sequence set length
5976 ** @valrule Seq      [const AjPSeq] Sequence object
5977 ** @valrule Seqarray [AjPSeq*]      Array of sequences, NULL terminated
5978 ** @valrule Size     [ajuint]        Number of sequences
5979 ** @valrule Totweight [float]       Sequence weight total
5980 ** @valrule Weight   [float]        Sequence weight total
5981 ** @valrule *C [const char*] Character string
5982 ** @valrule *S [const AjPStr] String object
5983 **
5984 ******************************************************************************/
5985 
5986 
5987 
5988 
5989 /* @func ajSeqsetGetBegin *****************************************************
5990 **
5991 ** Returns the sequence set start position, or 1 if no start has been set.
5992 **
5993 ** @param [r] seq [const AjPSeqset] Sequence set object
5994 ** @return [ajuint] Start position.
5995 **
5996 ** @release 4.1.0
5997 ** @@
5998 ******************************************************************************/
5999 
ajSeqsetGetBegin(const AjPSeqset seq)6000 ajuint ajSeqsetGetBegin(const AjPSeqset seq)
6001 {
6002     ajint jbegin;
6003 
6004     if(!seq->Begin)
6005 	return 1;
6006 
6007     jbegin = seq->Begin;
6008 
6009     if(jbegin > 0)
6010 	jbegin--;
6011 
6012     return 1 + ajCvtSposToPosStart(seq->Len, 0, jbegin);
6013 }
6014 
6015 
6016 
6017 
6018 /* @func ajSeqsetGetEnd *******************************************************
6019 **
6020 ** Returns the sequence set end position, or the sequence length if no end
6021 ** has been set.
6022 **
6023 ** @param [r] seq [const AjPSeqset] Sequence set object
6024 ** @return [ajuint] Start position.
6025 **
6026 ** @release 4.1.0
6027 ** @@
6028 ******************************************************************************/
6029 
ajSeqsetGetEnd(const AjPSeqset seq)6030 ajuint ajSeqsetGetEnd(const AjPSeqset seq)
6031 {
6032     ajint jend;
6033 
6034     if(!seq->End)
6035 	return (seq->Len);
6036 
6037     jend = seq->End;
6038 
6039     if(jend > 0)
6040 	jend--;
6041 
6042     return 1 + ajCvtSposToPosStart(seq->Len, ajSeqsetGetBegin(seq)-1, jend);
6043 }
6044 
6045 
6046 
6047 
6048 /* @func ajSeqsetGetLen *******************************************************
6049 **
6050 ** Returns the length of a sequence set, which is the maximum sequence
6051 ** length in the set.
6052 **
6053 ** @param [r] seq [const AjPSeqset] Sequence set object
6054 ** @return [ajuint] sequence set length.
6055 **
6056 ** @release 4.1.0
6057 ** @@
6058 ******************************************************************************/
6059 
ajSeqsetGetLen(const AjPSeqset seq)6060 ajuint ajSeqsetGetLen(const AjPSeqset seq)
6061 {
6062     return seq->Len;
6063 }
6064 
6065 
6066 
6067 
6068 /* @func ajSeqsetGetNameC *****************************************************
6069 **
6070 ** Returns the sequence name of a sequence set.
6071 ** Because this is a pointer to the real internal string
6072 ** the caller must take care not to change the character string in any way.
6073 ** If the string is to be changed (case for example) then it must first
6074 ** be copied.
6075 **
6076 ** @param [r] seq [const AjPSeqset] Sequence set object.
6077 ** @return [const char*] Name as a C character string.
6078 **
6079 ** @release 4.1.0
6080 ** @@
6081 ******************************************************************************/
6082 
ajSeqsetGetNameC(const AjPSeqset seq)6083 const char* ajSeqsetGetNameC(const AjPSeqset seq)
6084 {
6085     ajDebug("ajSeqsetGetName '%S' usa: '%S'\n", seq->Name, seq->Usa);
6086 
6087     if(ajStrGetLen(seq->Name))
6088       return MAJSTRGETPTR(seq->Name);
6089 
6090     return MAJSTRGETPTR(seq->Usa);
6091 }
6092 
6093 
6094 
6095 
6096 /* @func ajSeqsetGetNameS *****************************************************
6097 **
6098 ** Returns the sequence name of a sequence set.
6099 ** Because this is a pointer to the real internal string
6100 ** the caller must take care not to change the character string in any way.
6101 ** If the string is to be changed (case for example) then it must first
6102 ** be copied.
6103 **
6104 ** @param [r] seq [const AjPSeqset] Sequence set object.
6105 ** @return [const AjPStr] Name as a string.
6106 **
6107 ** @release 4.1.0
6108 ** @@
6109 ******************************************************************************/
6110 
ajSeqsetGetNameS(const AjPSeqset seq)6111 const AjPStr ajSeqsetGetNameS(const AjPSeqset seq)
6112 {
6113     if(!seq)
6114         return ajStrConstEmpty();
6115 
6116     ajDebug("ajSeqsetGetNameS '%S' usa: '%S'\n", seq->Name, seq->Usa);
6117 
6118     if(ajStrGetLen(seq->Name))
6119       return seq->Name;
6120 
6121     return seq->Usa;
6122 }
6123 
6124 
6125 
6126 
6127 /* @func ajSeqsetGetSeqarray **************************************************
6128 **
6129 ** Returns an array of sequences.
6130 ** Because this is a pointer to the real internal sequence
6131 ** the caller must take care not to change the data in any way.
6132 ** If the sequence is to be changed (case for example) then it must first
6133 ** be copied.
6134 **
6135 ** The array is 1 larger than the sequence set,
6136 ** with the last element set to NULL.
6137 ** @param [r] seq [const AjPSeqset] Sequence set object.
6138 ** @return [AjPSeq*] Sequence object.
6139 **
6140 ** @release 4.1.0
6141 ** @@
6142 ******************************************************************************/
6143 
ajSeqsetGetSeqarray(const AjPSeqset seq)6144 AjPSeq* ajSeqsetGetSeqarray(const AjPSeqset seq)
6145 {
6146     AjPSeq* ret;
6147     ajuint i;
6148 
6149     ajDebug("ajSeqsetGetSeqArray '%S' %d\n", seq->Name, seq->Size);
6150     AJCNEW0(ret, (seq->Size+1));
6151 
6152     for (i=0; i<seq->Size;i++)
6153     {
6154 	ret[i] = ajSeqNewSeq(seq->Seq[i]);
6155     }
6156 
6157     return ret;
6158 }
6159 
6160 
6161 
6162 
6163 /* @func ajSeqsetGetSize ******************************************************
6164 **
6165 ** Returns the number of sequences in a sequence set
6166 **
6167 ** @param [r] seq [const AjPSeqset] Sequence set object
6168 ** @return [ajuint] sequence set size.
6169 **
6170 ** @release 4.1.0
6171 ** @@
6172 ******************************************************************************/
6173 
ajSeqsetGetSize(const AjPSeqset seq)6174 ajuint ajSeqsetGetSize(const AjPSeqset seq)
6175 {
6176     return seq->Size;
6177 }
6178 
6179 
6180 
6181 
6182 /* @func ajSeqsetGetTotweight *************************************************
6183 **
6184 ** Returns the weight of all sequences in a sequence set
6185 **
6186 ** @param [r] seq [const AjPSeqset] Sequence set object
6187 ** @return [float] sequence weight as a float.
6188 **
6189 ** @release 4.1.0
6190 ** @@
6191 ******************************************************************************/
6192 
ajSeqsetGetTotweight(const AjPSeqset seq)6193 float ajSeqsetGetTotweight(const AjPSeqset seq)
6194 {
6195     ajuint i;
6196     float ret = 0.0;
6197 
6198     for(i=0; i < seq->Size; i++)
6199 	ret += seq->Seq[i]->Weight;
6200 
6201     return ret;
6202 }
6203 
6204 
6205 
6206 
6207 /* @func ajSeqsetGetseqAccC ***************************************************
6208 **
6209 ** Returns the accession number of a sequence in a sequence set
6210 **
6211 ** @param [r] seq [const AjPSeqset] Sequence set object
6212 ** @param [r] i [ajuint] Sequence index
6213 ** @return [const char*] accession number as a string.
6214 **
6215 ** @release 4.1.0
6216 ** @@
6217 ******************************************************************************/
6218 
ajSeqsetGetseqAccC(const AjPSeqset seq,ajuint i)6219 const char* ajSeqsetGetseqAccC(const AjPSeqset seq, ajuint i)
6220 {
6221     if(i >= seq->Size)
6222 	return NULL;
6223 
6224     return MAJSTRGETPTR(seq->Seq[i]->Acc);
6225 }
6226 
6227 
6228 
6229 
6230 /* @func ajSeqsetGetseqAccS ***************************************************
6231 **
6232 ** Returns the accession number of a sequence in a sequence set
6233 **
6234 ** @param [r] seq [const AjPSeqset] Sequence set object
6235 ** @param [r] i [ajuint] Sequence index
6236 ** @return [const AjPStr] accession number as a string.
6237 **
6238 ** @release 4.1.0
6239 ** @@
6240 ******************************************************************************/
6241 
ajSeqsetGetseqAccS(const AjPSeqset seq,ajuint i)6242 const AjPStr ajSeqsetGetseqAccS(const AjPSeqset seq, ajuint i)
6243 {
6244     if(i >= seq->Size)
6245 	return NULL;
6246 
6247     if(seq->Seq[i]->Acc)
6248         return seq->Seq[i]->Acc;
6249     return ajStrConstEmpty();
6250 }
6251 
6252 
6253 
6254 
6255 /* @func ajSeqsetGetseqNameC **************************************************
6256 **
6257 ** Returns the name of a sequence in a sequence set
6258 **
6259 ** @param [r] seq [const AjPSeqset] Sequence set object
6260 ** @param [r] i [ajuint] Sequence index
6261 ** @return [const char*] sequence name as a string.
6262 **
6263 ** @release 4.1.0
6264 ** @@
6265 ******************************************************************************/
6266 
ajSeqsetGetseqNameC(const AjPSeqset seq,ajuint i)6267 const char* ajSeqsetGetseqNameC(const AjPSeqset seq, ajuint i)
6268 {
6269     if(!seq)
6270         return "";
6271 
6272     if(i >= seq->Size)
6273 	return "";
6274 
6275     if(seq->Seq[i]->Name)
6276         return MAJSTRGETPTR(seq->Seq[i]->Name);
6277 
6278     return "";
6279 }
6280 
6281 
6282 
6283 
6284 /* @func ajSeqsetGetseqNameS **************************************************
6285 **
6286 ** Returns the name of a sequence in a sequence set
6287 **
6288 ** @param [r] seq [const AjPSeqset] Sequence set object
6289 ** @param [r] i [ajuint] Sequence index
6290 ** @return [const AjPStr] sequence name as a string.
6291 **
6292 ** @release 4.1.0
6293 ** @@
6294 ******************************************************************************/
6295 
ajSeqsetGetseqNameS(const AjPSeqset seq,ajuint i)6296 const AjPStr ajSeqsetGetseqNameS(const AjPSeqset seq, ajuint i)
6297 {
6298     if(!seq)
6299         return ajStrConstEmpty();
6300 
6301     if(i >= seq->Size)
6302 	return ajStrConstEmpty();
6303 
6304     if(seq->Seq[i]->Name)
6305         return seq->Seq[i]->Name;
6306 
6307     return ajStrConstEmpty();
6308 }
6309 
6310 
6311 
6312 
6313 /* @func ajSeqsetGetseqSeq ****************************************************
6314 **
6315 ** Returns one sequence from a sequence set.
6316 ** Because this is a pointer to the real internal sequence
6317 ** the caller must take care not to change the data in any way.
6318 ** If the sequence is to be changed (case for example) then it must first
6319 ** be copied.
6320 **
6321 ** @param [r] seq [const AjPSeqset] Sequence set object.
6322 ** @param [r] i [ajuint] Sequence index number in set
6323 ** @return [const AjPSeq] Sequence object.
6324 **
6325 ** @release 4.1.0
6326 ** @@
6327 ******************************************************************************/
6328 
ajSeqsetGetseqSeq(const AjPSeqset seq,ajuint i)6329 const AjPSeq ajSeqsetGetseqSeq(const AjPSeqset seq, ajuint i)
6330 {
6331     if(i >= seq->Size)
6332 	return NULL;
6333 
6334     return seq->Seq[i];
6335 }
6336 
6337 
6338 
6339 
6340 /* @func ajSeqsetGetseqSeqC ***************************************************
6341 **
6342 ** Returns one sequence from a sequence set.
6343 ** Because this is a pointer to the real internal sequence
6344 ** the caller must take care not to change the data in any way.
6345 ** If the sequence is to be changed (case for example) then it must first
6346 ** be copied.
6347 **
6348 ** @param [r] seq [const AjPSeqset] Sequence set object.
6349 ** @param [r] i [ajuint] Sequence index number in set
6350 ** @return [const char*] Sequence as a C string.
6351 **
6352 ** @release 4.1.0
6353 ** @@
6354 ******************************************************************************/
6355 
ajSeqsetGetseqSeqC(const AjPSeqset seq,ajuint i)6356 const char* ajSeqsetGetseqSeqC(const AjPSeqset seq, ajuint i)
6357 {
6358     if(i >= seq->Size)
6359 	return NULL;
6360 
6361     return MAJSTRGETPTR(seq->Seq[i]->Seq);
6362 }
6363 
6364 
6365 
6366 
6367 /* @func ajSeqsetGetseqSeqS ***************************************************
6368 **
6369 ** Returns one sequence from a sequence set.
6370 ** Because this is a pointer to the real internal sequence
6371 ** the caller must take care not to change the data in any way.
6372 ** If the sequence is to be changed (case for example) then it must first
6373 ** be copied.
6374 **
6375 ** @param [r] seq [const AjPSeqset] Sequence set object.
6376 ** @param [r] i [ajuint] Sequence index number in set
6377 ** @return [const AjPStr] Sequence object.
6378 **
6379 ** @release 4.1.0
6380 ** @@
6381 ******************************************************************************/
6382 
ajSeqsetGetseqSeqS(const AjPSeqset seq,ajuint i)6383 const AjPStr ajSeqsetGetseqSeqS(const AjPSeqset seq, ajuint i)
6384 {
6385     ajDebug("ajSeqsetGetseqSeq '%S' %d/%d\n", seq->Name, i, seq->Size);
6386 
6387     if(i >= seq->Size)
6388 	return NULL;
6389 
6390     if(seq->Seq[i]->Seq)
6391         return seq->Seq[i]->Seq;
6392     return ajStrConstEmpty();
6393 }
6394 
6395 
6396 
6397 
6398 /* @func ajSeqsetGetseqWeight *************************************************
6399 **
6400 ** Returns the weight of a sequence in a sequence set
6401 **
6402 ** @param [r] seq [const AjPSeqset] Sequence set object
6403 ** @param [r] i [ajuint] Sequence index
6404 ** @return [float] sequence weight as a float.
6405 **
6406 ** @release 4.1.0
6407 ** @@
6408 ******************************************************************************/
6409 
ajSeqsetGetseqWeight(const AjPSeqset seq,ajuint i)6410 float ajSeqsetGetseqWeight(const AjPSeqset seq, ajuint i)
6411 {
6412     if(i >= seq->Size)
6413 	return 0.0;
6414 
6415     return seq->Seq[i]->Weight;
6416 }
6417 
6418 
6419 
6420 
6421 /* @section testing properties ************************************************
6422 **
6423 ** Tests properties of a sequence set
6424 **
6425 ** @fdata [AjPSeqset]
6426 ** @fcategory cast
6427 **
6428 ** @nam3rule Is Test sequence property
6429 ** @nam4rule IsDna Sequence is DNA
6430 ** @nam4rule IsNuc Sequence is nucleotide
6431 ** @nam4rule IsProt Sequence is protein
6432 ** @nam4rule IsRna Sequence is RNA
6433 **
6434 ** @argrule * seq [const AjPSeqset] Sequence set object
6435 **
6436 ** @valrule Is [AjBool] True or false
6437 **
6438 ******************************************************************************/
6439 
6440 
6441 
6442 
6443 /* @func ajSeqsetIsDna ********************************************************
6444 **
6445 ** Tests whether a sequence set is DNA.
6446 **
6447 ** @param [r] seq [const AjPSeqset] Sequence set
6448 ** @return [AjBool] ajTrue for a nucleotide sequence set.
6449 **
6450 ** @release 2.3.0
6451 ** @@
6452 ******************************************************************************/
6453 
ajSeqsetIsDna(const AjPSeqset seq)6454 AjBool ajSeqsetIsDna(const AjPSeqset seq)
6455 {
6456     AjPSeq myseq;
6457 
6458     if(ajStrMatchC(seq->Type, "P"))
6459 	return ajFalse;
6460 
6461     myseq = seq->Seq[0];
6462 
6463     if(ajSeqTypeGapdnaS(myseq->Seq))
6464     	return ajFalse;
6465 
6466     return ajTrue;
6467 }
6468 
6469 
6470 
6471 
6472 /* @func ajSeqsetIsNuc ********************************************************
6473 **
6474 ** Tests whether a sequence set is nucleotide.
6475 **
6476 ** @param [r] seq [const AjPSeqset] Sequence set
6477 ** @return [AjBool] ajTrue for a nucleotide sequence set.
6478 **
6479 ** @release 1.0.0
6480 ** @@
6481 ******************************************************************************/
6482 
ajSeqsetIsNuc(const AjPSeqset seq)6483 AjBool ajSeqsetIsNuc(const AjPSeqset seq)
6484 {
6485     AjPSeq myseq;
6486 
6487     if(ajStrMatchC(seq->Type, "N"))
6488 	return ajTrue;
6489 
6490     myseq = seq->Seq[0];
6491 
6492     if(ajSeqTypeGapnucS(myseq->Seq))
6493     	return ajFalse;
6494 
6495     return ajTrue;
6496 }
6497 
6498 
6499 
6500 
6501 /* @func ajSeqsetIsProt *******************************************************
6502 **
6503 ** Tests whether a sequence set is protein.
6504 **
6505 ** @param [r] seq [const AjPSeqset] Sequence set
6506 ** @return [AjBool] ajTrue for a protein sequence set.
6507 **
6508 ** @release 1.0.0
6509 ** @@
6510 ******************************************************************************/
6511 
ajSeqsetIsProt(const AjPSeqset seq)6512 AjBool ajSeqsetIsProt(const AjPSeqset seq)
6513 {
6514     AjPSeq myseq;
6515 
6516     if(ajStrMatchC(seq->Type, "P"))
6517 	return ajTrue;
6518 
6519     if(ajSeqsetIsNuc(seq))
6520 	return ajFalse;
6521 
6522     myseq = seq->Seq[0];
6523 
6524     return ajSeqIsProt(myseq);
6525 }
6526 
6527 
6528 
6529 
6530 /* @func ajSeqsetIsRna ********************************************************
6531 **
6532 ** Tests whether a sequence set is RNA.
6533 **
6534 ** @param [r] seq [const AjPSeqset] Sequence set
6535 ** @return [AjBool] ajTrue for a nucleotide sequence set.
6536 **
6537 ** @release 2.0.1
6538 ** @@
6539 ******************************************************************************/
6540 
ajSeqsetIsRna(const AjPSeqset seq)6541 AjBool ajSeqsetIsRna(const AjPSeqset seq)
6542 {
6543     AjPSeq myseq;
6544 
6545     if(ajStrMatchC(seq->Type, "P"))
6546 	return ajFalse;
6547 
6548     myseq = seq->Seq[0];
6549 
6550     if(ajSeqTypeGaprnaS(myseq->Seq))
6551     	return ajFalse;
6552 
6553     return ajTrue;
6554 }
6555 
6556 
6557 
6558 
6559 /* @datasection [AjPStr] sequence strings *************************************
6560 **
6561 ** Sequences represented as string objects
6562 **
6563 ** @nam2rule Seqstr
6564 **
6565 ******************************************************************************/
6566 
6567 
6568 
6569 
6570 /* @section conversion *******************************************************
6571 **
6572 ** Convert sequence to numbers for efficient processing
6573 **
6574 ** @fdata [AjPStr]
6575 ** @fcategory derive
6576 **
6577 ** @nam3rule Convert Convert sequence to some other datatype
6578 ** @nam4rule ConvertNum Convert to integers
6579 **
6580 ** @argrule * seq [const AjPStr]
6581 ** @argrule Num cvt [const AjPSeqCvt] Conversion table
6582 ** @argrule Num Pnumseq [AjPStr*] Output numeric version of the sequence
6583 **
6584 ** @valrule * [AjBool] True on success
6585 ******************************************************************************/
6586 
6587 
6588 
6589 
6590 /* @func ajSeqstrConvertNum ***************************************************
6591 **
6592 ** Converts a string of sequence characters to numbers using
6593 ** a conversion table.
6594 **
6595 ** @param [r] seq [const AjPStr] Sequence as a string
6596 ** @param [r] cvt [const AjPSeqCvt] Conversion table.
6597 ** @param [w] Pnumseq [AjPStr*] Output numeric version of the sequence.
6598 ** @return [AjBool] ajTrue on success.
6599 **
6600 ** @release 4.1.0
6601 ** @@
6602 ******************************************************************************/
6603 
ajSeqstrConvertNum(const AjPStr seq,const AjPSeqCvt cvt,AjPStr * Pnumseq)6604 AjBool ajSeqstrConvertNum(const AjPStr seq, const AjPSeqCvt cvt,
6605 			  AjPStr* Pnumseq)
6606 {
6607     const char *cp;
6608     char *ncp;
6609 
6610     cp = ajStrGetPtr(seq);
6611 
6612     ajStrAssignS(Pnumseq, seq);
6613     ncp = ajStrGetuniquePtr(Pnumseq);
6614 
6615     while(*cp)
6616     {
6617 	*ncp = cvt->table[(ajint)*cp];
6618 	cp++;
6619 	ncp++;
6620     }
6621 
6622     return ajTrue;
6623 }
6624 
6625 
6626 
6627 
6628 /* @datasection [AjPSeqCvt] sequence conversion *******************************
6629 **
6630 ** Sequences represented as string objects
6631 **
6632 ** @nam2rule Seqcvt
6633 **
6634 ******************************************************************************/
6635 
6636 
6637 
6638 
6639 /* @section Sequence Conversion Functions *************************************
6640 **
6641 ** @fdata [AjPSeqCvt]
6642 ** @fcategory misc
6643 **
6644 ** @nam3rule Trace Report contents to debug output
6645 **
6646 ** @argrule * cvt [const AjPSeqCvt]
6647 **
6648 ** @valrule * [void]
6649 **
6650 ******************************************************************************/
6651 
6652 
6653 
6654 
6655 /* @func ajSeqcvtTrace ********************************************************
6656 **
6657 ** Traces a conversion table with debug calls.
6658 **
6659 ** @param [r] cvt [const AjPSeqCvt] Conversion table.
6660 ** @return [void]
6661 **
6662 ** @release 4.1.0
6663 ** @@
6664 ******************************************************************************/
6665 
ajSeqcvtTrace(const AjPSeqCvt cvt)6666 void ajSeqcvtTrace(const AjPSeqCvt cvt)
6667 {
6668     ajint i;
6669 
6670     ajDebug("Cvt table for '%S'\n\n", cvt->bases);
6671     ajDebug("index num ch\n");
6672     ajDebug("----- --- --\n");
6673     for(i=0; i < cvt->size; i++)
6674 	if(cvt->table[i])
6675 	    ajDebug("%5d %3d <%c>\n", i, cvt->table[i], ajSysCastItoc(i));
6676 
6677     ajDebug("... all others are zero ...\n", cvt->bases);
6678 
6679     return;
6680 }
6681 
6682 
6683 
6684 
6685 /* @section constructors *********************************************
6686 **
6687 ** @fdata [AjPSeqCvt]
6688 ** @fcategory new
6689 **
6690 ** @nam3rule New Constructor by default starting numbers from one,
6691 **           with zero used for characters not in the set of bases
6692 ** @nam4rule NewEnd Constructor starting numbers from zero,
6693 **           with the next number
6694 **           used for characters not in the set of bases
6695 ** @nam4rule NewNumber Conversion table uses base letters and numbers
6696 ** @nam4rule NewStr Conversion table uses labels longer than one
6697 **           character passed as an array of strings
6698 ** @nam5rule NewStrAsym Comparison matrix uses labels longer than one
6699 **           character passed as an array of strings. Table is
6700 **           asymmetric ... rows and columns have different labels.
6701 **
6702 ** @suffix C [char*] C character string
6703 ** @suffix S [AjPStr] string object
6704 **
6705 ** @argrule C bases [const char*] Allowed sequence characters
6706 ** @argrule S basestr [const AjPStr] Allowed sequence characters
6707 ** @argrule Str basearray [const AjPPStr] Allowed sequence characters
6708 **                                          string array
6709 ** @argrule Str numbases [ajint] Size of sequence characters
6710 **                                        string array
6711 ** @argrule Asym matchbases [const AjPPStr] Allowed matching
6712 **                                          sequence characters
6713 ** @argrule Asym nummatch [ajint] Size of matching sequence characters
6714 **                                         string array
6715 ** @valrule * [AjPSeqCvt]
6716 **
6717 ******************************************************************************/
6718 
6719 
6720 
6721 
6722 
6723 /* @func ajSeqcvtNewC *********************************************************
6724 **
6725 ** Generates a new conversion table in which the first character in the
6726 ** string provided is converted to 1, the second to 2, and so on.
6727 ** Upper and lower case characters are converted to the same numbers.
6728 ** All other characters are set to zero.
6729 **
6730 ** @param [r] bases [const char*] Allowed sequence characters.
6731 ** @return [AjPSeqCvt] Conversion table.
6732 **
6733 ** @release 4.1.0
6734 ** @@
6735 ******************************************************************************/
6736 
ajSeqcvtNewC(const char * bases)6737 AjPSeqCvt ajSeqcvtNewC(const char* bases)
6738 {
6739     static AjPSeqCvt ret;
6740     ajint i;
6741     const char *cp;
6742 
6743     cp = bases;
6744 
6745     AJNEW0(ret);
6746     ret->len     = strlen(bases);
6747     ret->size    = CHAR_MAX - CHAR_MIN + 1;
6748     ret->table   = AJCALLOC0(ret->size, sizeof(char));
6749     ret->bases   = ajStrNewC(bases);
6750     ret->missing = 0;
6751 
6752     i = 0;
6753 
6754     while(*cp)
6755     {
6756 	i++;
6757 	ret->table[toupper((ajint) *cp)] = ajSysCastItoc(i);
6758 	ret->table[tolower((ajint) *cp)] = ajSysCastItoc(i);
6759 	cp++;
6760     }
6761 
6762     return ret;
6763 }
6764 
6765 
6766 
6767 
6768 /* @func ajSeqcvtNewEndC ******************************************************
6769 **
6770 ** Generates a new conversion table in which the first character in the
6771 ** string provided is converted to 0, the second to 1, and so on.
6772 ** Upper and lower case characters are converted to the same numbers.
6773 ** All other characters are converted to one more than the highest char.
6774 **
6775 ** @param [r] bases [const char*] Allowed sequence characters.
6776 ** @return [AjPSeqCvt] Conversion table.
6777 **
6778 ** @release 4.1.0
6779 ** @@
6780 ******************************************************************************/
6781 
ajSeqcvtNewEndC(const char * bases)6782 AjPSeqCvt ajSeqcvtNewEndC(const char* bases)
6783 {
6784     static AjPSeqCvt ret;
6785     ajint i;
6786     ajint j;
6787     ajint imax;
6788     const char *cp;
6789 
6790     cp = bases;
6791 
6792     imax = strlen(bases);
6793 
6794     AJNEW0(ret);
6795     ret->len     = imax;
6796     ret->size    = CHAR_MAX - CHAR_MIN + 1;
6797     ret->table   = AJCALLOC0(ret->size, sizeof(char));
6798     ret->bases   = ajStrNewC(bases);
6799     ret->missing = imax;
6800 
6801     for(j=0; j < ret->size; j++)
6802 	ret->table[j] = ajSysCastItoc(imax);
6803 
6804     i = 0;
6805 
6806     while(*cp)
6807     {
6808 	ret->table[toupper((ajint) *cp)] = ajSysCastItoc(i);
6809 	ret->table[tolower((ajint) *cp)] = ajSysCastItoc(i);
6810 	cp++;
6811 	i++;
6812     }
6813 
6814     return ret;
6815 }
6816 
6817 
6818 
6819 
6820 /* @func ajSeqcvtNewNumberC ***************************************************
6821 **
6822 ** Generates a new conversion table in which the characters are retained
6823 ** as upper case, numbers are set to -1 and all other characters
6824 ** are set to -2.
6825 **
6826 ** @param [r] bases [const char*] Allowed sequence characters.
6827 ** @return [AjPSeqCvt] Conversion table.
6828 **
6829 ** @release 4.1.0
6830 ** @@
6831 ******************************************************************************/
6832 
ajSeqcvtNewNumberC(const char * bases)6833 AjPSeqCvt ajSeqcvtNewNumberC(const char* bases)
6834 {
6835     static AjPSeqCvt ret;
6836     ajint i;
6837     ajint j;
6838     const char *cp;
6839     char c;
6840 
6841     cp = bases;
6842 
6843     AJNEW0(ret);
6844     ret->len     = strlen(bases);
6845     ret->size    = CHAR_MAX - CHAR_MIN + 1;
6846     ret->table   = AJCALLOC0(ret->size, sizeof(char));
6847     ret->bases   = ajStrNewC(bases);
6848     ret->missing = -1;
6849 
6850     for(j=0; j < ret->size; j++)
6851 	if(isdigit(j))
6852 	    ret->table[j] = -1;
6853 	else
6854 	    ret->table[j] = -2;
6855 
6856 
6857     i = 0;
6858 
6859     while(*cp)
6860     {
6861 	c = ajSysCastItoc(toupper((ajint)*cp));
6862 	ret->table[toupper((ajint) *cp)] = c;
6863 	ret->table[tolower((ajint) *cp)] = c;
6864 	cp++;
6865 	i++;
6866     }
6867 
6868     return ret;
6869 }
6870 
6871 
6872 
6873 
6874 /* @func ajSeqcvtNewStr *******************************************************
6875 **
6876 ** Generates a new conversion table in which the first character of the first
6877 ** string in the array provided is converted to 1, the first character of the
6878 ** second string is converted to 2, the first character of the third string is
6879 ** converted to 3 and so on.
6880 ** Upper and lower case characters are converted to the same numbers.
6881 ** All other characters are set to zero.
6882 **
6883 ** @param [r] basearray [const AjPPStr] Allowed sequence character strings
6884 **                            (size specified by parameter n)
6885 ** @param [r] numbases [ajint] Number of strings
6886 ** @return [AjPSeqCvt] Conversion table.
6887 **
6888 ** @release 4.1.0
6889 ** @@
6890 ******************************************************************************/
6891 
ajSeqcvtNewStr(const AjPPStr basearray,ajint numbases)6892 AjPSeqCvt ajSeqcvtNewStr (const AjPPStr basearray, ajint numbases)
6893 {
6894     static AjPSeqCvt ret;
6895     ajint i;
6896 
6897 
6898     AJNEW0(ret);
6899     ret->len = numbases;
6900     ret->size = CHAR_MAX - CHAR_MIN + 1;
6901     ret->table = AJCALLOC0(ret->size, sizeof(char));
6902     ret->bases = ajStrNew();
6903     ret->missing = 0;
6904 
6905 
6906     AJCNEW0(ret->rlabels, numbases);
6907     for(i=0; i<numbases; i++)
6908 	ret->rlabels[i] = ajStrNew();
6909     for(i=0; i<numbases; i++)
6910 	ajStrAssignS(&ret->rlabels[i], basearray[i]);
6911 
6912 
6913     AJCNEW0(ret->clabels, numbases);
6914 
6915     for(i=0; i<numbases; i++)
6916 	ret->clabels[i] = ajStrNew();
6917 
6918     for(i=0; i<numbases; i++)
6919 	ajStrAssignS(&ret->clabels[i], basearray[i]);
6920 
6921     for(i=0; i<numbases; i++)
6922     {
6923 	ajStrAppendK(&ret->bases, ajStrGetCharFirst(basearray[i]));
6924 	ret->table[toupper((ajint) ajStrGetCharFirst(basearray[i]))] =
6925 	    ajSysCastItoc(i+1);
6926 	ret->table[tolower((ajint) ajStrGetCharFirst(basearray[i]))] =
6927 	    ajSysCastItoc(i+1);
6928     }
6929 
6930     return ret;
6931 }
6932 
6933 
6934 
6935 
6936 /* @func ajSeqcvtNewStrAsym ***************************************************
6937 **
6938 ** Generates a new conversion table in which the first character of the first
6939 ** string in the array provided is converted to 1, the first character of the
6940 ** second string is converted to 2, the first character of the third string is
6941 ** converted to 3 and so on.
6942 ** Upper and lower case characters are converted to the same numbers.
6943 ** All other characters are set to zero.
6944 ** For use with asymmetrical matrices.
6945 **
6946 ** @param [r] basearray [const AjPPStr] Allowed sequence character strings
6947 **                                      (size specified by parameter n)
6948 ** @param [r] numbases [ajint] Number of strings
6949 ** @param [r] matchbases [const AjPPStr] Allowed sequence character strings for
6950 **                                       rows (size specified by parameter rn)
6951 ** @param [r] nummatch [ajint] Number of strings (rows)
6952 ** @return [AjPSeqCvt] Conversion table.
6953 **
6954 ** @release 4.1.0
6955 ** @@
6956 ******************************************************************************/
6957 
ajSeqcvtNewStrAsym(const AjPPStr basearray,ajint numbases,const AjPPStr matchbases,ajint nummatch)6958 AjPSeqCvt ajSeqcvtNewStrAsym (const AjPPStr basearray, ajint numbases,
6959 				 const AjPPStr matchbases, ajint nummatch)
6960 {
6961     static AjPSeqCvt ret;
6962     ajint i;
6963 
6964 
6965     AJNEW0(ret);
6966     ret->len = numbases;
6967     ret->nclabels = numbases;
6968     ret->nrlabels = nummatch;
6969     ret->size = CHAR_MAX - CHAR_MIN + 1;
6970     ret->table = AJCALLOC0(ret->size, sizeof(char));
6971     ret->bases = ajStrNew();
6972     ret->missing = 0;
6973 
6974 
6975     AJCNEW0(ret->rlabels, nummatch);
6976 
6977     for(i=0; i<nummatch; i++)
6978 	ret->rlabels[i] = ajStrNew();
6979 
6980     for(i=0; i<nummatch; i++)
6981 	ajStrAssignS(&ret->rlabels[i], matchbases[i]);
6982 
6983 
6984     AJCNEW0(ret->clabels, numbases);
6985 
6986     for(i=0; i<numbases; i++)
6987 	ret->clabels[i] = ajStrNew();
6988 
6989     for(i=0; i<numbases; i++)
6990 	ajStrAssignS(&ret->clabels[i], basearray[i]);
6991 
6992 
6993     for(i=0; i<numbases; i++)
6994     {
6995 	/* ajStrAssignS(&ret->labels[i], bases[i]); */
6996 	ajStrAppendK(&ret->bases, ajStrGetCharFirst(basearray[i]));
6997 	ret->table[toupper((ajint) ajStrGetCharFirst(basearray[i]))] =
6998 	    ajSysCastItoc(i+1);
6999 	ret->table[tolower((ajint) ajStrGetCharFirst(basearray[i]))] =
7000 	    ajSysCastItoc(i+1);
7001     }
7002 
7003     return ret;
7004 }
7005 
7006 
7007 
7008 
7009 /* @section Sequence Destructors **********************************************
7010 **
7011 ** Destruction destroys all internal data structures and frees the
7012 ** memory allocated for the sequence.
7013 **
7014 ** @fdata [AjPSeqCvt]
7015 ** @fcategory delete
7016 **
7017 ** @nam3rule Del Destroy (free) a sequence conversion table object
7018 **
7019 ** @argrule * Pcvt [AjPSeqCvt*] Sequence conversion table object address
7020 **
7021 ** @valrule * [void]
7022 **
7023 ******************************************************************************/
7024 
7025 
7026 
7027 
7028 /* @func ajSeqcvtDel **********************************************************
7029 **
7030 ** Delete a conversion table
7031 **
7032 ** @param [w] Pcvt [AjPSeqCvt*] Conversion table reference
7033 ** @return [void]
7034 **
7035 ** @release 4.1.0
7036 ** @@
7037 ******************************************************************************/
7038 
ajSeqcvtDel(AjPSeqCvt * Pcvt)7039 void ajSeqcvtDel (AjPSeqCvt* Pcvt)
7040 {
7041     ajint i=0;
7042 
7043     if(!*Pcvt|| !Pcvt)
7044 	return;
7045 
7046     AJFREE((*Pcvt)->table);
7047     ajStrDel(&(*Pcvt)->bases);
7048 
7049     if((*Pcvt)->rlabels)
7050     {
7051 	for(i=0;i<(*Pcvt)->nrlabels;i++)
7052 	    ajStrDel(&(*Pcvt)->rlabels[i]);
7053 
7054 	AJFREE((*Pcvt)->rlabels);
7055     }
7056 
7057     if((*Pcvt)->clabels)
7058     {
7059 	for(i=0;i<(*Pcvt)->nclabels;i++)
7060 	    ajStrDel(&(*Pcvt)->clabels[i]);
7061 
7062 	AJFREE((*Pcvt)->clabels);
7063     }
7064 
7065     AJFREE(*Pcvt);
7066 
7067     return;
7068 }
7069 
7070 
7071 
7072 
7073 /* @section element retrieval ********************************************
7074 **
7075 ** These functions use the contents of a sequence conversion object
7076 **
7077 ** @fdata [AjPSeqCvt]
7078 ** @fcategory use
7079 **
7080 ** @nam3rule Get Return sequence conversion attribute(s)
7081 ** @nam4rule GetLen Return length (number of bases defined)
7082 ** @nam4rule GetCode Return conversion code
7083 ** @nam5rule GetCodeAsym Return conversion code from asymmetric table column
7084 ** @nam5rule GetCodeAsymrow Return conversion code from asymmetric table row
7085 **
7086 ** @suffix K Single character code
7087 ** @suffix S String label code
7088 ** @argrule * cvt [const AjPSeqCvt] Conversion table
7089 ** @argrule K ch [char] base character
7090 ** @argrule S str [const AjPStr] base character
7091 ** @valrule GetLen [ajuint] Table length
7092 ** @valrule GetCode [ajint] Table code value
7093 ******************************************************************************/
7094 
7095 
7096 
7097 
7098 /* @func ajSeqcvtGetCodeK *****************************************************
7099 **
7100 ** Returns the integer code corresponding to a sequence character
7101 ** in a conversion table
7102 **
7103 ** @param [r] cvt [const AjPSeqCvt] Conversion table
7104 ** @param [r] ch [char] Sequence character
7105 **
7106 ** @return [ajint] Conversion code
7107 **
7108 ** @release 4.1.0
7109 ** @@
7110 ******************************************************************************/
7111 
ajSeqcvtGetCodeK(const AjPSeqCvt cvt,char ch)7112 ajint ajSeqcvtGetCodeK(const AjPSeqCvt cvt, char ch)
7113 {
7114     return cvt->table[(ajint)ch];
7115 }
7116 
7117 
7118 
7119 
7120 /* @func ajSeqcvtGetCodeS *****************************************************
7121 **
7122 ** Returns the integer code corresponding to a sequence character string
7123 ** in a conversion table (for rows in asymmetrical matrices).
7124 **
7125 ** @param [r] cvt [const AjPSeqCvt] Conversion table
7126 ** @param [r] str [const AjPStr] Sequence character string
7127 **
7128 ** @return [ajint] Conversion code
7129 **
7130 ** @release 4.1.0
7131 ** @@
7132 ******************************************************************************/
7133 
ajSeqcvtGetCodeS(const AjPSeqCvt cvt,const AjPStr str)7134 ajint ajSeqcvtGetCodeS (const AjPSeqCvt cvt, const AjPStr str)
7135 {
7136     ajint i=0;
7137 
7138     for(i=0;i<cvt->nrlabels;i++)
7139 	if(ajStrMatchS(str, cvt->rlabels[i]))
7140 	    return i+1;
7141 
7142     /* i+1 is returned because the size of a matrix is always 1 bigger than
7143        the number of labels. This is the "padding" first row/column which
7144        has all values of 0. */
7145 
7146 
7147     ajWarn("Sequence character string not found in ajSeqcvtGetCodeS");
7148     return 0;
7149 }
7150 
7151 
7152 
7153 
7154 /* @func ajSeqcvtGetCodeAsymS *************************************************
7155 **
7156 ** Returns the integer code corresponding to a sequence character string
7157 ** in a conversion table (for columns in asymmetrical matrices).
7158 **
7159 ** @param [r] cvt [const AjPSeqCvt] Conversion table
7160 ** @param [r] str [const AjPStr] Sequence character string
7161 **
7162 ** @return [ajint] Conversion code
7163 **
7164 ** @release 4.1.0
7165 ** @@
7166 ******************************************************************************/
7167 
ajSeqcvtGetCodeAsymS(const AjPSeqCvt cvt,const AjPStr str)7168 ajint ajSeqcvtGetCodeAsymS (const AjPSeqCvt cvt, const AjPStr str)
7169 {
7170     ajint i=0;
7171 
7172     for(i=0;i<cvt->nclabels;i++)
7173 	if(ajStrMatchS(str, cvt->clabels[i]))
7174 	    return i+1;
7175 
7176     /* i+1 is returned because the size of a matrix is always 1 bigger than
7177        the number of labels. This is the "padding" first row/column which
7178        has all values of 0. */
7179 
7180 
7181     ajWarn("Sequence character string not found in ajSeqcvtGetCodeAsymS");
7182     return 0;
7183 }
7184 
7185 
7186 
7187 
7188 /* @func ajSeqcvtGetCodeAsymrowS **********************************************
7189 **
7190 ** Returns the integer code corresponding to a sequence character string
7191 ** in a conversion table (for rows in asymmetrical matrices).
7192 **
7193 ** @param [r] cvt [const AjPSeqCvt] Conversion table
7194 ** @param [r] str [const AjPStr] Sequence character string
7195 **
7196 ** @return [ajint] Conversion code
7197 **
7198 ** @release 6.3.0
7199 ** @@
7200 ******************************************************************************/
7201 
ajSeqcvtGetCodeAsymrowS(const AjPSeqCvt cvt,const AjPStr str)7202 ajint ajSeqcvtGetCodeAsymrowS (const AjPSeqCvt cvt, const AjPStr str)
7203 {
7204     ajint i=0;
7205 
7206     for(i=0;i<cvt->nrlabels;i++)
7207 	if(ajStrMatchS(str, cvt->rlabels[i]))
7208 	    return i+1;
7209 
7210     /* i+1 is returned because the size of a matrix is always 1 bigger than
7211        the number of labels. This is the "padding" first row/column which
7212        has all values of 0. */
7213 
7214 
7215     ajWarn("Sequence character string not found in ajSeqcvtGetCodeAsymrowS");
7216     return 0;
7217 }
7218 
7219 
7220 
7221 
7222 /* @func ajSeqcvtGetLen *******************************************************
7223 **
7224 ** Returns the length of a conversion table string (number of sequence
7225 ** characters explicitly included)
7226 **
7227 ** @param [r] cvt [const AjPSeqCvt] Conversion table
7228 **
7229 ** @return [ajuint] Length
7230 **
7231 ** @release 4.1.0
7232 ** @@
7233 ******************************************************************************/
7234 
ajSeqcvtGetLen(const AjPSeqCvt cvt)7235 ajuint ajSeqcvtGetLen(const AjPSeqCvt cvt)
7236 {
7237     return cvt->len;
7238 }
7239 
7240 
7241 
7242 
7243 /* @datasection [AjPSeqDate] sequence dates ***********************************
7244 **
7245 ** Functions handling sequence dates
7246 **
7247 ** @nam2rule Seqdate
7248 **
7249 ******************************************************************************/
7250 
7251 
7252 
7253 
7254 /* @section sequence date constructors ****************************************
7255 **
7256 ** @fdata [AjPSeqDate]
7257 ** @fcategory new
7258 **
7259 ** @nam3rule New Constructor
7260 ** @nam4rule NewDate Copy constructor
7261 **
7262 ** @argrule Date date [const AjPSeqDate] Original date to be copied
7263 **
7264 ** @valrule * [AjPSeqDate]
7265 **
7266 ******************************************************************************/
7267 
7268 
7269 
7270 
7271 /* @func ajSeqdateNew *********************************************************
7272 **
7273 ** Constructor for empty sequence date object
7274 **
7275 ** @return [AjPSeqDate] Empty sequence date object
7276 **
7277 ** @release 5.0.0
7278 ******************************************************************************/
7279 
ajSeqdateNew(void)7280 AjPSeqDate ajSeqdateNew(void)
7281 {
7282     AjPSeqDate ret;
7283     AJNEW0(ret);
7284 
7285     return ret;
7286 }
7287 
7288 
7289 
7290 
7291 /* @func ajSeqdateNewDate *****************************************************
7292 **
7293 ** Constructor for copy of a sequence date object
7294 **
7295 ** @param [r] date [const AjPSeqDate] Sequence date object
7296 ** @return [AjPSeqDate] Empty sequence date object
7297 **
7298 ** @release 5.0.0
7299 ******************************************************************************/
7300 
ajSeqdateNewDate(const AjPSeqDate date)7301 AjPSeqDate ajSeqdateNewDate(const AjPSeqDate date)
7302 {
7303     AjPSeqDate ret;
7304     AJNEW0(ret);
7305 
7306     if(!date)
7307 	return ret;
7308 
7309     if(date->CreDate)
7310 	ret->CreDate = ajTimeNewTime(date->CreDate);
7311 
7312     if(date->ModDate)
7313 	ret->ModDate = ajTimeNewTime(date->ModDate);
7314 
7315     if(date->SeqDate)
7316 	ret->SeqDate = ajTimeNewTime(date->SeqDate);
7317 
7318     if(date->CreRel)
7319 	ajStrAssignS(&ret->CreRel, date->CreRel);
7320 
7321     if(date->ModRel)
7322 	ajStrAssignS(&ret->ModRel, date->ModRel);
7323 
7324     if(date->SeqRel)
7325 	ajStrAssignS(&ret->SeqRel, date->SeqRel);
7326 
7327     if(date->CreVer)
7328 	ajStrAssignS(&ret->CreVer, date->CreVer);
7329 
7330     if(date->ModVer)
7331 	ajStrAssignS(&ret->ModVer, date->ModVer);
7332 
7333     if(date->SeqVer)
7334 	ajStrAssignS(&ret->SeqVer, date->SeqVer);
7335 
7336     return ret;
7337 }
7338 
7339 
7340 
7341 
7342 /* @section destructors **********************************************
7343 **
7344 ** Destruction destroys all internal data structures and frees the
7345 ** memory allocated for the sequence.
7346 **
7347 ** @fdata [AjPSeqDate]
7348 ** @fcategory delete
7349 **
7350 ** @nam3rule Del Destroy (free) a sequence date object
7351 **
7352 ** @argrule * Pdate [AjPSeqDate*] Sequence date object address
7353 **
7354 ** @valrule * [void]
7355 **
7356 ******************************************************************************/
7357 
7358 
7359 
7360 
7361 /* @func ajSeqdateDel *********************************************************
7362 **
7363 ** Deletes a sequence date object.
7364 **
7365 ** @param [d] Pdate [AjPSeqDate*] Sequence date object
7366 ** @return [void]
7367 **
7368 ** @release 5.0.0
7369 ** @@
7370 ******************************************************************************/
7371 
ajSeqdateDel(AjPSeqDate * Pdate)7372 void ajSeqdateDel(AjPSeqDate* Pdate)
7373 {
7374     AjPSeqDate date;
7375 
7376     if(!Pdate)
7377 	return;
7378 
7379     if(!*Pdate)
7380 	return;
7381 
7382     date = *Pdate;
7383 
7384     ajTimeDel(&date->CreDate);
7385     ajTimeDel(&date->ModDate);
7386     ajTimeDel(&date->SeqDate);
7387 
7388     ajStrDel(&date->CreRel);
7389     ajStrDel(&date->ModRel);
7390     ajStrDel(&date->SeqRel);
7391     ajStrDel(&date->CreVer);
7392     ajStrDel(&date->ModVer);
7393     ajStrDel(&date->SeqVer);
7394 
7395     AJFREE(*Pdate);
7396 
7397     return;
7398 }
7399 
7400 
7401 
7402 
7403 /* @section tests *************************************************************
7404 **
7405 ** These functions test properties of a sequence date
7406 **
7407 ** @fdata [AjPSeqDate]
7408 ** @fcategory use
7409 **
7410 ** @nam3rule Exists    Date is defined
7411 **
7412 ** @argrule *     date    [const AjPSeqDate] Sequence date object
7413 **
7414 ** @valrule *      [AjBool] True on success
7415 **
7416 ******************************************************************************/
7417 
7418 
7419 
7420 
7421 /* @func ajSeqdateExists ******************************************************
7422 **
7423 ** Returns true if a sequence has a creation or modification date defined
7424 **
7425 ** @param [r] date [const AjPSeqDate] Sequence date
7426 ** @return [AjBool] ajTrue if date(s) are defined
7427 **
7428 ** @release 6.6.0
7429 ** @@
7430 ******************************************************************************/
7431 
ajSeqdateExists(const AjPSeqDate date)7432 AjBool ajSeqdateExists(const AjPSeqDate date)
7433 {
7434     if(!date)
7435         return ajFalse;
7436 
7437     if(date->CreDate || date->ModDate || date->SeqDate)
7438         return ajTrue;
7439 
7440     return ajFalse;
7441 }
7442 
7443 
7444 
7445 
7446 /* @section modifiers *********************************************************
7447 **
7448 ** These functions update contents of a sequence date object.
7449 **
7450 ** @fdata [AjPSeqDate]
7451 ** @fcategory modify
7452 **
7453 **
7454 ** @nam3rule Clear     Clear all contents
7455 **
7456 ** @nam3rule Set       Set sequence date properties
7457 ** @nam4rule SetCreate Set creation date
7458 ** @nam4rule SetModify Set modified date
7459 ** @nam4rule SetModseq Set sequence modified date
7460 **
7461 ** @suffix   C         Date as a C string
7462 ** @suffix   S         Date as a string object
7463 **
7464 ** @argrule *     date    [AjPSeqDate] Sequence date object
7465 ** @argrule C     datestr [const char*] Character string
7466 ** @argrule S     datestr [const AjPStr] String
7467 **
7468 ** @valrule *      [AjBool] True on success
7469 ** @valrule *Clear [void]
7470 **
7471 ******************************************************************************/
7472 
7473 
7474 
7475 
7476 /* @func ajSeqdateClear *******************************************************
7477 **
7478 ** Resets all data for a sequence date object.
7479 **
7480 ** @param [u] date [AjPSeqDate] Sequence date object
7481 ** @return [void]
7482 **
7483 ** @release 6.1.0
7484 ** @@
7485 ******************************************************************************/
7486 
ajSeqdateClear(AjPSeqDate date)7487 void ajSeqdateClear(AjPSeqDate date)
7488 {
7489     if(!date)
7490         return;
7491 
7492     ajTimeDel(&date->CreDate);
7493     ajTimeDel(&date->ModDate);
7494     ajTimeDel(&date->SeqDate);
7495 
7496     ajStrSetClear(&date->CreRel);
7497     ajStrSetClear(&date->ModRel);
7498     ajStrSetClear(&date->SeqRel);
7499     ajStrSetClear(&date->CreVer);
7500     ajStrSetClear(&date->ModVer);
7501     ajStrSetClear(&date->SeqVer);
7502 
7503     return;
7504 }
7505 
7506 
7507 
7508 
7509 /* @func ajSeqdateSetCreateS **************************************************
7510 **
7511 ** Set the sequence creation date
7512 **
7513 ** @param [w] date [AjPSeqDate] Sequence date
7514 ** @param [r] datestr [const AjPStr] Date string
7515 ** @return [AjBool] ajTrue on success
7516 **
7517 ** @release 5.0.0
7518 ******************************************************************************/
7519 
ajSeqdateSetCreateS(AjPSeqDate date,const AjPStr datestr)7520 AjBool ajSeqdateSetCreateS(AjPSeqDate date, const AjPStr datestr)
7521 {
7522     if(!date)
7523 	return ajFalse;
7524 
7525     if(!seqDateSet(&date->CreDate, datestr))
7526         return ajFalse;
7527 
7528     if(!date->CreVer)
7529         date->CreVer = ajStrNewC("1");
7530 
7531     return ajTrue;
7532 }
7533 
7534 
7535 
7536 
7537 /* @func ajSeqdateSetModifyS **************************************************
7538 **
7539 ** Set the entry modification date
7540 **
7541 ** @param [w] date [AjPSeqDate] Sequence date
7542 ** @param [r] datestr [const AjPStr] Date string
7543 ** @return [AjBool] ajTrue on success
7544 **
7545 ** @release 5.0.0
7546 ******************************************************************************/
7547 
ajSeqdateSetModifyS(AjPSeqDate date,const AjPStr datestr)7548 AjBool ajSeqdateSetModifyS(AjPSeqDate date, const AjPStr datestr)
7549 {
7550     if(!date)
7551 	return ajFalse;
7552 
7553     if(!seqDateSet(&date->ModDate, datestr))
7554         return ajFalse;
7555 
7556     if(!date->ModVer)
7557         date->ModVer = ajStrNewC("1");
7558 
7559     return ajTrue;
7560 }
7561 
7562 
7563 
7564 
7565 /* @func ajSeqdateSetModseqS **************************************************
7566 **
7567 ** Set the sequence modification date
7568 **
7569 ** @param [w] date [AjPSeqDate] Sequence date
7570 ** @param [r] datestr [const AjPStr] Date string
7571 ** @return [AjBool] ajTrue on success
7572 **
7573 ** @release 5.0.0
7574 ******************************************************************************/
7575 
ajSeqdateSetModseqS(AjPSeqDate date,const AjPStr datestr)7576 AjBool ajSeqdateSetModseqS(AjPSeqDate date, const AjPStr datestr)
7577 {
7578     if(!date)
7579 	return ajFalse;
7580 
7581     if(!seqDateSet(&date->SeqDate, datestr))
7582         return ajFalse;
7583 
7584     if(!date->SeqVer)
7585         date->SeqVer = ajStrNewC("1");
7586 
7587     return ajTrue;
7588 }
7589 
7590 
7591 
7592 
7593 /* @funcstatic seqDateSet *****************************************************
7594 **
7595 ** Sets a sequence date object
7596 **
7597 ** @param [w] date [AjPTime*] Sequence date object
7598 ** @param [r] datestr [const AjPStr] Date as a string in EMBL/UniProt style
7599 ** @return [AjBool] ajTrue on success
7600 **
7601 ** @release 5.0.0
7602 ******************************************************************************/
7603 
seqDateSet(AjPTime * date,const AjPStr datestr)7604 static AjBool seqDateSet(AjPTime* date, const AjPStr datestr)
7605 {
7606     AjBool ok = ajTrue;
7607     AjPStrTok handle = NULL;
7608     AjPStr tmpstr = NULL;
7609     const char* months[] =
7610     {
7611 	"JAN", "FEB", "MAR", "APR", "MAY", "JUN",
7612 	"JUL", "AUG", "SEP", "OCT", "NOV", "DEC", NULL
7613     };
7614     ajint day;
7615     ajint month;
7616     ajint year;
7617 
7618     ajStrTokenAssignC(&handle, datestr, "-");
7619 
7620     ajStrTokenNextParse(handle, &tmpstr);
7621     ajStrToInt(tmpstr, &day);
7622 
7623     ajStrTokenNextParse(handle, &tmpstr);
7624     month = 0;
7625 
7626     while(months[month] && !ajStrMatchC(tmpstr, months[month]))
7627 	month++;
7628 
7629     if(!months[month])
7630     {
7631         ok = ajFalse;
7632 	month = 1;
7633     }
7634     else
7635 	month++;
7636 
7637     ajStrTokenNextParse(handle, &tmpstr);
7638     ajStrToInt(tmpstr, &year);
7639 
7640     if(year > 1900)
7641 	year -= 1900;
7642 
7643     if(!day)
7644     {
7645         ok = ajFalse;
7646         day = 1;
7647     }
7648 
7649     if(ok)
7650         *date = ajTimeNewDayFmt("dtline", day, month, year);
7651 
7652     ajStrTokenDel(&handle);
7653     ajStrDel(&tmpstr);
7654 
7655     return ok;
7656 }
7657 
7658 
7659 
7660 
7661 /* @datasection [AjPSeqDesc] sequence descriptions *****************************
7662 **
7663 ** Functions handling complex descriptions (e.g. in UniProt)
7664 **
7665 ** @nam2rule Seqdesc
7666 **
7667 ******************************************************************************/
7668 
7669 
7670 
7671 
7672 /* @section descriptions constructors ************************************
7673 **
7674 ** @fdata [AjPSeqDesc]
7675 ** @fcategory new
7676 **
7677 ** @nam3rule New Constructor
7678 ** @nam4rule NewDesc Copy constructor
7679 **
7680 ** @argrule Desc desc [const AjPSeqDesc] Source description object
7681 **
7682 ** @valrule * [AjPSeqDesc]
7683 **
7684 ******************************************************************************/
7685 
7686 
7687 
7688 
7689 /* @func ajSeqdescNew *********************************************************
7690 **
7691 ** Constructor for empty description object
7692 **
7693 ** @return [AjPSeqDesc] Empty sequence description object
7694 **
7695 ** @release 6.1.0
7696 ******************************************************************************/
7697 
ajSeqdescNew(void)7698 AjPSeqDesc ajSeqdescNew(void)
7699 {
7700     AjPSeqDesc ret;
7701 
7702     AJNEW0(ret);
7703 
7704     ret->Name     = ajStrNew();
7705 
7706     ret->Short    = ajListstrNew();
7707     ret->EC       = ajListstrNew();
7708     ret->Multi    = ajListstrNew();
7709 
7710 
7711     ret->AltNames = ajListNew();
7712     ret->SubNames = ajListNew();
7713     ret->Includes = ajListNew();
7714     ret->Contains = ajListNew();
7715     return ret;
7716 }
7717 
7718 
7719 
7720 
7721 /* @func ajSeqdescNewDesc *****************************************************
7722 **
7723 ** Constructor for copy of a description object
7724 **
7725 ** @param [r] desc [const AjPSeqDesc] Description object
7726 ** @return [AjPSeqDesc] Copied description object
7727 **
7728 ** @release 6.1.0
7729 ******************************************************************************/
7730 
ajSeqdescNewDesc(const AjPSeqDesc desc)7731 AjPSeqDesc ajSeqdescNewDesc(const AjPSeqDesc desc)
7732 {
7733     AjPSeqDesc ret;
7734 
7735     AJNEW0(ret);
7736 
7737     if(!desc)
7738 	return ret;
7739 
7740     ret->AltNames = ajListNew();
7741     ret->SubNames = ajListNew();
7742     ret->Includes = ajListNew();
7743     ret->Contains = ajListNew();
7744 
7745     ajStrAssignS(&ret->Name, desc->Name);
7746     ret->Short = ajListstrNewList(desc->Short);
7747     ret->EC = ajListstrNewList(desc->EC);
7748     ret->Multi = ajListstrNewList(desc->Multi);
7749     ajSeqsubdesclistClone(desc->AltNames, ret->AltNames);
7750     ajSeqsubdesclistClone(desc->SubNames, ret->SubNames);
7751     ajSeqdesclistClone(desc->Includes, ret->Includes);
7752     ajSeqdesclistClone(desc->Contains, ret->Contains);
7753 
7754     ret->Precursor = desc->Precursor;
7755     ret->Fragments = desc->Fragments;
7756 
7757     return ret;
7758 }
7759 
7760 
7761 
7762 
7763 /* @section destructors **********************************************
7764 **
7765 ** Destruction destroys all internal data structures and frees the
7766 ** memory allocated for a description object
7767 **
7768 ** @fdata [AjPSeqDesc]
7769 ** @fcategory delete
7770 **
7771 ** @nam3rule Del Destroy (free) a description object
7772 **
7773 ** @argrule * Pdesc [AjPSeqDesc*] Description object address
7774 **
7775 ** @valrule * [void]
7776 **
7777 ******************************************************************************/
7778 
7779 
7780 
7781 
7782 /* @func ajSeqdescDel *********************************************************
7783 **
7784 ** Deletes a description object.
7785 **
7786 ** @param [d] Pdesc [AjPSeqDesc*] Description object
7787 ** @return [void]
7788 **
7789 ** @release 6.1.0
7790 ** @@
7791 ******************************************************************************/
7792 
ajSeqdescDel(AjPSeqDesc * Pdesc)7793 void ajSeqdescDel(AjPSeqDesc* Pdesc)
7794 {
7795     AjPSeqDesc sdesc;
7796     AjPSeqDesc desc;
7797     AjPSeqSubdesc sub;
7798 
7799     if(!Pdesc)
7800 	return;
7801 
7802     if(!*Pdesc)
7803 	return;
7804 
7805     sdesc = *Pdesc;
7806 
7807     ajStrDel(&sdesc->Name);
7808 
7809     ajListstrFreeData(&sdesc->Short);
7810     ajListstrFreeData(&sdesc->EC);
7811     ajListstrFreeData(&sdesc->Multi);
7812 
7813     while(ajListPop(sdesc->AltNames,(void **)&sub))
7814 	ajSeqsubdescDel(&sub);
7815 
7816     ajListFree(&sdesc->AltNames);
7817 
7818     while(ajListPop(sdesc->SubNames,(void **)&sub))
7819 	ajSeqsubdescDel(&sub);
7820 
7821     ajListFree(&sdesc->SubNames);
7822 
7823     while(ajListPop(sdesc->Includes,(void **)&desc))
7824 	ajSeqdescDel(&desc);
7825 
7826     ajListFree(&sdesc->Includes);
7827 
7828     while(ajListPop(sdesc->Contains,(void **)&desc))
7829 	ajSeqdescDel(&desc);
7830 
7831     ajListFree(&sdesc->Contains);
7832 
7833     AJFREE(*Pdesc);
7834 
7835     return;
7836 }
7837 
7838 
7839 
7840 
7841 /* @section modifiers ************************************************
7842 **
7843 ** These functions update contents of a description object.
7844 **
7845 ** @fdata [AjPSeqDesc]
7846 ** @fcategory modify
7847 **
7848 ** @nam3rule Append     Append to a description object
7849 ** @nam3rule Clear      Clear all contents
7850 ** @nam3rule Set        Set a description object
7851 ** @nam4rule AppendName Append to name of a description object
7852 ** @nam4rule SetName    Set name of a description object
7853 **
7854 ** @argrule * desc [AjPSeqDesc] Description object
7855 **
7856 ** @argrule Append str [const AjPStr] Text to append
7857 ** @argrule Set    str [const AjPStr] Text to assign
7858 **
7859 ** @valrule *      [AjBool] True on success
7860 ** @valrule *Clear [void]
7861 ******************************************************************************/
7862 
7863 
7864 
7865 
7866 /* @func ajSeqdescAppendName **************************************************
7867 **
7868 ** Append to the name of a description
7869 **
7870 ** @param [u] desc [AjPSeqDesc] Description object
7871 ** @param [r] str [const AjPStr] Name string
7872 ** @return [AjBool] True on success
7873 **
7874 ** @release 6.1.0
7875 ******************************************************************************/
7876 
ajSeqdescAppendName(AjPSeqDesc desc,const AjPStr str)7877 AjBool ajSeqdescAppendName(AjPSeqDesc desc, const AjPStr str)
7878 {
7879     if(ajStrGetLen(desc->Name))
7880 	ajStrAppendK(&desc->Name, ' ');
7881 
7882     ajStrAppendS(&desc->Name, str);
7883 
7884     return ajTrue;
7885 }
7886 
7887 
7888 
7889 
7890 /* @func ajSeqdescClear *******************************************************
7891 **
7892 ** Resets data for a description object.
7893 **
7894 ** @param [u] desc [AjPSeqDesc] Description object
7895 ** @return [void]
7896 **
7897 ** @release 6.1.0
7898 ** @@
7899 ******************************************************************************/
7900 
ajSeqdescClear(AjPSeqDesc desc)7901 void ajSeqdescClear(AjPSeqDesc desc)
7902 {
7903     AjPSeqDesc sdesc;
7904     AjPSeqSubdesc sub;
7905     AjPStr ptr = NULL;
7906 
7907     if(!desc) return;
7908 
7909     ajStrSetClear(&desc->Name);
7910 
7911     while(ajListstrPop(desc->Short,&ptr))
7912 	ajStrDel(&ptr);
7913 
7914     while(ajListstrPop(desc->EC,&ptr))
7915 	ajStrDel(&ptr);
7916 
7917     while(ajListstrPop(desc->Multi,&ptr))
7918 	ajStrDel(&ptr);
7919 
7920     while(ajListPop(desc->AltNames,(void **)&sub))
7921 	ajSeqsubdescDel(&sub);
7922 
7923     while(ajListPop(desc->SubNames,(void **)&sub))
7924 	ajSeqsubdescDel(&sub);
7925 
7926     while(ajListPop(desc->Includes,(void **)&sdesc))
7927 	ajSeqdescDel(&sdesc);
7928 
7929     while(ajListPop(desc->Contains,(void **)&sdesc))
7930 	ajSeqdescDel(&sdesc);
7931 
7932     desc->Precursor = ajFalse;
7933     desc->Fragments = 0;
7934 
7935     return;
7936 }
7937 
7938 
7939 
7940 
7941 /* @func ajSeqdescSetName *****************************************************
7942 **
7943 ** Set the name of a description object
7944 **
7945 ** @param [u] desc [AjPSeqDesc] Description object
7946 ** @param [r] str [const AjPStr] Synonyms string
7947 ** @return [AjBool] True on success
7948 **
7949 ** @release 6.1.0
7950 ******************************************************************************/
7951 
ajSeqdescSetName(AjPSeqDesc desc,const AjPStr str)7952 AjBool ajSeqdescSetName(AjPSeqDesc desc, const AjPStr str)
7953 {
7954     ajStrAssignS(&desc->Name, str);
7955 
7956     return ajTrue;
7957 }
7958 
7959 
7960 
7961 
7962 /* @datasection [AjPList] Description list operations *************************
7963 **
7964 ** Manipulating lists of descriptions
7965 **
7966 ** @nam2rule Seqdesclist
7967 **
7968 ******************************************************************************/
7969 
7970 
7971 
7972 
7973 /* @section Description list operations ****************************************
7974 **
7975 ** Manipulating lists of descriptions
7976 **
7977 ** @fdata [AjPList]
7978 ** @fcategory use
7979 **
7980 ** @nam3rule Clone Clone list of sequence descriptions
7981 **
7982 ** @argrule * src [const AjPList] List of sequence description objects
7983 ** @argrule Clone dest [AjPList] Empty list to hold sequence description objects
7984 **
7985 ** @valrule * [AjBool] True on success
7986 **
7987 ******************************************************************************/
7988 
7989 
7990 
7991 
7992 /* @func ajSeqdesclistClone ***************************************************
7993 **
7994 ** Copy a list of genes to another list
7995 **
7996 ** @param [r] src [const AjPList] Source list of descriptions
7997 ** @param [w] dest [AjPList] Destination list of descriptions
7998 ** @return [AjBool] True on success
7999 **
8000 ** @release 6.1.0
8001 ******************************************************************************/
8002 
ajSeqdesclistClone(const AjPList src,AjPList dest)8003 AjBool ajSeqdesclistClone(const AjPList src, AjPList dest)
8004 {
8005     AjIList iter;
8006     AjPSeqDesc descout = NULL;
8007     AjPSeqDesc descin = NULL;
8008 
8009     if(ajListGetLength(dest))
8010 	return ajFalse;
8011 
8012     iter = ajListIterNewread(src);
8013 
8014     while ((descin = (AjPSeqDesc) ajListIterGet(iter)))
8015     {
8016 	descout = ajSeqdescNewDesc(descin);
8017 	ajListPushAppend(dest, descout);
8018     }
8019 
8020     ajListIterDel(&iter);
8021 
8022     return ajTrue;
8023 }
8024 
8025 
8026 
8027 
8028 /* @datasection [AjPSeqSubdesc] sequence sub-descriptions **********************
8029 **
8030 ** Functions handling complex sub-descriptions (e.g. in UniProt)
8031 **
8032 ** @nam2rule Seqsubdesc
8033 **
8034 ******************************************************************************/
8035 
8036 
8037 
8038 
8039 /* @section sub-descriptions constructors ************************************
8040 **
8041 ** @fdata [AjPSeqSubdesc]
8042 ** @fcategory new
8043 **
8044 ** @nam3rule New        Constructor
8045 ** @nam4rule NewSubdesc Copy constructor
8046 **
8047 ** @argrule Subdesc desc [const AjPSeqSubdesc] Source sub-description object
8048 **
8049 ** @valrule * [AjPSeqSubdesc]
8050 **
8051 ******************************************************************************/
8052 
8053 
8054 
8055 
8056 /* @func ajSeqsubdescNew ******************************************************
8057 **
8058 ** Constructor for empty sub-description object
8059 **
8060 ** @return [AjPSeqSubdesc] Empty sequence sub-description object
8061 **
8062 ** @release 6.1.0
8063 ******************************************************************************/
8064 
ajSeqsubdescNew(void)8065 AjPSeqSubdesc ajSeqsubdescNew(void)
8066 {
8067     AjPSeqSubdesc ret;
8068     AJNEW0(ret);
8069 
8070     ret->Short     = ajListstrNew();
8071     ret->EC        = ajListstrNew();
8072     ret->Allergen  = ajListstrNew();
8073     ret->Biotech   = ajListstrNew();
8074     ret->Cdantigen = ajListstrNew();
8075     ret->Inn       = ajListstrNew();
8076 
8077     return ret;
8078 }
8079 
8080 
8081 
8082 
8083 /* @func ajSeqsubdescNewSubdesc ***********************************************
8084 **
8085 ** Constructor for copy of a sub-description object
8086 **
8087 ** @param [r] desc [const AjPSeqSubdesc] Sub-description object
8088 ** @return [AjPSeqSubdesc] Copied sub-description object
8089 **
8090 ** @release 6.1.0
8091 ******************************************************************************/
8092 
ajSeqsubdescNewSubdesc(const AjPSeqSubdesc desc)8093 AjPSeqSubdesc ajSeqsubdescNewSubdesc(const AjPSeqSubdesc desc)
8094 {
8095     AjPSeqSubdesc ret;
8096     AJNEW0(ret);
8097 
8098     if(!desc)
8099 	return ret;
8100 
8101     ajStrAssignS(&ret->Name, desc->Name);
8102     ret->Short = ajListstrNewList(desc->Short);
8103     ret->EC = ajListstrNewList(desc->EC);
8104     ret->Allergen = ajListstrNewList(desc->Allergen);
8105     ret->Biotech = ajListstrNewList(desc->Biotech);
8106     ret->Cdantigen = ajListstrNewList(desc->Cdantigen);
8107     ret->Inn = ajListstrNewList(desc->Inn);
8108 
8109     return ret;
8110 }
8111 
8112 
8113 
8114 
8115 /* @section destructors **********************************************
8116 **
8117 ** Destruction destroys all internal data structures and frees the
8118 ** memory allocated for a sub-description object
8119 **
8120 ** @fdata [AjPSeqSubdesc]
8121 ** @fcategory delete
8122 **
8123 ** @nam3rule Del Destroy (free) a sub-description object
8124 **
8125 ** @argrule * Pdesc [AjPSeqSubdesc*] Sub-description object address
8126 **
8127 ** @valrule * [void]
8128 **
8129 ******************************************************************************/
8130 
8131 
8132 
8133 
8134 /* @func ajSeqsubdescDel ******************************************************
8135 **
8136 ** Deletes a sub-description object.
8137 **
8138 ** @param [d] Pdesc [AjPSeqSubdesc*] Sub-description object
8139 ** @return [void]
8140 **
8141 ** @release 6.1.0
8142 ** @@
8143 ******************************************************************************/
8144 
ajSeqsubdescDel(AjPSeqSubdesc * Pdesc)8145 void ajSeqsubdescDel(AjPSeqSubdesc* Pdesc)
8146 {
8147     AjPSeqSubdesc sdesc;
8148 
8149     if(!Pdesc)
8150 	return;
8151 
8152     if(!*Pdesc)
8153 	return;
8154 
8155     sdesc = *Pdesc;
8156 
8157     ajStrDel(&sdesc->Name);
8158     ajListstrFreeData(&sdesc->Short);
8159     ajListstrFreeData(&sdesc->EC);
8160     ajListstrFreeData(&sdesc->Allergen);
8161     ajListstrFreeData(&sdesc->Biotech);
8162     ajListstrFreeData(&sdesc->Cdantigen);
8163     ajListstrFreeData(&sdesc->Inn);
8164 
8165     AJFREE(*Pdesc);
8166 
8167     return;
8168 }
8169 
8170 
8171 
8172 
8173 /* @section modifiers ************************************************
8174 **
8175 ** These functions update contents of a sub-description object.
8176 **
8177 ** @fdata [AjPSeqSubdesc]
8178 ** @fcategory modify
8179 **
8180 ** @nam3rule Append Append to a sub-description object
8181 ** @nam3rule Clear     Clear all contents
8182 ** @nam3rule Set Set a sub-description object
8183 ** @nam4rule AppendName Append to name of a sub-description object
8184 ** @nam4rule SetName Set name of a sub-description object
8185 **
8186 ** @argrule *  desc [AjPSeqSubdesc] Sub-description object
8187 **
8188 ** @argrule Append str [const AjPStr] Text to append
8189 ** @argrule Set str [const AjPStr] Text to assign
8190 **
8191 ** @valrule * [AjBool] True on success
8192 ** @valrule *Clear [void]
8193 ******************************************************************************/
8194 
8195 
8196 
8197 
8198 /* @func ajSeqsubdescAppendName ***********************************************
8199 **
8200 ** Append to the name of a description
8201 **
8202 ** @param [u] desc [AjPSeqSubdesc] Description object
8203 ** @param [r] str [const AjPStr] Name string
8204 ** @return [AjBool] True on success
8205 **
8206 ** @release 6.1.0
8207 ******************************************************************************/
8208 
ajSeqsubdescAppendName(AjPSeqSubdesc desc,const AjPStr str)8209 AjBool ajSeqsubdescAppendName(AjPSeqSubdesc desc, const AjPStr str)
8210 {
8211     if(ajStrGetLen(desc->Name))
8212 	ajStrAppendK(&desc->Name, ' ');
8213     ajStrAppendS(&desc->Name, str);
8214 
8215     return ajTrue;
8216 }
8217 
8218 
8219 
8220 
8221 /* @func ajSeqsubdescClear ****************************************************
8222 **
8223 ** Resets data for a sub-description object.
8224 **
8225 ** @param [u] desc [AjPSeqSubdesc] Sub-description object
8226 ** @return [void]
8227 **
8228 ** @release 6.1.0
8229 ** @@
8230 ******************************************************************************/
8231 
ajSeqsubdescClear(AjPSeqSubdesc desc)8232 void ajSeqsubdescClear(AjPSeqSubdesc desc)
8233 {
8234     AjPStr ptr = NULL;
8235 
8236     if(!desc)
8237         return;
8238 
8239     ajStrSetClear(&desc->Name);
8240 
8241     while(ajListstrPop(desc->Short,&ptr))
8242 	ajStrDel(&ptr);
8243 
8244     while(ajListstrPop(desc->EC,&ptr))
8245 	ajStrDel(&ptr);
8246 
8247     while(ajListstrPop(desc->Allergen,&ptr))
8248 	ajStrDel(&ptr);
8249 
8250     while(ajListstrPop(desc->Biotech,&ptr))
8251 	ajStrDel(&ptr);
8252 
8253     while(ajListstrPop(desc->Cdantigen,&ptr))
8254 	ajStrDel(&ptr);
8255 
8256     while(ajListstrPop(desc->Inn,&ptr))
8257 	ajStrDel(&ptr);
8258 
8259     return;
8260 }
8261 
8262 
8263 
8264 
8265 /* @func ajSeqsubdescSetName **************************************************
8266 **
8267 ** Set the name of a sub-description object
8268 **
8269 ** @param [u] desc [AjPSeqSubdesc] Sub-description object
8270 ** @param [r] str [const AjPStr] Synonyms string
8271 ** @return [AjBool] True on success
8272 **
8273 ** @release 6.1.0
8274 ******************************************************************************/
8275 
ajSeqsubdescSetName(AjPSeqSubdesc desc,const AjPStr str)8276 AjBool ajSeqsubdescSetName(AjPSeqSubdesc desc, const AjPStr str)
8277 {
8278     ajStrAssignS(&desc->Name, str);
8279 
8280     return ajTrue;
8281 }
8282 
8283 
8284 
8285 
8286 /* @datasection [AjPList] Description list operations *************************
8287 **
8288 ** Manipulating lists of sub-descriptions
8289 **
8290 ** @nam2rule Seqsubdesclist
8291 **
8292 ******************************************************************************/
8293 
8294 
8295 
8296 
8297 /* @section Description list operations ****************************************
8298 **
8299 ** Manipulating lists of sub-descriptions
8300 **
8301 ** @fdata [AjPList]
8302 ** @fcategory use
8303 **
8304 ** @nam3rule Clone Clone list of sequence sub-descriptions
8305 **
8306 ** @argrule *     src  [const AjPList] List of sequence sub-description objects
8307 ** @argrule Clone dest [AjPList] Empty list to hold sequence sub-description
8308 **                               objects
8309 **
8310 ** @valrule * [AjBool] True on success
8311 **
8312 ******************************************************************************/
8313 
8314 
8315 
8316 
8317 /* @func ajSeqsubdesclistClone ************************************************
8318 **
8319 ** Copy a list of sub-descriptions to another list
8320 **
8321 ** @param [r] src [const AjPList] Source list of sub-descriptions
8322 ** @param [w] dest [AjPList] Destination list of sub-descriptions
8323 ** @return [AjBool] True on success
8324 **
8325 ** @release 6.1.0
8326 ******************************************************************************/
8327 
ajSeqsubdesclistClone(const AjPList src,AjPList dest)8328 AjBool ajSeqsubdesclistClone(const AjPList src, AjPList dest)
8329 {
8330     AjIList iter;
8331     AjPSeqSubdesc descout = NULL;
8332     AjPSeqSubdesc descin = NULL;
8333 
8334     if(ajListGetLength(dest))
8335 	return ajFalse;
8336 
8337     iter = ajListIterNewread(src);
8338 
8339     while ((descin = (AjPSeqSubdesc) ajListIterGet(iter)))
8340     {
8341 	descout = ajSeqsubdescNewSubdesc(descin);
8342 	ajListPushAppend(dest, descout);
8343     }
8344 
8345     ajListIterDel(&iter);
8346 
8347     return ajTrue;
8348 }
8349 
8350 
8351 
8352 
8353 /* @datasection [AjPSeqGene] gene names ***************************************
8354 **
8355 ** Functions handling gene names, synonyms and other terms
8356 **
8357 ** @nam2rule Seqgene
8358 **
8359 ******************************************************************************/
8360 
8361 
8362 
8363 
8364 /* @section gene names constructors ************************************
8365 **
8366 ** @fdata [AjPSeqGene]
8367 ** @fcategory new
8368 **
8369 ** @nam3rule New Constructor
8370 ** @nam4rule NewGene Copy constructor
8371 ** @nam4rule NewName Constructor with given name
8372 **
8373 ** @argrule Gene gene [const AjPSeqGene] Source gene object
8374 ** @argrule Name str [const AjPStr] Gene name
8375 **
8376 ** @valrule * [AjPSeqGene]
8377 **
8378 ******************************************************************************/
8379 
8380 
8381 
8382 
8383 /* @func ajSeqgeneNew *********************************************************
8384 **
8385 ** Constructor for empty gene object
8386 **
8387 ** @return [AjPSeqGene] Empty sequence gene object
8388 **
8389 ** @release 6.1.0
8390 ******************************************************************************/
8391 
ajSeqgeneNew(void)8392 AjPSeqGene ajSeqgeneNew(void)
8393 {
8394     AjPSeqGene ret;
8395     AJNEW0(ret);
8396 
8397     return ret;
8398 }
8399 
8400 
8401 
8402 
8403 /* @func ajSeqgeneNewGene *****************************************************
8404 **
8405 ** Constructor for copy of a gene object
8406 **
8407 ** @param [r] gene [const AjPSeqGene] Gene object
8408 ** @return [AjPSeqGene] Copied gene object
8409 **
8410 ** @release 6.1.0
8411 ******************************************************************************/
8412 
ajSeqgeneNewGene(const AjPSeqGene gene)8413 AjPSeqGene ajSeqgeneNewGene(const AjPSeqGene gene)
8414 {
8415     AjPSeqGene ret;
8416     AJNEW0(ret);
8417 
8418     if(!gene)
8419 	return ret;
8420 
8421     ajStrAssignS(&ret->Name, gene->Name);
8422     ajStrAssignS(&ret->Synonyms, gene->Synonyms);
8423     ajStrAssignS(&ret->Orf, gene->Orf);
8424     ajStrAssignS(&ret->Oln, gene->Oln);
8425 
8426     return ret;
8427 }
8428 
8429 
8430 
8431 
8432 /* @func ajSeqgeneNewName *****************************************************
8433 **
8434 ** Constructor for gene with given name
8435 **
8436 ** @param [r] str [const AjPStr] Gene name
8437 ** @return [AjPSeqGene] New gene object
8438 **
8439 ** @release 6.1.0
8440 ******************************************************************************/
8441 
ajSeqgeneNewName(const AjPStr str)8442 AjPSeqGene ajSeqgeneNewName(const AjPStr str)
8443 {
8444     AjPSeqGene ret;
8445     AJNEW0(ret);
8446 
8447     if(!str)
8448 	return ret;
8449 
8450     ajStrAssignS(&ret->Name, str);
8451 
8452     return ret;
8453 }
8454 
8455 
8456 
8457 
8458 /* @section destructors **********************************************
8459 **
8460 ** Destruction destroys all internal data structures and frees the
8461 ** memory allocated for a gene object
8462 **
8463 ** @fdata [AjPSeqGene]
8464 ** @fcategory delete
8465 **
8466 ** @nam3rule Del Destroy (free) a gene object
8467 **
8468 ** @argrule * Pgene [AjPSeqGene*] Gene object address
8469 **
8470 ** @valrule * [void]
8471 **
8472 ******************************************************************************/
8473 
8474 
8475 
8476 
8477 /* @func ajSeqgeneDel *********************************************************
8478 **
8479 ** Deletes a gene object.
8480 **
8481 ** @param [d] Pgene [AjPSeqGene*] Gene object
8482 ** @return [void]
8483 **
8484 ** @release 6.1.0
8485 ** @@
8486 ******************************************************************************/
8487 
ajSeqgeneDel(AjPSeqGene * Pgene)8488 void ajSeqgeneDel(AjPSeqGene* Pgene)
8489 {
8490     AjPSeqGene sgene;
8491 
8492     if(!Pgene)
8493 	return;
8494 
8495     if(!*Pgene)
8496 	return;
8497 
8498     sgene = *Pgene;
8499 
8500     ajStrDel(&sgene->Name);
8501     ajStrDel(&sgene->Synonyms);
8502     ajStrDel(&sgene->Orf);
8503     ajStrDel(&sgene->Oln);
8504 
8505     AJFREE(*Pgene);
8506 
8507     return;
8508 }
8509 
8510 
8511 
8512 
8513 /* @section modifiers ************************************************
8514 **
8515 ** These functions update contents of a gene object.
8516 **
8517 ** @fdata [AjPSeqGene]
8518 ** @fcategory modify
8519 **
8520 ** @nam3rule Append         Append to names of a gene object
8521 ** @nam3rule Set            Set names of a gene object
8522 ** @nam4rule AppendName     Append to name of a gene object
8523 ** @nam4rule AppendOrf      Append to ORF names of a gene object
8524 ** @nam4rule AppendOln      Append to ordered locus names of a gene object
8525 ** @nam4rule AppendSynonyms Append to synonyms of a gene object
8526 ** @nam4rule SetName        Set name of a gene object
8527 ** @nam4rule SetOrf         Set ORF names of a gene object
8528 ** @nam4rule SetOln         Set ordered locus names of a gene object
8529 ** @nam4rule SetSynonyms    Set synonyms of a gene object
8530 **
8531 ** @argrule Append gene [AjPSeqGene] Gene object
8532 ** @argrule Set    gene [AjPSeqGene] Gene object
8533 **
8534 ** @argrule Append str [const AjPStr] Text to append
8535 ** @argrule Set    str [const AjPStr] Text to assign
8536 **
8537 ** @valrule * [AjBool] True on success
8538 ******************************************************************************/
8539 
8540 
8541 
8542 
8543 /* @func ajSeqgeneAppendName **************************************************
8544 **
8545 ** Append to the name of a gene
8546 **
8547 ** @param [u] gene [AjPSeqGene] Gene object
8548 ** @param [r] str [const AjPStr] Name string
8549 ** @return [AjBool] True on success
8550 **
8551 ** @release 6.1.0
8552 ******************************************************************************/
8553 
ajSeqgeneAppendName(AjPSeqGene gene,const AjPStr str)8554 AjBool ajSeqgeneAppendName(AjPSeqGene gene, const AjPStr str)
8555 {
8556     if(ajStrGetLen(gene->Name))
8557 	ajStrAppendK(&gene->Name, ' ');
8558 
8559     ajStrAppendS(&gene->Name, str);
8560 
8561     return ajTrue;
8562 }
8563 
8564 
8565 
8566 
8567 /* @func ajSeqgeneAppendOln ***************************************************
8568 **
8569 ** Append to ordered locus names of a gene
8570 **
8571 ** @param [u] gene [AjPSeqGene] Gene object
8572 ** @param [r] str [const AjPStr] Ordered locus names string
8573 ** @return [AjBool] True on success
8574 **
8575 ** @release 6.1.0
8576 ******************************************************************************/
8577 
ajSeqgeneAppendOln(AjPSeqGene gene,const AjPStr str)8578 AjBool ajSeqgeneAppendOln(AjPSeqGene gene, const AjPStr str)
8579 {
8580     if(ajStrGetLen(gene->Oln))
8581 	ajStrAppendK(&gene->Oln, ' ');
8582 
8583     ajStrAppendS(&gene->Oln, str);
8584 
8585     return ajTrue;
8586 }
8587 
8588 
8589 
8590 
8591 /* @func ajSeqgeneAppendOrf ***************************************************
8592 **
8593 ** Append to the ORF name of a gene
8594 **
8595 ** @param [u] gene [AjPSeqGene] Gene object
8596 ** @param [r] str [const AjPStr] ORF name string
8597 ** @return [AjBool] True on success
8598 **
8599 ** @release 6.1.0
8600 ******************************************************************************/
8601 
ajSeqgeneAppendOrf(AjPSeqGene gene,const AjPStr str)8602 AjBool ajSeqgeneAppendOrf(AjPSeqGene gene, const AjPStr str)
8603 {
8604     if(ajStrGetLen(gene->Orf))
8605 	ajStrAppendK(&gene->Orf, ' ');
8606 
8607     ajStrAppendS(&gene->Orf, str);
8608 
8609     return ajTrue;
8610 }
8611 
8612 
8613 
8614 
8615 /* @func ajSeqgeneAppendSynonyms **********************************************
8616 **
8617 ** Append to the name of a gene
8618 **
8619 ** @param [u] gene [AjPSeqGene] Gene object
8620 ** @param [r] str [const AjPStr] Synonyms string
8621 ** @return [AjBool] True on success
8622 **
8623 ** @release 6.1.0
8624 ******************************************************************************/
8625 
ajSeqgeneAppendSynonyms(AjPSeqGene gene,const AjPStr str)8626 AjBool ajSeqgeneAppendSynonyms(AjPSeqGene gene, const AjPStr str)
8627 {
8628     if(ajStrGetLen(gene->Synonyms))
8629 	ajStrAppendK(&gene->Synonyms, ' ');
8630 
8631     ajStrAppendS(&gene->Synonyms, str);
8632 
8633     return ajTrue;
8634 }
8635 
8636 
8637 
8638 
8639 /* @func ajSeqgeneSetName *****************************************************
8640 **
8641 ** Set the name of a gene
8642 **
8643 ** @param [u] gene [AjPSeqGene] Gene object
8644 ** @param [r] str [const AjPStr] Name string
8645 ** @return [AjBool] True on success
8646 **
8647 ** @release 6.1.0
8648 ******************************************************************************/
8649 
ajSeqgeneSetName(AjPSeqGene gene,const AjPStr str)8650 AjBool ajSeqgeneSetName(AjPSeqGene gene, const AjPStr str)
8651 {
8652     ajStrAssignS(&gene->Name, str);
8653 
8654     return ajTrue;
8655 }
8656 
8657 
8658 
8659 
8660 /* @func ajSeqgeneSetOln ******************************************************
8661 **
8662 ** Set the ordered locus names of a gene
8663 **
8664 ** @param [u] gene [AjPSeqGene] Gene object
8665 ** @param [r] str [const AjPStr] Ordered locus names string
8666 ** @return [AjBool] True on success
8667 **
8668 ** @release 6.1.0
8669 ******************************************************************************/
8670 
ajSeqgeneSetOln(AjPSeqGene gene,const AjPStr str)8671 AjBool ajSeqgeneSetOln(AjPSeqGene gene, const AjPStr str)
8672 {
8673     ajStrAssignS(&gene->Oln, str);
8674 
8675     return ajTrue;
8676 }
8677 
8678 
8679 
8680 
8681 /* @func ajSeqgeneSetOrf ******************************************************
8682 **
8683 ** Set the ORF name of a gene
8684 **
8685 ** @param [u] gene [AjPSeqGene] Gene object
8686 ** @param [r] str [const AjPStr] ORF name string
8687 ** @return [AjBool] True on success
8688 **
8689 ** @release 6.1.0
8690 ******************************************************************************/
8691 
ajSeqgeneSetOrf(AjPSeqGene gene,const AjPStr str)8692 AjBool ajSeqgeneSetOrf(AjPSeqGene gene, const AjPStr str)
8693 {
8694     ajStrAssignS(&gene->Orf, str);
8695 
8696     return ajTrue;
8697 }
8698 
8699 
8700 
8701 
8702 /* @func ajSeqgeneSetSynonyms *************************************************
8703 **
8704 ** Set the name of a gene
8705 **
8706 ** @param [u] gene [AjPSeqGene] Gene object
8707 ** @param [r] str [const AjPStr] Synonyms string
8708 ** @return [AjBool] True on success
8709 **
8710 ** @release 6.1.0
8711 ******************************************************************************/
8712 
ajSeqgeneSetSynonyms(AjPSeqGene gene,const AjPStr str)8713 AjBool ajSeqgeneSetSynonyms(AjPSeqGene gene, const AjPStr str)
8714 {
8715     ajStrAssignS(&gene->Synonyms, str);
8716 
8717     return ajTrue;
8718 }
8719 
8720 
8721 
8722 
8723 /* @datasection [AjPList] Reference list operations ***************************
8724 **
8725 ** Manipulating lists of genes
8726 **
8727 ** @nam2rule Seqgenelist
8728 **
8729 ******************************************************************************/
8730 
8731 
8732 
8733 
8734 /* @section Reference list operations *****************************************
8735 **
8736 ** Manipulating lists of genes
8737 **
8738 ** @fdata [AjPList]
8739 ** @fcategory use
8740 **
8741 ** @nam3rule Clone Clone list of sequence citations
8742 **
8743 ** @argrule * src [const AjPList] List of sequence citation objects
8744 ** @argrule Clone dest [AjPList] Empty list to hold sequence citation objects
8745 **
8746 ** @valrule * [AjBool] True on success
8747 **
8748 ******************************************************************************/
8749 
8750 
8751 
8752 
8753 /* @func ajSeqgenelistClone ***************************************************
8754 **
8755 ** Copy a list of genes to another list
8756 **
8757 ** @param [r] src [const AjPList] Source list of genes
8758 ** @param [w] dest [AjPList] Destination list of genes
8759 ** @return [AjBool] True on success
8760 **
8761 ** @release 6.1.0
8762 ******************************************************************************/
8763 
ajSeqgenelistClone(const AjPList src,AjPList dest)8764 AjBool ajSeqgenelistClone(const AjPList src, AjPList dest)
8765 {
8766     AjIList iter;
8767     AjPSeqGene geneout = NULL;
8768     AjPSeqGene genein = NULL;
8769 
8770     if(ajListGetLength(dest))
8771 	return ajFalse;
8772 
8773     iter = ajListIterNewread(src);
8774 
8775     while ((genein = (AjPSeqGene) ajListIterGet(iter)))
8776     {
8777 	geneout = ajSeqgeneNewGene(genein);
8778 	ajListPushAppend(dest, geneout);
8779     }
8780 
8781     ajListIterDel(&iter);
8782 
8783     return ajTrue;
8784 }
8785 
8786 
8787 
8788 
8789 /* @datasection [AjPSeqXref] sequence citations ********************************
8790 **
8791 ** Functions handling sequence cross-references
8792 **
8793 ** @nam2rule Seqxref
8794 **
8795 ******************************************************************************/
8796 
8797 
8798 
8799 
8800 /* @section sequence cross-reference constructors ******************************
8801 **
8802 ** @fdata [AjPSeqXref]
8803 ** @fcategory new
8804 **
8805 ** @nam3rule New Constructor
8806 ** @nam4rule NewDb Constructor with database and id
8807 ** @nam4rule NewRef Copy constructor
8808 ** @suffix C Data provided as char*
8809 ** @suffix S Data provided as AjPStr
8810 **
8811 ** @argrule Ref xref [const AjPSeqXref] Source sequence cross-reference object
8812 ** @argrule Db id      [const AjPStr] Identifier
8813 ** @argrule C  db      [const char*] Database name
8814 ** @argrule S  db      [const AjPStr] Database name
8815 ** @argrule Db reftype [ajuint] Enumerated reference type
8816 **
8817 ** @valrule * [AjPSeqXref]
8818 **
8819 ******************************************************************************/
8820 
8821 
8822 
8823 
8824 /* @func ajSeqxrefNew *********************************************************
8825 **
8826 ** Constructor for empty sequence citation object
8827 **
8828 ** @return [AjPSeqXref] Empty sequence cross-reference object
8829 **
8830 ** @release 6.1.0
8831 ******************************************************************************/
8832 
ajSeqxrefNew(void)8833 AjPSeqXref ajSeqxrefNew(void)
8834 {
8835     AjPSeqXref ret;
8836     AJNEW0(ret);
8837 
8838     return ret;
8839 }
8840 
8841 
8842 
8843 
8844 /* @func ajSeqxrefNewDbC ******************************************************
8845 **
8846 ** Constructor for copy of a sequence citation object
8847 **
8848 ** @param [r] id [const AjPStr] Primary identifier
8849 ** @param [r] db [const char *] Database name
8850 ** @param [r] reftype [ajuint] Reference type
8851 ** @return [AjPSeqXref] New sequence cross-reference object
8852 **
8853 ** @release 6.1.0
8854 ******************************************************************************/
8855 
ajSeqxrefNewDbC(const AjPStr id,const char * db,ajuint reftype)8856 AjPSeqXref ajSeqxrefNewDbC(const AjPStr id, const char* db, ajuint reftype)
8857 {
8858     AjPSeqXref ret;
8859 
8860     AJNEW0(ret);
8861 
8862     ajStrAssignC(&ret->Db, db);
8863     ajStrAssignS(&ret->Id, id);
8864 
8865     if(ajStrPrefixCaseS(ret->Id, ret->Db) &&
8866        ajStrGetCharPos(ret->Id, ajStrGetLen(ret->Db)) == ':')
8867         ajStrCutStart(&ret->Id, 1+ajStrGetLen(ret->Db));
8868 
8869     ret->Type = reftype;
8870 
8871     return ret;
8872 }
8873 
8874 
8875 
8876 
8877 /* @func ajSeqxrefNewDbS ******************************************************
8878 **
8879 ** Constructor for copy of a sequence citation object
8880 **
8881 ** @param [r] id [const AjPStr] Primary identifier
8882 ** @param [r] db [const AjPStr] Database name
8883 ** @param [r] reftype [ajuint] Reference type
8884 ** @return [AjPSeqXref] New sequence cross-reference object
8885 **
8886 ** @release 6.1.0
8887 ******************************************************************************/
8888 
ajSeqxrefNewDbS(const AjPStr id,const AjPStr db,ajuint reftype)8889 AjPSeqXref ajSeqxrefNewDbS(const AjPStr id, const AjPStr db, ajuint reftype)
8890 {
8891     AjPSeqXref ret;
8892 
8893     AJNEW0(ret);
8894 
8895     ajStrAssignS(&ret->Db, db);
8896     ajStrAssignS(&ret->Id, id);
8897 
8898     if(ajStrPrefixCaseS(ret->Id, ret->Db) &&
8899        ajStrGetCharPos(ret->Id, ajStrGetLen(ret->Db)) == ':')
8900         ajStrCutStart(&ret->Id, 1+ajStrGetLen(ret->Db));
8901 
8902     ret->Type = reftype;
8903 
8904     return ret;
8905 }
8906 
8907 
8908 
8909 
8910 /* @func ajSeqxrefNewRef ******************************************************
8911 **
8912 ** Constructor for copy of a sequence citation object
8913 **
8914 ** @param [r] xref [const AjPSeqXref] Sequence cross-reference object
8915 ** @return [AjPSeqXref] Copied sequence cross-reference object
8916 **
8917 ** @release 6.1.0
8918 ******************************************************************************/
8919 
ajSeqxrefNewRef(const AjPSeqXref xref)8920 AjPSeqXref ajSeqxrefNewRef(const AjPSeqXref xref)
8921 {
8922     AjPSeqXref ret;
8923     AJNEW0(ret);
8924 
8925     if(!xref)
8926 	return ret;
8927 
8928     ajStrAssignS(&ret->Db, xref->Db);
8929     ajStrAssignS(&ret->Id, xref->Id);
8930     ajStrAssignS(&ret->Secid, xref->Secid);
8931     ajStrAssignS(&ret->Terid, xref->Terid);
8932     ajStrAssignS(&ret->Quatid, xref->Quatid);
8933     ret->Type = xref->Type;
8934     ret->Start = xref->Start;
8935     ret->End = xref->End;
8936 
8937     return ret;
8938 }
8939 
8940 
8941 
8942 
8943 /* @section destructors **********************************************
8944 **
8945 ** Destruction destroys all internal data structures and frees the
8946 ** memory allocated for the sequence cross-reference
8947 **
8948 ** @fdata [AjPSeqXref]
8949 ** @fcategory delete
8950 **
8951 ** @nam3rule Del Destroy (free) a sequence cross-reference object
8952 **
8953 ** @argrule * Pxref [AjPSeqXref*] Sequence cross-reference object address
8954 **
8955 ** @valrule * [void]
8956 **
8957 ******************************************************************************/
8958 
8959 
8960 
8961 
8962 /* @func ajSeqxrefDel *********************************************************
8963 **
8964 ** Deletes a sequence cross-reference object.
8965 **
8966 ** @param [d] Pxref [AjPSeqXref*] Sequence cross-reference object
8967 ** @return [void]
8968 **
8969 ** @release 6.1.0
8970 ** @@
8971 ******************************************************************************/
8972 
ajSeqxrefDel(AjPSeqXref * Pxref)8973 void ajSeqxrefDel(AjPSeqXref* Pxref)
8974 {
8975     AjPSeqXref xref;
8976 
8977     if(!Pxref)
8978 	return;
8979 
8980     if(!*Pxref)
8981 	return;
8982 
8983     xref = *Pxref;
8984 
8985     ajStrDel(&xref->Db);
8986     ajStrDel(&xref->Id);
8987     ajStrDel(&xref->Secid);
8988     ajStrDel(&xref->Terid);
8989     ajStrDel(&xref->Quatid);
8990 
8991     AJFREE(*Pxref);
8992 
8993     return;
8994 }
8995 
8996 
8997 
8998 
8999 /* @datasection [AjPList] Cross-reference list operations *********************
9000 **
9001 ** Manipulating lists of sequence cross-references
9002 **
9003 ** @nam2rule Seqxreflist
9004 **
9005 ******************************************************************************/
9006 
9007 
9008 
9009 
9010 /* @section Reference list operations *****************************************
9011 **
9012 ** Manipulating lists of sequence cross-references
9013 **
9014 ** @fdata [AjPList]
9015 ** @fcategory use
9016 **
9017 ** @nam3rule Clone Clone list of sequence cross-references
9018 **
9019 ** @argrule * src [const AjPList] List of sequence cross-reference objects
9020 ** @argrule Clone dest [AjPList] Empty list to hold sequence cross-reference
9021 **                               objects
9022 **
9023 ** @valrule * [AjBool] True on success
9024 **
9025 ******************************************************************************/
9026 
9027 
9028 
9029 
9030 /* @func ajSeqxreflistClone ***************************************************
9031 **
9032 ** Copy a list of cross-references to another list
9033 **
9034 ** @param [r] src [const AjPList] Source list of cross-references
9035 ** @param [w] dest [AjPList] Destination list of cross-references
9036 ** @return [AjBool] True on success
9037 **
9038 ** @release 6.1.0
9039 ******************************************************************************/
9040 
ajSeqxreflistClone(const AjPList src,AjPList dest)9041 AjBool ajSeqxreflistClone(const AjPList src, AjPList dest)
9042 {
9043     AjIList iter;
9044     AjPSeqXref refout = NULL;
9045     AjPSeqXref refin = NULL;
9046 
9047     if(ajListGetLength(dest))
9048 	return ajFalse;
9049 
9050     iter = ajListIterNewread(src);
9051 
9052     while ((refin = (AjPSeqXref) ajListIterGet(iter)))
9053     {
9054 	refout = ajSeqxrefNewRef(refin);
9055 	ajListPushAppend(dest, refout);
9056     }
9057 
9058     ajListIterDel(&iter);
9059 
9060     return ajTrue;
9061 }
9062 
9063 
9064 
9065 
9066 /* @section Reference list operations *****************************************
9067 **
9068 ** Manipulating lists of sequence cross-references
9069 **
9070 ** @fdata [AjPList]
9071 ** @fcategory modify
9072 **
9073 ** @nam3rule Sort Sort list of sequence cross-references
9074 **
9075 ** @argrule * list [AjPList] List of sequence cross-reference objects
9076 **
9077 ** @valrule * [AjBool] True on success
9078 **
9079 ******************************************************************************/
9080 
9081 
9082 
9083 
9084 /* @func ajSeqxreflistSort ****************************************************
9085 **
9086 ** Sort a list of cross-references
9087 **
9088 ** @param [u] list [AjPList] Source list of cross-references
9089 ** @return [AjBool] True on success
9090 **
9091 ** @release 6.4.0
9092 ******************************************************************************/
9093 
ajSeqxreflistSort(AjPList list)9094 AjBool ajSeqxreflistSort(AjPList list)
9095 {
9096 ajListSortUnique(list, &seqxrefSortDb, &seqxrefDel);
9097 
9098     return ajTrue;
9099 }
9100 
9101 
9102 
9103 
9104 /* @funcstatic seqxrefSortDb **************************************************
9105 **
9106 ** Sort a cross-reference list by database name
9107 **
9108 ** @param [r] refa [const void*] First xref
9109 ** @param [r] refb [const void*] Second xref
9110 ** @return [int] -1 if first string should sort before second, +1 if the
9111 **         second string should sort first. 0 if they are identical
9112 **         in length and content.
9113 **
9114 ** @release 6.4.0
9115 ** @@
9116 ******************************************************************************/
9117 
seqxrefSortDb(const void * refa,const void * refb)9118 static int seqxrefSortDb(const void* refa, const void* refb)
9119 {
9120     const AjPSeqXref xrefa = *(AjPSeqXref const *) refa;
9121     const AjPSeqXref xrefb = *(AjPSeqXref const *)refb;
9122 
9123     int ret = 0;
9124 
9125     ret = ajStrCmpCaseS(xrefa->Db, xrefb->Db);
9126     if(ret) return ret;
9127 
9128     ret = ajStrCmpCaseS(xrefa->Id, xrefb->Id);
9129     if(ret) return ret;
9130 
9131     ret = ajStrCmpCaseS(xrefa->Secid, xrefb->Secid);
9132     if(ret) return ret;
9133 
9134     ret = ajStrCmpCaseS(xrefa->Terid, xrefb->Terid);
9135     if(ret) return ret;
9136 
9137     ret = ajStrCmpCaseS(xrefa->Quatid, xrefb->Quatid);
9138     if(ret) return ret;
9139 
9140     return 0;
9141 }
9142 
9143 
9144 
9145 
9146 /* @funcstatic seqxrefDel *****************************************************
9147 **
9148 ** Delete a sequence cross-reference object
9149 **
9150 ** @param [d] Pxref [void**] Pointer to cross-reference object
9151 ** @param [r] cl [void*] Second argumant (NULL)
9152 ** @return [void]
9153 **
9154 ** @release 6.4.0
9155 ******************************************************************************/
9156 
seqxrefDel(void ** Pxref,void * cl)9157 static void seqxrefDel(void** Pxref, void *cl)
9158 {
9159     (void) cl;
9160 
9161     ajSeqxrefDel((AjPSeqXref*) Pxref);
9162     return;
9163 }
9164 
9165 
9166 
9167 
9168 /* @datasection [AjPSeqRef] sequence citations ********************************
9169 **
9170 ** Functions handling sequence citations
9171 **
9172 ** @nam2rule Seqref
9173 **
9174 ******************************************************************************/
9175 
9176 
9177 
9178 
9179 /* @section sequence citation constructors ************************************
9180 **
9181 ** @fdata [AjPSeqRef]
9182 ** @fcategory new
9183 **
9184 ** @nam3rule New Constructor
9185 ** @nam4rule NewRef Copy constructor
9186 **
9187 ** @argrule Ref ref [const AjPSeqRef] Source sequence citation object
9188 **
9189 ** @valrule * [AjPSeqRef]
9190 **
9191 ******************************************************************************/
9192 
9193 
9194 
9195 
9196 /* @func ajSeqrefNew **********************************************************
9197 **
9198 ** Constructor for empty sequence citation object
9199 **
9200 ** @return [AjPSeqRef] Empty sequence citation object
9201 **
9202 ** @release 5.0.0
9203 ******************************************************************************/
9204 
ajSeqrefNew(void)9205 AjPSeqRef ajSeqrefNew(void)
9206 {
9207     AjPSeqRef ret;
9208     AJNEW0(ret);
9209 
9210     return ret;
9211 }
9212 
9213 
9214 
9215 
9216 /* @func ajSeqrefNewRef *******************************************************
9217 **
9218 ** Constructor for copy of a sequence citation object
9219 **
9220 ** @param [r] ref [const AjPSeqRef] Sequence citation object
9221 ** @return [AjPSeqRef] Copied sequence citation object
9222 **
9223 ** @release 5.0.0
9224 ******************************************************************************/
9225 
ajSeqrefNewRef(const AjPSeqRef ref)9226 AjPSeqRef ajSeqrefNewRef(const AjPSeqRef ref)
9227 {
9228     AjPSeqRef ret;
9229     AJNEW0(ret);
9230 
9231     if(!ref)
9232 	return ret;
9233 
9234     ajStrAssignS(&ret->Position, ref->Position);
9235     ajStrAssignS(&ret->Groupname, ref->Groupname);
9236     ajStrAssignS(&ret->Authors, ref->Authors);
9237     ajStrAssignS(&ret->Title, ref->Title);
9238     ajStrAssignS(&ret->Comment, ref->Comment);
9239     ajStrAssignS(&ret->Xref, ref->Xref);
9240     ajStrAssignS(&ret->Location, ref->Location);
9241     ajStrAssignS(&ret->Loctype, ref->Loctype);
9242     ret->Number = ref->Number;
9243 
9244     return ret;
9245 }
9246 
9247 
9248 
9249 
9250 /* @section destructors **********************************************
9251 **
9252 ** Destruction destroys all internal data structures and frees the
9253 ** memory allocated for the sequence citation
9254 **
9255 ** @fdata [AjPSeqRef]
9256 ** @fcategory delete
9257 **
9258 ** @nam3rule Del Destroy (free) a sequence citation object
9259 **
9260 ** @argrule * Pref [AjPSeqRef*] Sequence citation object address
9261 **
9262 ** @valrule * [void]
9263 **
9264 ******************************************************************************/
9265 
9266 
9267 
9268 
9269 /* @func ajSeqrefDel **********************************************************
9270 **
9271 ** Deletes a sequence citation object.
9272 **
9273 ** @param [d] Pref [AjPSeqRef*] Sequence citation object
9274 ** @return [void]
9275 **
9276 ** @release 5.0.0
9277 ** @@
9278 ******************************************************************************/
9279 
ajSeqrefDel(AjPSeqRef * Pref)9280 void ajSeqrefDel(AjPSeqRef* Pref)
9281 {
9282     AjPSeqRef sref;
9283 
9284     if(!Pref)
9285 	return;
9286 
9287     if(!*Pref)
9288 	return;
9289 
9290     sref = *Pref;
9291 
9292     ajStrDel(&sref->Position);
9293     ajStrDel(&sref->Groupname);
9294     ajStrDel(&sref->Authors);
9295     ajStrDel(&sref->Title);
9296     ajStrDel(&sref->Comment);
9297     ajStrDel(&sref->Xref);
9298     ajStrDel(&sref->Location);
9299     ajStrDel(&sref->Loctype);
9300 
9301     AJFREE(*Pref);
9302 
9303     return;
9304 }
9305 
9306 
9307 
9308 
9309 /* @section modifiers ************************************************
9310 **
9311 ** These functions update contents of a sequence citation object.
9312 **
9313 ** @fdata [AjPSeqRef]
9314 ** @fcategory modify
9315 **
9316 ** @nam3rule Append Append to part of a citation
9317 ** @nam4rule AppendAuthors Append to authors part of a citation
9318 ** @nam4rule AppendComment Append to comment part of a citation
9319 ** @nam4rule AppendGroupname Append to group name part of a citation
9320 ** @nam4rule AppendLocation Append to location part of a citation
9321 ** @nam4rule AppendPosition Append to position part of a citation
9322 ** @nam4rule AppendTitle Append to title part of a citation
9323 ** @nam4rule AppendXref Append to cross-reference part of a citation
9324 ** @nam3rule Fmt Reformat part of a citation
9325 ** @nam4rule FmtAuthors Reformat authors part of a citation
9326 ** @nam5rule FmtAuthorsEmbl Reformat authors part of a citation for EMBL
9327 ** @nam5rule FmtAuthorsGb Reformat authors part of a citation for GenBank
9328 ** @nam4rule FmtLocation Reformat location part of a citation
9329 ** @nam5rule FmtLocationEmbl Reformat location part of a citation for EMBL
9330 ** @nam5rule FmtLocationGb Reformat location part of a citation for GenBank
9331 ** @nam4rule FmtTitle Reformat title part of a citation
9332 ** @nam5rule FmtTitleEmbl Reformat title part of a citation for EMBL
9333 ** @nam5rule FmtTitleGb Reformat title part of a citation for GenBank
9334 ** @nam3rule Set Set text part of a citation
9335 ** @nam4rule SetAuthors Set authors part of a citation
9336 ** @nam4rule SetComment Set comment part of a citation
9337 ** @nam4rule SetGroupname Set group name part of a citation
9338 ** @nam4rule SetLocation Set location part of a citation
9339 ** @nam4rule SetLoctype Set location type of a citation
9340 ** @nam4rule SetPosition Set position part of a citation
9341 ** @nam4rule SetTitle Set title part of a citation
9342 ** @nam4rule SetXref Set cross-reference part of a citation
9343 ** @nam3rule Setnum Set numeric part of a citation
9344 ** @nam4rule SetnumNumber Set number of a citation
9345 ** @nam3rule Standard Standardise internal representation of a citation
9346 **
9347 ** @argrule Append ref [AjPSeqRef] Sequence citation object
9348 ** @argrule Fmt ref [const AjPSeqRef] Sequence citation object
9349 ** @argrule Set ref [AjPSeqRef] Sequence citation object
9350 ** @argrule Setnum ref [AjPSeqRef] Sequence citation object
9351 ** @argrule Standard ref [AjPSeqRef] Sequence citation object
9352 **
9353 ** @argrule Append str [const AjPStr] Text to append
9354 ** @argrule Fmt Pdest [AjPStr*] Returned formatted string
9355 ** @argrule Set str [const AjPStr] Text to assign
9356 ** @argrule Setnum num [ajuint] Number to assign
9357 **
9358 ** @valrule * [AjBool] True on success
9359 **
9360 ******************************************************************************/
9361 
9362 
9363 
9364 
9365 /* @func ajSeqrefAppendAuthors ************************************************
9366 **
9367 ** Append to the Authors string of a citation
9368 **
9369 ** @param [u] ref [AjPSeqRef] Sequence citation object
9370 ** @param [r] str [const AjPStr] Authors string
9371 ** @return [AjBool] True on success
9372 **
9373 ** @release 5.0.0
9374 ******************************************************************************/
9375 
ajSeqrefAppendAuthors(AjPSeqRef ref,const AjPStr str)9376 AjBool ajSeqrefAppendAuthors(AjPSeqRef ref, const AjPStr str)
9377 {
9378     if(ajStrGetLen(ref->Authors))
9379 	ajStrAppendK(&ref->Authors, ' ');
9380 
9381     ajStrAppendS(&ref->Authors, str);
9382 
9383     return ajTrue;
9384 }
9385 
9386 
9387 
9388 
9389 /* @func ajSeqrefAppendComment ************************************************
9390 **
9391 ** Append to the Comment string of a citation
9392 **
9393 ** @param [u] ref [AjPSeqRef] Sequence citation object
9394 ** @param [r] str [const AjPStr] Comment string
9395 ** @return [AjBool] True on success
9396 **
9397 ** @release 5.0.0
9398 ******************************************************************************/
9399 
ajSeqrefAppendComment(AjPSeqRef ref,const AjPStr str)9400 AjBool ajSeqrefAppendComment(AjPSeqRef ref, const AjPStr str)
9401 {
9402     if(ajStrGetLen(ref->Comment))
9403 	ajStrAppendK(&ref->Comment, ' ');
9404 
9405     ajStrAppendS(&ref->Comment, str);
9406 
9407     return ajTrue;
9408 }
9409 
9410 
9411 
9412 
9413 /* @func ajSeqrefAppendGroupname **********************************************
9414 **
9415 ** Append to the group name string of a citation
9416 **
9417 ** @param [u] ref [AjPSeqRef] Sequence citation object
9418 ** @param [r] str [const AjPStr] Group name string
9419 ** @return [AjBool] True on success
9420 **
9421 ** @release 5.0.0
9422 ******************************************************************************/
9423 
ajSeqrefAppendGroupname(AjPSeqRef ref,const AjPStr str)9424 AjBool ajSeqrefAppendGroupname(AjPSeqRef ref, const AjPStr str)
9425 {
9426     if(ajStrGetLen(ref->Groupname))
9427 	ajStrAppendK(&ref->Groupname, ' ');
9428 
9429     ajStrAppendS(&ref->Groupname, str);
9430 
9431     return ajTrue;
9432 }
9433 
9434 
9435 
9436 
9437 /* @func ajSeqrefAppendLocation ***********************************************
9438 **
9439 ** Append to the location string of a citation
9440 **
9441 ** @param [u] ref [AjPSeqRef] Sequence citation object
9442 ** @param [r] str [const AjPStr] Location string
9443 ** @return [AjBool] True on success
9444 **
9445 ** @release 5.0.0
9446 ******************************************************************************/
9447 
ajSeqrefAppendLocation(AjPSeqRef ref,const AjPStr str)9448 AjBool ajSeqrefAppendLocation(AjPSeqRef ref, const AjPStr str)
9449 {
9450     if(ajStrGetLen(ref->Location))
9451     {
9452 	if(ajStrGetCharLast(ref->Location) == '.')
9453 	    ajStrAppendK(&ref->Location, '\n');
9454 	else if(ajStrGetCharLast(ref->Location) == ';')
9455 	    ajStrAppendK(&ref->Location, '\n');
9456 	else
9457 	    ajStrAppendK(&ref->Location, ' ');
9458     }
9459     else
9460 	ajSeqrefSetLoctype(ref, str);
9461 
9462     ajStrAppendS(&ref->Location, str);
9463 
9464     return ajTrue;
9465 }
9466 
9467 
9468 
9469 
9470 /* @func ajSeqrefAppendPosition *q**********************************************
9471 **
9472 ** Append to the position string of a citation
9473 **
9474 ** @param [u] ref [AjPSeqRef] Sequence citation object
9475 ** @param [r] str [const AjPStr] Position string
9476 ** @return [AjBool] True on success
9477 **
9478 ** @release 5.0.0
9479 ******************************************************************************/
9480 
ajSeqrefAppendPosition(AjPSeqRef ref,const AjPStr str)9481 AjBool ajSeqrefAppendPosition(AjPSeqRef ref, const AjPStr str)
9482 {
9483     if(ajStrGetLen(ref->Position))
9484 	ajStrAppendK(&ref->Position, ' ');
9485 
9486     /* EMBL positions are nn-nn */
9487     /* GenBank positions are (residues nn to nn) */
9488     ajStrAppendS(&ref->Position, str);
9489 
9490     return ajTrue;
9491 }
9492 
9493 
9494 
9495 
9496 /* @func ajSeqrefAppendTitle **************************************************
9497 **
9498 ** Append to the title string of a citation
9499 **
9500 ** @param [u] ref [AjPSeqRef] Sequence citation object
9501 ** @param [r] str [const AjPStr] Title string
9502 ** @return [AjBool] True on success
9503 **
9504 ** @release 5.0.0
9505 ******************************************************************************/
9506 
ajSeqrefAppendTitle(AjPSeqRef ref,const AjPStr str)9507 AjBool ajSeqrefAppendTitle(AjPSeqRef ref, const AjPStr str)
9508 {
9509     if(ajStrGetLen(ref->Title))
9510 	ajStrAppendK(&ref->Title, ' ');
9511 
9512     ajStrAppendS(&ref->Title, str);
9513 
9514     return ajTrue;
9515 }
9516 
9517 
9518 
9519 
9520 /* @func ajSeqrefAppendXref ***************************************************
9521 **
9522 ** Append to the Cross reference string of a citation
9523 **
9524 ** @param [u] ref [AjPSeqRef] Sequence citation object
9525 ** @param [r] str [const AjPStr] Xref string
9526 ** @return [AjBool] True on success
9527 **
9528 ** @release 5.0.0
9529 ******************************************************************************/
9530 
ajSeqrefAppendXref(AjPSeqRef ref,const AjPStr str)9531 AjBool ajSeqrefAppendXref(AjPSeqRef ref, const AjPStr str)
9532 {
9533     if(ajStrGetLen(ref->Xref))
9534     {
9535 	if(ajStrGetCharLast(ref->Xref) == '.')
9536 	    ajStrAppendK(&ref->Xref, '\n');
9537 	else
9538 	    ajStrAppendK(&ref->Xref, ' ');
9539     }
9540 
9541     ajStrAppendS(&ref->Xref, str);
9542 
9543     return ajTrue;
9544 }
9545 
9546 
9547 
9548 
9549 /* @func ajSeqrefFmtAuthorsEmbl ***********************************************
9550 **
9551 ** Return the Authors string of a citation in EMBL format
9552 **
9553 ** @param [r] ref [const AjPSeqRef] Sequence citation object
9554 ** @param [w] Pdest [AjPStr*] Authors string in EMBL format
9555 ** @return [AjBool] True if author list exists
9556 **
9557 ** @release 5.0.0
9558 ******************************************************************************/
9559 
ajSeqrefFmtAuthorsEmbl(const AjPSeqRef ref,AjPStr * Pdest)9560 AjBool ajSeqrefFmtAuthorsEmbl(const AjPSeqRef ref, AjPStr* Pdest)
9561 {
9562     ajStrAssignClear(Pdest);
9563 
9564     if(!ref->Authors)
9565 	return ajFalse;
9566 
9567     ajStrAssignS(Pdest, ref->Authors);
9568 
9569     return ajTrue;
9570 }
9571 
9572 
9573 
9574 
9575 /* @func ajSeqrefFmtAuthorsGb *************************************************
9576 **
9577 ** Return the Authors string of a citation in Genbank format
9578 **
9579 ** @param [r] ref [const AjPSeqRef] Sequence citation object
9580 ** @param [w] Pdest [AjPStr*] Authors string in Genbank format
9581 ** @return [AjBool] True if author list exists
9582 **
9583 ** @release 5.0.0
9584 ******************************************************************************/
9585 
ajSeqrefFmtAuthorsGb(const AjPSeqRef ref,AjPStr * Pdest)9586 AjBool ajSeqrefFmtAuthorsGb(const AjPSeqRef ref, AjPStr* Pdest)
9587 {
9588     ajlong i;
9589     ajint imax;
9590     char* cp;
9591 
9592     ajStrAssignClear(Pdest);
9593 
9594     if(!ref->Authors)
9595 	return ajFalse;
9596 
9597     ajStrAssignS(Pdest, ref->Authors);
9598     i = ajStrFindlastC(*Pdest, ", "); /* replace , with and */
9599 
9600     if(i != -1)
9601     {
9602 	ajStrCutRange(Pdest, i, i);
9603 	ajStrInsertC(Pdest, i, " and");
9604     }
9605 
9606     cp = ajStrGetuniquePtr(Pdest);
9607     imax=ajStrGetLen(*Pdest)-2;
9608 
9609     for(i=0;i<imax;i++)
9610     {
9611 	if(*cp == ' ' && cp[2] == '.' && isalpha((int)cp[1]))
9612 	    *cp = ',';
9613 
9614 	cp++;
9615     }
9616 
9617     return ajTrue;
9618 }
9619 
9620 
9621 
9622 
9623 /* @func ajSeqrefFmtLocationEmbl **********************************************
9624 **
9625 ** Return the location string of a citation in EMBL format
9626 **
9627 ** @param [r] ref [const AjPSeqRef] Sequence citation object
9628 ** @param [w] Pdest [AjPStr*] Authors string in EMBL format
9629 ** @return [AjBool] True if author list exists
9630 **
9631 ** @release 5.0.0
9632 ******************************************************************************/
9633 
ajSeqrefFmtLocationEmbl(const AjPSeqRef ref,AjPStr * Pdest)9634 AjBool ajSeqrefFmtLocationEmbl(const AjPSeqRef ref, AjPStr* Pdest)
9635 {
9636     ajStrAssignClear(Pdest);
9637 
9638     if(!ref->Location)
9639 	return ajFalse;
9640 
9641     ajStrAssignS(Pdest, ref->Location);
9642 
9643     return ajTrue;
9644 }
9645 
9646 
9647 
9648 
9649 /* @func ajSeqrefFmtLocationGb ************************************************
9650 **
9651 ** Return the location string of a citation in Genbank format
9652 **
9653 ** @param [r] ref [const AjPSeqRef] Sequence citation object
9654 ** @param [w] Pdest [AjPStr*] Authors string in Genbank format
9655 ** @return [AjBool] True if author list exists
9656 **
9657 ** @release 5.0.0
9658 ******************************************************************************/
9659 
ajSeqrefFmtLocationGb(const AjPSeqRef ref,AjPStr * Pdest)9660 AjBool ajSeqrefFmtLocationGb(const AjPSeqRef ref, AjPStr* Pdest)
9661 {
9662     ajStrAssignClear(Pdest);
9663 
9664     if(!ref->Location)
9665 	return ajFalse;
9666 
9667     ajStrAssignS(Pdest, ref->Location);
9668 
9669     ajStrExchangeCC(Pdest, "):", "), ");
9670     ajStrExchangeCC(Pdest, "(", "\1");
9671     ajStrExchangeCC(Pdest, "\1", " (");
9672     ajStrExchangeCC(Pdest, "  (", " (");
9673 
9674     return ajTrue;
9675 }
9676 
9677 
9678 
9679 
9680 /* @func ajSeqrefFmtTitleGb ***************************************************
9681 **
9682 ** Return the title string of a citation in Genbank format
9683 **
9684 ** @param [r] ref [const AjPSeqRef] Sequence citation object
9685 ** @param [w] Pdest [AjPStr*] Authors string in Genbank format
9686 ** @return [AjBool] True if author list exists
9687 **
9688 ** @release 5.0.0
9689 ******************************************************************************/
9690 
ajSeqrefFmtTitleGb(const AjPSeqRef ref,AjPStr * Pdest)9691 AjBool ajSeqrefFmtTitleGb(const AjPSeqRef ref, AjPStr* Pdest)
9692 {
9693     ajStrAssignClear(Pdest);
9694 
9695     if(!ajStrGetLen(ref->Title))
9696     {
9697 	if(ajStrMatchC(ref->Loctype, "submission"))
9698 	{
9699 	    ajStrAssignC(Pdest, "Direct Submission");
9700 
9701 	    return ajTrue;
9702 	}
9703 
9704 	return ajFalse;
9705     }
9706 
9707     ajStrAssignS(Pdest, ref->Title);
9708 
9709     return ajTrue;
9710 }
9711 
9712 
9713 
9714 
9715 /* @func ajSeqrefSetAuthors ***************************************************
9716 **
9717 ** Set the Authors string of a citation
9718 **
9719 ** @param [u] ref [AjPSeqRef] Sequence citation object
9720 ** @param [r] str [const AjPStr] Authors string
9721 ** @return [AjBool] True on success
9722 **
9723 ** @release 5.0.0
9724 ******************************************************************************/
9725 
ajSeqrefSetAuthors(AjPSeqRef ref,const AjPStr str)9726 AjBool ajSeqrefSetAuthors(AjPSeqRef ref, const AjPStr str)
9727 {
9728     ajStrAssignS(&ref->Authors, str);
9729 
9730     return ajTrue;
9731 }
9732 
9733 
9734 
9735 
9736 /* @func ajSeqrefSetComment ***************************************************
9737 **
9738 ** Set the Comment string of a citation
9739 **
9740 ** @param [u] ref [AjPSeqRef] Sequence citation object
9741 ** @param [r] str [const AjPStr] Comment string
9742 ** @return [AjBool] True on success
9743 **
9744 ** @release 5.0.0
9745 ******************************************************************************/
9746 
ajSeqrefSetComment(AjPSeqRef ref,const AjPStr str)9747 AjBool ajSeqrefSetComment(AjPSeqRef ref, const AjPStr str)
9748 {
9749     ajStrAssignS(&ref->Comment, str);
9750 
9751     return ajTrue;
9752 }
9753 
9754 
9755 
9756 
9757 /* @func ajSeqrefSetGroupname *************************************************
9758 **
9759 ** Set the group name string of a citation
9760 **
9761 ** @param [u] ref [AjPSeqRef] Sequence citation object
9762 ** @param [r] str [const AjPStr] Groupname string
9763 ** @return [AjBool] True on success
9764 **
9765 ** @release 5.0.0
9766 ******************************************************************************/
9767 
ajSeqrefSetGroupname(AjPSeqRef ref,const AjPStr str)9768 AjBool ajSeqrefSetGroupname(AjPSeqRef ref, const AjPStr str)
9769 {
9770     ajStrAssignS(&ref->Groupname, str);
9771 
9772     return ajTrue;
9773 }
9774 
9775 
9776 
9777 
9778 /* @func ajSeqrefSetLocation **************************************************
9779 **
9780 ** Set the location string of a citation
9781 **
9782 ** @param [u] ref [AjPSeqRef] Sequence citation object
9783 ** @param [r] str [const AjPStr] Location string
9784 ** @return [AjBool] True on success
9785 **
9786 ** @release 5.0.0
9787 ******************************************************************************/
9788 
ajSeqrefSetLocation(AjPSeqRef ref,const AjPStr str)9789 AjBool ajSeqrefSetLocation(AjPSeqRef ref, const AjPStr str)
9790 {
9791     ajStrAssignS(&ref->Location, str);
9792     ajSeqrefSetLoctype(ref, str);
9793 
9794     return ajTrue;
9795 }
9796 
9797 
9798 
9799 
9800 /* @func ajSeqrefSetLoctype ***************************************************
9801 **
9802 ** Set the location type of a citation
9803 **
9804 ** @param [u] ref [AjPSeqRef] Sequence citation object
9805 ** @param [r] str [const AjPStr] Location string
9806 ** @return [AjBool] True on success
9807 **
9808 ** @release 5.0.0
9809 ******************************************************************************/
9810 
ajSeqrefSetLoctype(AjPSeqRef ref,const AjPStr str)9811 AjBool ajSeqrefSetLoctype(AjPSeqRef ref, const AjPStr str)
9812 {
9813     if(ajStrPrefixC(str, "Submitted "))
9814 	ajStrAssignC(&ref->Loctype, "submission");
9815     else if(ajStrPrefixC(str, "(in) "))
9816 	ajStrAssignC(&ref->Loctype, "book");
9817     else if(ajStrPrefixC(str, "(er) "))
9818 	ajStrAssignC(&ref->Loctype, "electronic");
9819     else if(ajStrPrefixC(str, "Thesis "))
9820 	ajStrAssignC(&ref->Loctype, "thesis");
9821     else if(ajStrPrefixC(str, "Patent "))
9822 	ajStrAssignC(&ref->Loctype, "patent");
9823     else if(ajStrPrefixC(str, "(misc) "))
9824 	ajStrAssignC(&ref->Loctype, "misc");
9825     else
9826 	ajStrAssignC(&ref->Loctype, "journal");
9827 
9828     return ajTrue;
9829 }
9830 
9831 
9832 
9833 
9834 /* @func ajSeqrefSetPosition **************************************************
9835 **
9836 ** Set the position string of a citation
9837 **
9838 ** @param [u] ref [AjPSeqRef] Sequence citation object
9839 ** @param [r] str [const AjPStr] pPosition string
9840 ** @return [AjBool] True on success
9841 **
9842 ** @release 5.0.0
9843 ******************************************************************************/
9844 
ajSeqrefSetPosition(AjPSeqRef ref,const AjPStr str)9845 AjBool ajSeqrefSetPosition(AjPSeqRef ref, const AjPStr str)
9846 {
9847     ajStrAssignS(&ref->Position, str);
9848 
9849     return ajTrue;
9850 }
9851 
9852 
9853 
9854 
9855 /* @func ajSeqrefSetTitle *****************************************************
9856 **
9857 ** Set the title string of a citation
9858 **
9859 ** @param [u] ref [AjPSeqRef] Sequence citation object
9860 ** @param [r] str [const AjPStr] Title string
9861 ** @return [AjBool] True on success
9862 **
9863 ** @release 5.0.0
9864 ******************************************************************************/
9865 
ajSeqrefSetTitle(AjPSeqRef ref,const AjPStr str)9866 AjBool ajSeqrefSetTitle(AjPSeqRef ref, const AjPStr str)
9867 {
9868     ajStrAssignS(&ref->Title, str);
9869 
9870     return ajTrue;
9871 }
9872 
9873 
9874 
9875 
9876 /* @func ajSeqrefSetXref ******************************************************
9877 **
9878 ** Set the cross reference string of a citation
9879 **
9880 ** @param [u] ref [AjPSeqRef] Sequence citation object
9881 ** @param [r] str [const AjPStr] Xref string
9882 ** @return [AjBool] True on success
9883 **
9884 ** @release 5.0.0
9885 ******************************************************************************/
9886 
ajSeqrefSetXref(AjPSeqRef ref,const AjPStr str)9887 AjBool ajSeqrefSetXref(AjPSeqRef ref, const AjPStr str)
9888 {
9889     ajStrAssignS(&ref->Xref, str);
9890 
9891     return ajTrue;
9892 }
9893 
9894 
9895 
9896 
9897 /* @func ajSeqrefSetnumNumber *************************************************
9898 **
9899 ** Sets the citation number
9900 **
9901 ** @param [u] ref [AjPSeqRef] Sequence citation object
9902 ** @param [r] num [ajuint] Citation number
9903 ** @return [AjBool] True on success
9904 **
9905 ** @release 5.0.0
9906 ******************************************************************************/
9907 
ajSeqrefSetnumNumber(AjPSeqRef ref,ajuint num)9908 AjBool ajSeqrefSetnumNumber(AjPSeqRef ref, ajuint num)
9909 {
9910     ref->Number = num;
9911 
9912     return ajTrue;
9913 }
9914 
9915 
9916 
9917 
9918 /* @func ajSeqrefStandard *****************************************************
9919 **
9920 ** Standardise internal representation of a sequence reference
9921 **
9922 ** @param [u] ref [AjPSeqRef] Sequence citation object
9923 ** @return [AjBool] True on success
9924 **
9925 ** @release 5.0.0
9926 ******************************************************************************/
9927 
ajSeqrefStandard(AjPSeqRef ref)9928 AjBool ajSeqrefStandard(AjPSeqRef ref)
9929 {
9930 
9931     if(ajStrGetCharLast(ref->Xref) == '.')
9932 	ajStrTrimEndC(&ref->Xref, ".");
9933 
9934     if(ajStrGetCharLast(ref->Location) == '.')
9935 	ajStrTrimEndC(&ref->Location, ".");
9936 
9937     if(ajStrGetCharLast(ref->Title) == '.')
9938 	ajStrTrimEndC(&ref->Title, ".");
9939 
9940     if(ajStrGetCharLast(ref->Title) == ';')
9941 	ajStrTrimEndC(&ref->Title, ";");
9942 
9943     ajStrQuoteStrip(&ref->Title);
9944 
9945     if(ajStrGetCharLast(ref->Authors) == ';')
9946 	ajStrTrimEndC(&ref->Authors, ";");
9947 
9948     return ajTrue;
9949 }
9950 
9951 
9952 
9953 
9954 /* @datasection [AjPList] Reference list operations ***************************8
9955 **
9956 ** Manipulating lists of sequence citations
9957 **
9958 ** @nam2rule Seqreflist
9959 **
9960 ******************************************************************************/
9961 
9962 
9963 
9964 
9965 /* @section Reference list operations *****************************************
9966 **
9967 ** Manipulating lists of sequence citations
9968 **
9969 ** @fdata [AjPList]
9970 ** @fcategory use
9971 **
9972 ** @nam3rule Clone Clone list of sequence citations
9973 **
9974 ** @argrule * src [const AjPList] List of sequence citation objects
9975 ** @argrule Clone dest [AjPList] Empty list to hold sequence citation objects
9976 **
9977 ** @valrule * [AjBool] True on success
9978 **
9979 ******************************************************************************/
9980 
9981 
9982 
9983 
9984 /* @func ajSeqreflistClone ****************************************************
9985 **
9986 ** Copy a list of citations to another list
9987 **
9988 ** @param [r] src [const AjPList] Source list of citations
9989 ** @param [w] dest [AjPList] Destination list of citations
9990 ** @return [AjBool] True on success
9991 **
9992 ** @release 5.0.0
9993 ******************************************************************************/
9994 
ajSeqreflistClone(const AjPList src,AjPList dest)9995 AjBool ajSeqreflistClone(const AjPList src, AjPList dest)
9996 {
9997     AjIList iter;
9998     AjPSeqRef refout = NULL;
9999     AjPSeqRef refin = NULL;
10000 
10001     if(ajListGetLength(dest))
10002 	return ajFalse;
10003 
10004     iter = ajListIterNewread(src);
10005 
10006     while ((refin = (AjPSeqRef) ajListIterGet(iter)))
10007     {
10008 	refout = ajSeqrefNewRef(refin);
10009 	ajListPushAppend(dest, refout);
10010     }
10011 
10012     ajListIterDel(&iter);
10013 
10014     return ajTrue;
10015 }
10016 
10017 
10018 
10019 
10020 /* @section element retrieval ************************************************
10021 **
10022 ** These functions return contents of a list of sequence cross-reference
10023 ** objects.
10024 **
10025 ** @fdata [AjPList]
10026 ** @fcategory use
10027 **
10028 ** @nam3rule Get return reference attributes
10029 ** @nam4rule GetXrefs Return cross-references
10030 **
10031 ** @argrule Get   src   [const AjPList] List of sequence citation object
10032 ** @argrule Xrefs Plist [AjPList*]      List of cross-reference objects
10033 **
10034 ** @valrule GetXrefs [ajuint] Number of cross-references returned
10035 **
10036 ******************************************************************************/
10037 
10038 
10039 
10040 
10041 /* @func ajSeqreflistGetXrefs *************************************************
10042 **
10043 ** Copy a cross-reference list
10044 **
10045 ** @param [r] src [const AjPList] Source cross-reference list
10046 ** @param [w] Plist [AjPList*] Target list,
10047 **                             created if it does not already exist
10048 ** @return [ajuint] number of cross-references copied
10049 **
10050 ** @release 6.2.0
10051 ******************************************************************************/
10052 
ajSeqreflistGetXrefs(const AjPList src,AjPList * Plist)10053 ajuint ajSeqreflistGetXrefs(const AjPList src, AjPList *Plist)
10054 {
10055     AjPStrTok handle = NULL;
10056     AjPStr token = NULL;
10057     AjPStr dbtoken = NULL;
10058     AjIList iter = NULL;
10059     ajulong oldnum = 0UL;
10060     AjPSeqRef tmpref = NULL;
10061     AjPSeqXref xref = NULL;
10062     AjPList list;
10063 
10064     if(!*Plist)
10065         *Plist = ajListNew();
10066 
10067     list = *Plist;
10068 
10069     oldnum = ajListGetLength(list);
10070     iter = ajListIterNewread(src);
10071     while(!ajListIterDone(iter))
10072     {
10073         tmpref = ajListIterGet(iter);
10074         if(!ajStrGetLen(tmpref->Xref))
10075             continue;
10076 
10077         ajStrTokenAssignC(&handle, tmpref->Xref, " =;\r\n");
10078 
10079         while (ajStrTokenNextParseC(handle, " =;\r\n", &dbtoken))
10080         {
10081             ajStrTokenNextParseC(handle, " ;\r\n", &token);
10082 
10083             if(ajStrGetCharLast(token) == '.')
10084                 ajStrCutEnd(&token, 1);
10085 
10086             if(!ajStrGetLen(dbtoken))
10087                 continue;
10088             if(!ajStrGetLen(token))
10089                 continue;
10090 
10091             if(ajStrMatchCaseC(dbtoken, "MEDLINE"))
10092             {
10093                 xref = ajSeqxrefNewDbC(token, "MEDLINE", XREF_RX);
10094                 ajListPushAppend(list, xref);
10095                 xref = NULL;
10096             }
10097             else if(ajStrMatchCaseC(dbtoken, "PubMed"))
10098             {
10099                 xref = ajSeqxrefNewDbC(token, "PubMed", XREF_RX);
10100                 ajListPushAppend(list, xref);
10101                 xref = NULL;
10102             }
10103             else if(ajStrMatchCaseC(dbtoken, "DOI"))
10104             {
10105                 xref = ajSeqxrefNewDbC(token, "DOI", XREF_RX);
10106                 ajListPushAppend(list, xref);
10107                 xref = NULL;
10108             }
10109             else if(ajStrMatchCaseC(dbtoken, "AGRICOLA"))
10110             {
10111                 xref = ajSeqxrefNewDbC(token, "AGRICOLA", XREF_RX);
10112                 ajListPushAppend(list, xref);
10113                 xref = NULL;
10114             }
10115             else
10116             {
10117                 xref = ajSeqxrefNewDbS(token, dbtoken, XREF_RX);
10118                 ajListPushAppend(list, xref);
10119                 xref = NULL;
10120             }
10121         }
10122     }
10123     ajListIterDel(&iter);
10124 
10125     ajStrTokenDel(&handle);
10126     ajStrDel(&dbtoken);
10127     ajStrDel(&token);
10128 
10129     return (ajuint) (ajListGetLength(list) - oldnum);
10130 }
10131 
10132 
10133 
10134 
10135 /* @datasection [AjPSeqRange] Sequence ranges **********************************
10136 **
10137 ** Functions handling sequence ranges
10138 **
10139 ** @nam2rule Seqrange
10140 **
10141 ******************************************************************************/
10142 
10143 
10144 
10145 
10146 /* @section Sequence range constructors ****************************************
10147 **
10148 ** @fdata [AjPSeqRange]
10149 ** @fcategory new
10150 **
10151 ** @nam3rule New Constructor
10152 ** @nam4rule NewRange Copy constructor
10153 ** @nam4rule NewValues Constructor with given values
10154 **
10155 ** @argrule Range range [const AjPSeqRange] Source range object
10156 ** @argrule Values pos [ajulong] Start position
10157 ** @argrule Values len [ajulong] Length
10158 ** @argrule Values qry [const AjPStr] Query
10159 **
10160 ** @valrule * [AjPSeqRange]
10161 **
10162 ******************************************************************************/
10163 
10164 
10165 
10166 
10167 /* @func ajSeqrangeNew ********************************************************
10168 **
10169 ** Constructor for empty range object
10170 **
10171 ** @return [AjPSeqRange] Empty sequence range object
10172 **
10173 ** @release 6.5.0
10174 ******************************************************************************/
10175 
ajSeqrangeNew(void)10176 AjPSeqRange ajSeqrangeNew(void)
10177 {
10178     AjPSeqRange ret;
10179     AJNEW0(ret);
10180 
10181     return ret;
10182 }
10183 
10184 
10185 
10186 
10187 /* @func ajSeqrangeNewRange ***************************************************
10188 **
10189 ** Constructor for copy of a range object
10190 **
10191 ** @param [r] range [const AjPSeqRange] Range object
10192 ** @return [AjPSeqRange] Copied range object
10193 **
10194 ** @release 6.5.0
10195 ******************************************************************************/
10196 
ajSeqrangeNewRange(const AjPSeqRange range)10197 AjPSeqRange ajSeqrangeNewRange(const AjPSeqRange range)
10198 {
10199     AjPSeqRange ret;
10200 
10201     AJNEW0(ret);
10202 
10203     if(!range)
10204 	return ret;
10205 
10206     ajStrAssignS(&ret->Query, range->Query);
10207     ret->Start = range->Start;
10208     ret->Length = range->Length;
10209 
10210     return ret;
10211 }
10212 
10213 
10214 
10215 
10216 /* @func ajSeqrangeNewValues **************************************************
10217 **
10218 ** Constructor for range with given values
10219 **
10220 ** @param [r] pos [ajulong] Start position
10221 ** @param [r] len [ajulong] Length
10222 ** @param [r] qry [const AjPStr] Query
10223 ** @return [AjPSeqRange] New range object
10224 **
10225 ** @release 6.5.0
10226 ******************************************************************************/
10227 
ajSeqrangeNewValues(ajulong pos,ajulong len,const AjPStr qry)10228 AjPSeqRange ajSeqrangeNewValues(ajulong pos, ajulong len, const AjPStr qry)
10229 {
10230     AjPSeqRange ret;
10231     AJNEW0(ret);
10232 
10233     ret->Start = pos;
10234     ret->Length = len;
10235 
10236     if(qry)
10237         ret->Query = ajStrNewS(qry);
10238 
10239     return ret;
10240 }
10241 
10242 
10243 
10244 
10245 /* @section destructors *******************************************************
10246 **
10247 ** Destruction destroys all internal data structures and frees the
10248 ** memory allocated for a sequence range object
10249 **
10250 ** @fdata [AjPSeqRange]
10251 ** @fcategory delete
10252 **
10253 ** @nam3rule Del Destroy (free) a range object
10254 **
10255 ** @argrule * Prange [AjPSeqRange*] Range object address
10256 **
10257 ** @valrule * [void]
10258 **
10259 ******************************************************************************/
10260 
10261 
10262 
10263 
10264 /* @func ajSeqrangeDel *********************************************************
10265 **
10266 ** Deletes a range object.
10267 **
10268 ** @param [d] Prange [AjPSeqRange*] Range object
10269 ** @return [void]
10270 **
10271 ** @release 6.5.0
10272 ** @@
10273 ******************************************************************************/
10274 
ajSeqrangeDel(AjPSeqRange * Prange)10275 void ajSeqrangeDel(AjPSeqRange* Prange)
10276 {
10277     AjPSeqRange srange;
10278 
10279     if(!Prange)
10280 	return;
10281 
10282     if(!*Prange)
10283 	return;
10284 
10285     srange = *Prange;
10286 
10287     ajStrDel(&srange->Query);
10288 
10289     AJFREE(*Prange);
10290 
10291     return;
10292 }
10293 
10294 
10295 
10296 
10297 /* @section modifiers *********************************************************
10298 **
10299 ** These functions update contents of a range object.
10300 **
10301 ** @fdata [AjPSeqRange]
10302 ** @fcategory modify
10303 **
10304 ** @nam3rule Set            Set data in a range object
10305 ** @nam4rule SetQuery       Set query of a range object
10306 ** @nam4rule SetRange       Set Start and length of a range object
10307 **
10308 ** @argrule Set    range [AjPSeqRange] Range object
10309 **
10310 ** @argrule Query    qry [const AjPStr] Query
10311 ** @argrule Range    pos [ajulong] Start position
10312 ** @argrule Range    len [ajulong] Length
10313 **
10314 ** @valrule * [AjBool] True on success
10315 ******************************************************************************/
10316 
10317 
10318 
10319 
10320 /* @func ajSeqrangeSetQuery ***************************************************
10321 **
10322 ** Set the query of a range
10323 **
10324 ** @param [u] range [AjPSeqRange] Range object
10325 ** @param [r] qry [const AjPStr] Query string
10326 ** @return [AjBool] True on success
10327 **
10328 ** @release 6.1.0
10329 ******************************************************************************/
10330 
ajSeqrangeSetQuery(AjPSeqRange range,const AjPStr qry)10331 AjBool ajSeqrangeSetQuery(AjPSeqRange range, const AjPStr qry)
10332 {
10333     ajStrAssignS(&range->Query, qry);
10334 
10335     return ajTrue;
10336 }
10337 
10338 
10339 
10340 
10341 /* @func ajSeqrangeSetRange ***************************************************
10342 **
10343 ** Set the start and length of a range
10344 **
10345 ** @param [u] range [AjPSeqRange] Range object
10346 ** @param [r] pos [ajulong] Start position
10347 ** @param [r] len [ajulong] Length
10348 ** @return [AjBool] True on success
10349 **
10350 ** @release 6.5.0
10351 ******************************************************************************/
10352 
ajSeqrangeSetRange(AjPSeqRange range,ajulong pos,ajulong len)10353 AjBool ajSeqrangeSetRange(AjPSeqRange range, ajulong pos, ajulong len)
10354 {
10355     range->Start = pos;
10356     range->Length = len;
10357 
10358     return ajTrue;
10359 }
10360 
10361 
10362 
10363 
10364 /* @datasection [AjPStr] string tests *****************************************
10365 **
10366 ** Functions handling strings for specialist sequence-related tests
10367 **
10368 ** @nam2rule Seqtest
10369 **
10370 ******************************************************************************/
10371 
10372 
10373 
10374 
10375 /* @section string tests ******************************************************
10376 **
10377 ** @fdata [AjPStr]
10378 ** @fcategory use
10379 **
10380 ** @nam3rule Is Test string matches some type
10381 ** @nam4rule IsAccession Tests string is an accession number for any
10382 **                       known database
10383 ** @nam4rule IsSeqversion Tests string is a sequence version number for any
10384 **                       known database
10385 **
10386 ** @argrule * str [const AjPStr] String value to test
10387 **
10388 ** @valrule IsAccession [AjBool] True if string passes the test
10389 ** @valrule IsSeqversion [const AjPStr] Accession number part of the version
10390 ******************************************************************************/
10391 
10392 
10393 
10394 
10395 /* @func ajSeqtestIsAccession *************************************************
10396 **
10397 ** Tests whether a string is a potential sequence accession number.
10398 ** The current definition is one or two alpha characters,
10399 ** then a possible underscore (for REFSEQ accessions),
10400 ** followed by a string of digits and a minimum length of 6.
10401 **
10402 ** Revised for new Swiss-Prot accession number format AnXXXn
10403 **
10404 ** @param [r] str [const AjPStr] String to be tested
10405 ** @return [AjBool] ajTrue if the string is a possible accession number.
10406 **
10407 ** @release 4.1.0
10408 ** @@
10409 ******************************************************************************/
10410 
ajSeqtestIsAccession(const AjPStr str)10411 AjBool ajSeqtestIsAccession(const AjPStr str)
10412 {
10413     ajint i;
10414     const char *cp;
10415 
10416     if(!str)
10417 	return ajFalse;
10418 
10419     i = ajStrGetLen(str);
10420 
10421     if(i < 6)
10422 	return ajFalse;
10423 
10424     cp = ajStrGetPtr(str);
10425 
10426     /* must have an alphabetic start */
10427 
10428     if(!isalpha((ajint)*cp++))
10429 	return ajFalse;
10430 
10431     /* two choices for the next character */
10432 
10433     if(isalpha((ajint)*cp))
10434     {					/* EMBL/GenBank AAnnnnnn */
10435 	cp++;
10436 
10437 	if(*cp == '_') cp++;		/* REFSEQ NM_nnnnnn */
10438 
10439 	while(*cp)
10440 	    if(isdigit((ajint)*cp))
10441 		++cp;
10442 	    else
10443 		return ajFalse;
10444 
10445 	return ajTrue;
10446     }
10447     else if(isdigit((ajint)*cp))
10448     {					/* EMBL/GenBank old Annnnn */
10449 	cp++;				/* or SWISS AnXXXn */
10450 
10451 	for(i=0; i<3; i++)
10452 	    if(isalpha((ajint)*cp) || isdigit((ajint)*cp))
10453 		cp++;
10454 	    else
10455 		return ajFalse;
10456 
10457 	if(!isdigit((ajint)*cp))
10458 	    return ajFalse;
10459 
10460 	while(*cp)
10461 	    if(isdigit((ajint)*cp))
10462 		++cp;
10463 	    else
10464 		return ajFalse;
10465 
10466 	return ajTrue;
10467     }
10468 
10469     return ajFalse;
10470 }
10471 
10472 
10473 
10474 
10475 /* @func ajSeqtestIsSeqversion ************************************************
10476 **
10477 ** Tests whether a string is a potential sequence version number.
10478 ** The current definition is an accession number, followed by a dot and
10479 ** a number.
10480 **
10481 ** Revised for new Swiss-Prot accession number format AnXXXn
10482 ** Revised for REFSEQ accession number format NM_nnnnnn
10483 ** Revised for protein ID format XXXnnnnnn.nnn
10484 **
10485 ** @param [r] str [const AjPStr] String to be tested
10486 ** @return [const AjPStr] accession number part of the string if successful
10487 **
10488 ** @release 4.1.0
10489 ** @@
10490 ******************************************************************************/
10491 
ajSeqtestIsSeqversion(const AjPStr str)10492 const AjPStr ajSeqtestIsSeqversion(const AjPStr str)
10493 {
10494     ajint i;
10495     const char *cp;
10496     AjBool dot = ajFalse;		/* have we found the '.' */
10497     AjBool v = 0;	   /* number of digits of version after '.' */
10498 
10499     if(!str)
10500 	return NULL;
10501 
10502     i = ajStrGetLen(str);
10503 
10504     if(i < 8)
10505 	return NULL;
10506 
10507     cp = ajStrGetPtr(str);
10508 
10509     /* must have an alphabetic start */
10510 
10511     if(!isalpha((ajint)*cp))
10512 	return NULL;
10513 
10514     ajStrAssignResC(&seqVersionAccnum, 12, "");
10515     ajStrAppendK(&seqVersionAccnum, *cp++);
10516 
10517     /* two choices for the next character */
10518 
10519     if(isalpha((ajint)*cp))
10520     {					/* EMBL/GenBank AAnnnnnn */
10521         ajStrAppendK(&seqVersionAccnum, *cp);
10522 	cp++;
10523 
10524 	if(isalpha((ajint)*cp))
10525 	{			/* EMBL/GenBank protein_id AAAnnnnnn */
10526 	    ajStrAppendK(&seqVersionAccnum, *cp);
10527 	    cp++;
10528 	}
10529 	else if(*cp == '_')		/* REFSEQ NM_nnnnnn */
10530 	{
10531 	    ajStrAppendK(&seqVersionAccnum, *cp);
10532 	    cp++;
10533 	}
10534 	while(*cp)		      /* optional trailing .version */
10535 	{
10536 	    if(isdigit((ajint)*cp) || *cp=='.')
10537 	    {
10538 		if(*cp == '.')
10539 		{
10540 		    if(dot)
10541 			return NULL;	/* one '.' only */
10542 		    dot = ajTrue;
10543 		}
10544 		else
10545 		{
10546 		    if(dot)
10547 			v++;
10548 		    else
10549 			ajStrAppendK(&seqVersionAccnum, *cp);
10550 		}
10551 		++cp;
10552 	    }
10553 	    else
10554 		return NULL;
10555 	}
10556 
10557 	if(v)
10558 	    return seqVersionAccnum;
10559 	else
10560 	    return NULL;
10561     }
10562     else if(isdigit((ajint)*cp))
10563     {					/* EMBL/GenBank old Annnnn */
10564 	/* or SWISS AnXXXn */
10565         ajStrAppendK(&seqVersionAccnum, *cp);
10566 	cp++;
10567 
10568 	for(i=0; i<3; i++)
10569 	    if(isalpha((ajint)*cp) || isdigit((ajint)*cp))
10570 	    {
10571 	        ajStrAppendK(&seqVersionAccnum, *cp);
10572 		cp++;
10573 	    }
10574 	    else
10575 		return NULL;
10576 
10577 	if(!isdigit((ajint)*cp))
10578 	    return NULL;
10579 
10580 	while(*cp)		      /* optional trailing .version */
10581 	{
10582 	    if(isdigit((ajint)*cp) || *cp=='.')
10583 	    {
10584 		if(*cp == '.')
10585 		{
10586 		    if(dot)
10587 			return NULL; /* one '.' only */
10588 		    dot = ajTrue;
10589 		}
10590 		else
10591 		{
10592 		    if(dot)
10593 			v++;
10594 		    else
10595 			ajStrAppendK(&seqVersionAccnum, *cp);
10596 		}
10597 		++cp;
10598 	    }
10599 	    else
10600 		return NULL;
10601 	}
10602 
10603 	if(v)
10604 	    return seqVersionAccnum;
10605 	else
10606 	    return NULL;
10607     }
10608 
10609     return NULL;
10610 }
10611 
10612 
10613 
10614 
10615 /* @datasection [AjPStr] string sequences *************************************
10616 **
10617 ** Handles a string as a sequence
10618 **
10619 ** Example uses are in sequence output object processing
10620 **
10621 ** @nam2rule Seqstr
10622 **
10623 ******************************************************************************/
10624 
10625 
10626 
10627 
10628 /* @section string properties
10629 **
10630 ** @fdata [AjPStr]
10631 ** @fcategory use
10632 **
10633 ** @nam3rule Calc Calculate sequence properties
10634 ** @nam4rule CalcMolwt Calculate molecular weight of a protein
10635 ** @nam3rule Count Count statistics over a sequence
10636 ** @nam4rule CountGaps Count gap characters
10637 **
10638 ** @argrule * seq [const AjPStr] Sequence string to be processed
10639 **
10640 ** @valrule CalcMolwt [float] Molecular weight
10641 ** @valrule CountGaps [ajuint] Number of gap characters
10642 ******************************************************************************/
10643 
10644 
10645 
10646 
10647 /* @func ajSeqstrCalcMolwt ****************************************************
10648 **
10649 ** Calculates the molecular weight of a protein sequence
10650 ** using average molecular weights
10651 **
10652 ** @param [r] seq [const AjPStr] Sequence
10653 ** @return [float] Molecular weight.
10654 **
10655 ** @release 4.0.0
10656 ** @@
10657 ******************************************************************************/
10658 
ajSeqstrCalcMolwt(const AjPStr seq)10659 float ajSeqstrCalcMolwt(const AjPStr seq)
10660 {
10661     /* source: www.expasy.org/tools/findmod/findmod_masses.html */
10662     static double aa[26] =
10663     {
10664         89.0894,  132.6068,  121.1494,  133.0992, /* A-D */
10665        147.1261,  165.1872,   75.0625,  155.1517, /* E-H */
10666        131.1700,  131.1700,  146.1847,  131.1700, /* I-L */
10667        149.2032,  132.1144,  255.3124,  115.1273, /* M-P */
10668        146.1413,  174.1981,  105.0888,  119.1157, /* Q-T */
10669        168.0494,  117.1432,  204.2238,  136.8966, /* U-X */
10670        181.1866,  146.6337                        /* Y-Z */
10671     };
10672     double mw;
10673     ajint i;
10674     const char* cp;
10675 
10676     cp = ajStrGetPtr(seq);
10677     mw = (double) 18.01057;
10678 
10679     while(*cp)
10680     {
10681         if(*cp == '-')
10682         {
10683             cp++;
10684             continue;
10685         }
10686 
10687 	i = toupper((ajint) *cp)-'A';
10688 
10689 	if(i > 25 || i < 0)
10690 	{
10691 	    ajDebug("seqMW bad character '%c' %d\n", *cp, *cp);
10692 	    i = 'X' - 'A';
10693 	}
10694 
10695 	mw += (double) aa[i] - (double) 18.01057;
10696 	cp++;
10697     }
10698 
10699     ajDebug("seqMW calculated %.2f\n", mw);
10700 
10701     return (float) mw;
10702 }
10703 
10704 
10705 
10706 
10707 /* @func ajSeqstrCountGaps ****************************************************
10708 **
10709 ** Complements but does not reverse a nucleotide sequence provided as a string.
10710 **
10711 ** @param [r] seq [const AjPStr] Sequence as a string.
10712 **
10713 ** @return [ajuint] Number of gap characters
10714 **
10715 ** @release 4.1.0
10716 ******************************************************************************/
10717 
ajSeqstrCountGaps(const AjPStr seq)10718 ajuint ajSeqstrCountGaps(const AjPStr seq)
10719 {
10720     ajuint ret = 0;
10721 
10722     static char testchars[] = "-~.? "; /* all known gap characters */
10723     char *testgap;
10724 
10725     testgap = testchars;
10726 
10727     while(*testgap)
10728     {
10729       ret += (ajuint) ajStrCalcCountK(seq, *testgap);
10730 	testgap++;
10731     }
10732 
10733     return ret;
10734 }
10735 
10736 
10737 
10738 
10739 /* @section string processing
10740 **
10741 ** @fdata [AjPStr]
10742 ** @fcategory modify
10743 **
10744 ** @nam3rule Complement Complement a sequence but do not reverse it
10745 ** @nam3rule Reverse Reverse complement a sequence
10746 **
10747 ** @argrule  * Pseq [AjPStr*] Sequence string to be processed
10748 **
10749 ** @valrule * [void]
10750 ******************************************************************************/
10751 
10752 
10753 
10754 
10755 /* @func ajSeqstrComplement ***************************************************
10756 **
10757 ** Complements but does not reverse a nucleotide sequence provided as a string.
10758 **
10759 ** @param [u] Pseq [AjPStr*] Sequence as a string.
10760 ** @return [void]
10761 **
10762 ** @release 4.1.0
10763 ** @@
10764 ******************************************************************************/
10765 
ajSeqstrComplement(AjPStr * Pseq)10766 void ajSeqstrComplement(AjPStr* Pseq)
10767 {
10768     char *cp;
10769 
10770     cp = ajStrGetuniquePtr(Pseq);
10771 
10772     while(*cp)
10773     {
10774 	*cp = ajBaseAlphacharComp(*cp);
10775 	cp++;
10776     }
10777 
10778     return;
10779 }
10780 
10781 
10782 
10783 
10784 /* @func ajSeqstrReverse ******************************************************
10785 **
10786 ** Reverses and complements a nucleotide sequence provided as a string.
10787 **
10788 ** @param [u] Pseq [AjPStr*] Sequence as a string.
10789 ** @return [void]
10790 **
10791 ** @release 4.0.0
10792 ** @@
10793 ******************************************************************************/
10794 
ajSeqstrReverse(AjPStr * Pseq)10795 void ajSeqstrReverse(AjPStr* Pseq)
10796 {
10797     char *cp;
10798     char *cq;
10799     char tmp;
10800 
10801     cp = ajStrGetuniquePtr(Pseq);
10802     cq = cp + ajStrGetLen(*Pseq) - 1;
10803 
10804     while(cp < cq)
10805     {
10806 	tmp = ajBaseAlphacharComp(*cp);
10807 	*cp = ajBaseAlphacharComp(*cq);
10808 	*cq = tmp;
10809 	cp++;
10810 	cq--;
10811     }
10812 
10813     if(cp == cq)
10814 	*cp = ajBaseAlphacharComp(*cp);
10815 
10816     return;
10817 }
10818 
10819 
10820 
10821 
10822 /* @datasection [AjPStr] Sequence entry classes *******************************
10823 **
10824 ** Sequence entry class vocabularies
10825 **
10826 ** @nam2rule Seqcls
10827 **
10828 ******************************************************************************/
10829 
10830 
10831 
10832 
10833 /* @section assignment ********************************************************
10834 **
10835 ** Assign values for sequence entry classes
10836 **
10837 ** @fdata [AjPStr]
10838 ** @fcategory assign
10839 **
10840 ** @nam3rule Set Assign value
10841 ** @nam4rule Embl Assign with an EMBL class name
10842 ** @nam4rule Gb   Assign with a GenBank class name
10843 **
10844 ** @argrule Set Pcls [AjPStr*] Target sequence class string
10845 ** @argrule Embl clsembl [const AjPStr] EMBL class name
10846 ** @argrule Gb   clsgb   [const AjPStr] Genbank class name
10847 **
10848 ** @valrule * [AjBool] True on success
10849 **
10850 ******************************************************************************/
10851 
10852 
10853 
10854 
10855 /* @func ajSeqclsSetEmbl ******************************************************
10856 **
10857 ** Sets the internal entry class for a sequence
10858 **
10859 ** @param [u] Pcls [AjPStr*] Internal entry class name
10860 ** @param [r] clsembl [const AjPStr] EMBL database entry class
10861 ** @return [AjBool] True if a known type
10862 **
10863 ** @release 5.0.0
10864 ******************************************************************************/
10865 
ajSeqclsSetEmbl(AjPStr * Pcls,const AjPStr clsembl)10866 AjBool ajSeqclsSetEmbl(AjPStr* Pcls, const AjPStr clsembl)
10867 {
10868     static AjBool called = AJFALSE;
10869     const AjPStr clsname = NULL;
10870 
10871     if(!called)
10872     {
10873 	seqclsInit();
10874 	called = ajTrue;
10875     }
10876 
10877     clsname = ajTablestrFetchS(seqTableClsEmbl, clsembl);
10878 
10879     if(!clsname)
10880 	return ajFalse;
10881 
10882     ajStrAssignS(Pcls, clsname);
10883 
10884     return ajTrue;
10885 
10886 }
10887 
10888 
10889 
10890 
10891 /* @func ajSeqclsSetGb ********************************************************
10892 **
10893 ** Sets the internal entry class for a sequence
10894 **
10895 ** @param [u] Pcls [AjPStr*] Internal entry class name
10896 ** @param [r] clsgb [const AjPStr] Genbank database entry class
10897 ** @return [AjBool] True if a known type
10898 **
10899 ** @release 5.0.0
10900 ******************************************************************************/
10901 
ajSeqclsSetGb(AjPStr * Pcls,const AjPStr clsgb)10902 AjBool ajSeqclsSetGb(AjPStr* Pcls, const AjPStr clsgb)
10903 {
10904     static AjBool called = AJFALSE;
10905     const AjPStr clsname = NULL;
10906 
10907     if(!called)
10908     {
10909 	seqclsInit();
10910 	called = ajTrue;
10911     }
10912 
10913     clsname = ajTablestrFetchS(seqTableClsGb, clsgb);
10914 
10915     if(!clsname)
10916 	return ajFalse;
10917 
10918     ajStrAssignS(Pcls, clsname);
10919 
10920     return ajTrue;
10921 
10922 }
10923 
10924 
10925 
10926 
10927 /* @section retrieval ********************************************************
10928 **
10929 ** Return values for sequence entry class
10930 **
10931 ** @fdata [AjPStr]
10932 ** @fcategory use
10933 **
10934 ** @nam3rule Get Retrieve value
10935 ** @nam4rule Embl Retrieve as an EMBL class name
10936 ** @nam4rule Gb   Retrieve as a GenBank class name
10937 **
10938 ** @argrule Get cls [const AjPStr] Internal sequence class string
10939 **
10940 ** @valrule * [const char*] Databank-specific class name
10941 **
10942 ******************************************************************************/
10943 
10944 
10945 
10946 
10947 /* @func ajSeqclsGetEmbl ******************************************************
10948 **
10949 ** Returns the EMBL entry class for a sequence
10950 **
10951 ** @param [r] cls [const AjPStr] Internal entry class name
10952 ** @return [const char*] EMBL entry class name
10953 **
10954 ** @release 5.0.0
10955 ******************************************************************************/
10956 
ajSeqclsGetEmbl(const AjPStr cls)10957 const char* ajSeqclsGetEmbl(const AjPStr cls)
10958 {
10959     static AjBool called = AJFALSE;
10960     const SeqOClass *clsdef = NULL;
10961 
10962     if(!called)
10963     {
10964 	seqclsInit();
10965 	called = ajTrue;
10966     }
10967 
10968     ajDebug("ajSeqclsGetEmbl '%S'\n", cls);
10969 
10970     if(ajStrGetLen(cls))
10971 	clsdef = ajTableFetchS(seqTableCls, cls);
10972 
10973     if(!clsdef)
10974 	clsdef = ajTableFetchS(seqTableCls, seqClassDef);
10975 
10976     if(!clsdef)
10977 	return ajStrGetPtr(seqClassDef);
10978 
10979     ajDebug("ajSeqclsGetEmbl '%S' => '%s'\n",
10980 	    cls, clsdef->Embl);
10981 
10982     return clsdef->Embl;
10983 
10984 }
10985 
10986 
10987 
10988 
10989 /* @func ajSeqclsGetGb ********************************************************
10990 **
10991 ** Returns the GenBank entry class for a sequence
10992 **
10993 ** @param [r] cls [const AjPStr] Internal entry class name
10994 ** @return [const char*] Genbank entry class name
10995 **
10996 ** @release 6.6.0
10997 ******************************************************************************/
10998 
ajSeqclsGetGb(const AjPStr cls)10999 const char* ajSeqclsGetGb(const AjPStr cls)
11000 {
11001     static AjBool called = AJFALSE;
11002     const SeqOClass *clsdef = NULL;
11003 
11004     if(!called)
11005     {
11006 	seqclsInit();
11007 	called = ajTrue;
11008     }
11009 
11010     ajDebug("ajSeqclsGetGb '%S'\n", cls);
11011 
11012     if(ajStrGetLen(cls))
11013 	clsdef = ajTableFetchS(seqTableCls, cls);
11014 
11015     if(!clsdef)
11016 	clsdef = ajTableFetchS(seqTableCls, seqClassDef);
11017 
11018     if(!clsdef)
11019 	return ajStrGetPtr(seqClassDef);
11020 
11021     ajDebug("ajSeqclsGetGb '%S' => '%s'\n",
11022 	    cls, clsdef->Genbank);
11023 
11024     return clsdef->Genbank;
11025 
11026 }
11027 
11028 
11029 
11030 
11031 /* @funcstatic seqclsInit *****************************************************
11032 **
11033 ** Initialises the tables of molecule types
11034 **
11035 ** @return [void]
11036 **
11037 ** @release 5.0.0
11038 ******************************************************************************/
11039 
seqclsInit(void)11040 static void seqclsInit(void)
11041 {
11042     ajuint i;
11043     AjPStr keystr = NULL;
11044     AjPStr valstr = NULL;
11045 
11046     if(seqTableCls)
11047 	return;
11048 
11049     seqTableCls = ajTablestrNewCase(16);
11050     seqTableClsEmbl = ajTablestrNewCase(16);
11051     seqTableClsDdbj = ajTablestrNewCase(16);
11052     seqTableClsGb = ajTablestrNewCase(16);
11053 
11054     seqClassDef = ajStrNewC(seqClass[0].Name);
11055 
11056     for(i=0;seqClass[i].Name;i++)
11057     {
11058 	keystr = ajStrNewC(seqClass[i].Name);
11059 
11060 	ajTablePut(seqTableCls, keystr, &seqClass[i]);
11061 
11062 	if(seqClass[i].Embl[0])
11063 	{
11064 	    valstr = ajStrNewC(seqClass[i].Embl);
11065 
11066 	    ajTablePut(seqTableClsEmbl, valstr, keystr);
11067 	}
11068 
11069 	if(seqClass[i].Ddbj[0])
11070 	{
11071 	    valstr = ajStrNewC(seqClass[i].Ddbj);
11072 
11073 	    ajTablePut(seqTableClsDdbj, valstr, keystr);
11074 	}
11075 
11076 	if(seqClass[i].Genbank[0])
11077 	{
11078 	    valstr = ajStrNewC(seqClass[i].Genbank);
11079 
11080 	    ajTablePut(seqTableClsGb, valstr, keystr);
11081 	}
11082     }
11083 
11084     return;
11085 }
11086 
11087 
11088 
11089 
11090 /* @datasection [AjPStr] Sequence entry divisions *****************************
11091 **
11092 ** Sequence entry division vocabularies
11093 **
11094 ** @nam2rule Seqdiv
11095 **
11096 ******************************************************************************/
11097 
11098 
11099 
11100 
11101 /* @section assignment ********************************************************
11102 **
11103 ** Assign values for sequence entry division
11104 **
11105 ** @fdata [AjPStr]
11106 ** @fcategory assign
11107 **
11108 ** @nam3rule Set Assign value
11109 ** @nam4rule Embl Assign with an EMBL division name
11110 ** @nam4rule Gb   Assign with a GenBank division name
11111 **
11112 ** @argrule Set Pdivi [AjPStr*] Target sequence division string
11113 ** @argrule Embl divembl [const AjPStr] EMBL division name
11114 ** @argrule Gb   divgb   [const AjPStr] Genbank division name
11115 **
11116 ** @valrule * [AjBool] True on success
11117 **
11118 ******************************************************************************/
11119 
11120 
11121 
11122 
11123 /* @func ajSeqdivSetEmbl ******************************************************
11124 **
11125 ** Sets the internal database division for a sequence
11126 **
11127 ** @param [u] Pdivi [AjPStr*] Internal database division
11128 ** @param [r] divembl [const AjPStr] EMBL database division
11129 ** @return [AjBool] True if a known type
11130 **
11131 ** @release 5.0.0
11132 ******************************************************************************/
11133 
ajSeqdivSetEmbl(AjPStr * Pdivi,const AjPStr divembl)11134 AjBool ajSeqdivSetEmbl(AjPStr* Pdivi, const AjPStr divembl)
11135 {
11136     static AjBool called = AJFALSE;
11137     const AjPStr divname = NULL;
11138 
11139     if(!called)
11140     {
11141 	seqdivInit();
11142 	called = ajTrue;
11143     }
11144 
11145     divname = ajTableFetchS(seqTableDivEmbl, divembl);
11146 
11147     if(!divname)
11148 	return ajFalse;
11149 
11150     ajStrAssignS(Pdivi, divname);
11151 
11152     return ajTrue;
11153 
11154 }
11155 
11156 
11157 
11158 
11159 /* @func ajSeqdivSetGb ********************************************************
11160 **
11161 ** Sets the internal database division for a sequence
11162 **
11163 ** @param [u] Pdivi [AjPStr*] Internal database division
11164 ** @param [r] divgb [const AjPStr] Genbank database division
11165 ** @return [AjBool] True if a known type
11166 **
11167 ** @release 5.0.0
11168 ******************************************************************************/
11169 
ajSeqdivSetGb(AjPStr * Pdivi,const AjPStr divgb)11170 AjBool ajSeqdivSetGb(AjPStr* Pdivi, const AjPStr divgb)
11171 {
11172     static AjBool called = AJFALSE;
11173     const AjPStr divname = NULL;
11174 
11175     if(!called)
11176     {
11177 	seqdivInit();
11178 	called = ajTrue;
11179     }
11180 
11181     divname = ajTableFetchS(seqTableDivGb, divgb);
11182 
11183     if(!divname)		/* Genbank mixes division and class */
11184 	divname = ajTableFetchS(seqTableClsGb, divgb);
11185 
11186     if(!divname)
11187 	return ajFalse;
11188 
11189     ajStrAssignS(Pdivi, divname);
11190 
11191     return ajTrue;
11192 
11193 }
11194 
11195 
11196 
11197 
11198 /* @section retrieval ********************************************************
11199 **
11200 ** Return values for sequence entry division
11201 **
11202 ** @fdata [AjPStr]
11203 ** @fcategory use
11204 **
11205 ** @nam3rule Get Retrieve value
11206 ** @nam4rule Embl Retrieve as an EMBL division name
11207 ** @nam4rule Gb   Retrieve as a GenBank division name
11208 **
11209 ** @argrule Get divi [const AjPStr] Internal sequence division string
11210 **
11211 ** @valrule * [const char*] Databank-specific division name
11212 **
11213 ******************************************************************************/
11214 
11215 
11216 
11217 
11218 /* @func ajSeqdivGetEmbl ******************************************************
11219 **
11220 ** Returns the EMBL database division for a sequence
11221 **
11222 ** @param [r] divi [const AjPStr] Internal database division
11223 ** @return [const char*] EMBL database division
11224 **
11225 ** @release 5.0.0
11226 ******************************************************************************/
11227 
ajSeqdivGetEmbl(const AjPStr divi)11228 const char* ajSeqdivGetEmbl(const AjPStr divi)
11229 {
11230     static AjBool called = AJFALSE;
11231     const SeqODivision *divdef = NULL;
11232 
11233     if(!called)
11234     {
11235 	seqdivInit();
11236 	called = ajTrue;
11237     }
11238 
11239     ajDebug("ajSeqdivGetEmbl '%S'\n", divi);
11240 
11241     if(ajStrGetLen(divi))
11242 	divdef = ajTableFetchS(seqTableDiv, divi);
11243 
11244     if(!divdef)
11245 	divdef = ajTableFetchS(seqTableDiv, seqDivisionDef);
11246 
11247     if(!divdef)
11248 	return ajStrGetPtr(seqDivisionDef);
11249 
11250     ajDebug("ajSeqdivGetEmbl '%S' => '%s'\n",
11251 	    divi, divdef->Embl);
11252 
11253     return divdef->Embl;
11254 
11255 }
11256 
11257 
11258 
11259 
11260 /* @func ajSeqdivGetGb ********************************************************
11261 **
11262 ** Returns the Genbank database division for a sequence
11263 **
11264 ** @param [r] divi [const AjPStr] Internal database division
11265 ** @return [const char*] Genbank database division
11266 **
11267 ** @release 5.0.0
11268 ******************************************************************************/
11269 
ajSeqdivGetGb(const AjPStr divi)11270 const char* ajSeqdivGetGb(const AjPStr divi)
11271 {
11272     static AjBool called = AJFALSE;
11273     const SeqODivision *divdef = NULL;
11274 
11275     if(!called)
11276     {
11277 	seqdivInit();
11278 	called = ajTrue;
11279     }
11280 
11281     ajDebug("ajSeqdivGetGb '%S'\n", divi);
11282 
11283     if(ajStrGetLen(divi))
11284 	divdef = ajTableFetchS(seqTableDiv, divi);
11285 
11286     if(!divdef)
11287 	divdef = ajTableFetchS(seqTableDiv, seqDivisionDef);
11288 
11289     if(!divdef)
11290 	return ajStrGetPtr(seqDivisionDef);
11291 
11292     ajDebug("ajSeqdivGetGb '%S' => '%s'\n",
11293 	    divi, divdef->Genbank);
11294 
11295     return divdef->Genbank;
11296 
11297 }
11298 
11299 
11300 
11301 
11302 /* @funcstatic seqdivInit *****************************************************
11303 **
11304 ** Initialises the tables of sequence database divisions
11305 **
11306 ** @return [void]
11307 **
11308 ** @release 5.0.0
11309 ******************************************************************************/
11310 
seqdivInit(void)11311 static void seqdivInit(void)
11312 {
11313     ajuint i;
11314     AjPStr keystr = NULL;
11315     AjPStr valstr = NULL;
11316 
11317     if(seqTableDiv)
11318 	return;
11319 
11320     seqTableDiv = ajTablestrNewCase(16);
11321     seqTableDivEmbl = ajTablestrNewCase(16);
11322     seqTableDivDdbj = ajTablestrNewCase(16);
11323     seqTableDivGb = ajTablestrNewCase(16);
11324 
11325     seqDivisionDef = ajStrNewC(seqDivision[0].Name);
11326 
11327     for(i=0;seqDivision[i].Name;i++)
11328     {
11329 	keystr = ajStrNewC(seqDivision[i].Name);
11330 
11331 	ajTablePut(seqTableDiv, keystr, &seqDivision[i]);
11332 
11333 	if(seqDivision[i].Embl[0])
11334 	{
11335 	    valstr = ajStrNewC(seqDivision[i].Embl);
11336 
11337 	    ajTablePut(seqTableDivEmbl, valstr, keystr);
11338 	}
11339 
11340 	if(seqDivision[i].Ddbj[0])
11341 	{
11342 	    valstr = ajStrNewC(seqDivision[i].Ddbj);
11343 
11344 	    ajTablePut(seqTableDivDdbj, valstr, keystr);
11345 	}
11346 
11347 	if(seqDivision[i].Genbank[0])
11348 	{
11349 	    valstr = ajStrNewC(seqDivision[i].Genbank);
11350 
11351 	    ajTablePut(seqTableDivGb, valstr, keystr);
11352 	}
11353 
11354     }
11355 
11356     return;
11357 }
11358 
11359 
11360 
11361 
11362 /* @datasection [AjPStr] Sequence entry molecule types ************************
11363 **
11364 ** Sequence entry molecule type vocabularies
11365 **
11366 ** @nam2rule Seqmol
11367 **
11368 ******************************************************************************/
11369 
11370 
11371 
11372 
11373 /* @section assignment ********************************************************
11374 **
11375 ** Assign values for sequence entry molecule types
11376 **
11377 ** @fdata [AjPStr]
11378 ** @fcategory assign
11379 **
11380 ** @nam3rule Set Assign value
11381 ** @nam4rule Embl Assign with an EMBL molecule type name
11382 ** @nam4rule Gb   Assign with a GenBank molecule type name
11383 **
11384 ** @argrule Set Pmol [AjPStr*] Target sequence molecule type string
11385 ** @argrule Embl molembl [const AjPStr] EMBL molecule type name
11386 ** @argrule Gb   molgb   [const AjPStr] Genbank molecule type name
11387 **
11388 ** @valrule * [AjBool] True on success
11389 **
11390 ******************************************************************************/
11391 
11392 
11393 
11394 
11395 /* @func ajSeqmolSetEmbl ******************************************************
11396 **
11397 ** Sets the internal molecule type for a sequence
11398 **
11399 ** @param [u] Pmol [AjPStr*] Sequence object
11400 ** @param [r] molembl [const AjPStr] Molecule type
11401 ** @return [AjBool] True if a known type
11402 **
11403 ** @release 5.0.0
11404 ******************************************************************************/
11405 
ajSeqmolSetEmbl(AjPStr * Pmol,const AjPStr molembl)11406 AjBool ajSeqmolSetEmbl(AjPStr* Pmol, const AjPStr molembl)
11407 {
11408     static AjBool called = AJFALSE;
11409     const AjPStr molname = NULL;
11410 
11411     if(!called)
11412     {
11413 	seqmolInit();
11414 	called = ajTrue;
11415     }
11416 
11417     molname = ajTableFetchS(seqTableMolEmbl, molembl);
11418 
11419     if(!molname)
11420 	return ajFalse;
11421 
11422     ajStrAssignS(Pmol, molname);
11423 
11424     return ajTrue;
11425 }
11426 
11427 
11428 
11429 
11430 /* @func ajSeqmolSetGb ********************************************************
11431 **
11432 ** Sets the internal molecule type for a sequence
11433 **
11434 ** @param [u] Pmol [AjPStr*] Sequence object
11435 ** @param [r] molgb [const AjPStr] Molecule type
11436 ** @return [AjBool] True if a known type
11437 **
11438 ** @release 5.0.0
11439 ******************************************************************************/
11440 
ajSeqmolSetGb(AjPStr * Pmol,const AjPStr molgb)11441 AjBool ajSeqmolSetGb(AjPStr* Pmol, const AjPStr molgb)
11442 {
11443     static AjBool called = AJFALSE;
11444     const AjPStr molname = NULL;
11445 
11446     if(!called)
11447     {
11448 	seqmolInit();
11449 	called = ajTrue;
11450     }
11451 
11452     molname = ajTableFetchS(seqTableMolGb, molgb);
11453 
11454     if(!molname)
11455 	return ajFalse;
11456 
11457     ajStrAssignS(Pmol, molname);
11458 
11459     return ajTrue;
11460 }
11461 
11462 
11463 
11464 
11465 /* @section retrieval ********************************************************
11466 **
11467 ** Return values for sequence molecule type division
11468 **
11469 ** @fdata [AjPStr]
11470 ** @fcategory use
11471 **
11472 ** @nam3rule Get Retrieve value
11473 ** @nam4rule Embl Retrieve as an EMBL molecule type name
11474 ** @nam4rule Gb   Retrieve as a GenBank molecule type name
11475 **
11476 ** @argrule Get mol [const AjPStr] Internal sequence molecule type string
11477 **
11478 ** @valrule * [const char*] Databank-specific molecule type name
11479 **
11480 ******************************************************************************/
11481 
11482 
11483 
11484 
11485 /* @func ajSeqmolGetEmbl ******************************************************
11486 **
11487 ** Returns the EMBL molecule type for a sequence
11488 **
11489 ** @param [r] mol [const AjPStr] Internal molecule type
11490 ** @return [const char*] EMBL molecule type
11491 **
11492 ** @release 5.0.0
11493 ******************************************************************************/
11494 
ajSeqmolGetEmbl(const AjPStr mol)11495 const char* ajSeqmolGetEmbl(const AjPStr mol)
11496 {
11497     static AjBool called = AJFALSE;
11498     const SeqOMolecule *moldef = NULL;
11499 
11500     if(!called)
11501     {
11502 	seqmolInit();
11503 	called = ajTrue;
11504     }
11505 
11506     ajDebug("ajSeqMoleculeGetEmbl '%S'\n", mol);
11507 
11508     if(ajStrGetLen(mol))
11509 	moldef = ajTableFetchS(seqTableMol, mol);
11510 
11511     if(!moldef)
11512 	moldef = ajTableFetchS(seqTableMol, seqMoleculeDef);
11513 
11514     if(!moldef)
11515 	return ajStrGetPtr(seqMoleculeDef);
11516 
11517     ajDebug("ajSeqMoleculeGetEmbl '%S' => '%s'\n",
11518 	    mol, moldef->Embl);
11519 
11520     return moldef->Embl;
11521 }
11522 
11523 
11524 
11525 
11526 /* @func ajSeqmolGetGb ********************************************************
11527 **
11528 ** Returns the Genbank molecule type for a sequence
11529 **
11530 ** @param [r] mol [const AjPStr] Internal molecule type
11531 ** @return [const char*] Genbank molecule type
11532 **
11533 ** @release 5.0.0
11534 ******************************************************************************/
11535 
ajSeqmolGetGb(const AjPStr mol)11536 const char* ajSeqmolGetGb(const AjPStr mol)
11537 {
11538     static AjBool called = AJFALSE;
11539     const SeqOMolecule *moldef = NULL;
11540 
11541     if(!called)
11542     {
11543 	seqmolInit();
11544 	called = ajTrue;
11545     }
11546 
11547     ajDebug("ajSeqMoleculeGetGb '%S'\n", mol);
11548 
11549     if(ajStrGetLen(mol))
11550 	moldef = ajTableFetchS(seqTableMol, mol);
11551 
11552     if(!moldef)
11553 	moldef = ajTableFetchS(seqTableMol, seqMoleculeDef);
11554 
11555     if(!moldef)
11556 	return ajStrGetPtr(seqMoleculeDef);
11557 
11558     ajDebug("ajSeqMoleculeGetGb '%S' => '%s'\n",
11559 	    mol, moldef->Genbank);
11560 
11561     return moldef->Genbank;
11562 }
11563 
11564 
11565 
11566 
11567 /* @funcstatic seqmolInit *****************************************************
11568 **
11569 ** Initialises the tables of molecule types
11570 **
11571 ** @return [void]
11572 **
11573 ** @release 5.0.0
11574 ******************************************************************************/
11575 
seqmolInit(void)11576 static void seqmolInit(void)
11577 {
11578     ajuint i;
11579     AjPStr keystr = NULL;
11580     AjPStr valstr = NULL;
11581 
11582     if(seqTableMol)
11583 	return;
11584 
11585     seqTableMol = ajTablestrNewCase(16);
11586     seqTableMolEmbl = ajTablestrNewCase(16);
11587     seqTableMolDdbj = ajTablestrNewCase(16);
11588     seqTableMolGb = ajTablestrNewCase(16);
11589 
11590     seqMoleculeDef = ajStrNewC(seqMolecule[0].Name);
11591 
11592     for(i=0;seqMolecule[i].Name;i++)
11593     {
11594 	if(!ajTableMatchC(seqTableMol, seqMolecule[i].Name)){
11595             keystr = ajStrNewC(seqMolecule[i].Name);
11596 
11597             ajTablePut(seqTableMol, keystr, &seqMolecule[i]);
11598         }
11599 
11600 	if(seqMolecule[i].Embl[0])
11601 	{
11602 	    if(!ajTableMatchC(seqTableMolEmbl, seqMolecule[i].Embl))
11603             {
11604                 valstr = ajStrNewC(seqMolecule[i].Embl);
11605 
11606                 ajTablePut(seqTableMolEmbl, valstr, keystr);
11607             }
11608         }
11609 
11610 	if(seqMolecule[i].Ddbj[0])
11611 	{
11612 	    if(!ajTableMatchC(seqTableMolDdbj, seqMolecule[i].Ddbj))
11613             {
11614                 valstr = ajStrNewC(seqMolecule[i].Ddbj);
11615 
11616                 ajTablePut(seqTableMolDdbj, valstr, keystr);
11617             }
11618 	}
11619 
11620 	if(seqMolecule[i].Genbank[0])
11621 	{
11622 	    if(!ajTableMatchC(seqTableMolGb, seqMolecule[i].Genbank))
11623             {
11624                 valstr = ajStrNewC(seqMolecule[i].Genbank);
11625 
11626                 ajTablePut(seqTableMolGb, valstr, keystr);
11627             }
11628 	}
11629 
11630     }
11631 
11632     return;
11633 }
11634 
11635 
11636 
11637 
11638 #ifdef AJ_COMPILE_DEPRECATED_BOOK
11639 #endif /* AJ_COMPILE_DEPRECATED_BOOK */
11640 
11641 
11642 
11643 
11644 #ifdef AJ_COMPILE_DEPRECATED
11645 /* @obsolete ajSeqNewC
11646 ** @rename ajSeqNewNameC
11647 */
11648 
ajSeqNewC(const char * seq,const char * name)11649 __deprecated AjPSeq  ajSeqNewC(const char* seq, const char* name)
11650 {
11651     return ajSeqNewNameC(seq, name);
11652 }
11653 
11654 
11655 
11656 
11657 /* @obsolete ajSeqNewStr
11658 ** @rename ajSeqNewNameS
11659 */
11660 
ajSeqNewStr(const AjPStr seq)11661 __deprecated AjPSeq  ajSeqNewStr(const AjPStr seq)
11662 {
11663     AjPStr name = ajStrNew();
11664 
11665     return ajSeqNewNameS(seq, name);
11666 }
11667 
11668 
11669 
11670 
11671 /* @obsolete ajSeqNewRange
11672 ** @rename ajSeqNewRangeS
11673 */
11674 
ajSeqNewRange(const AjPStr seq,ajint offset,ajint offend,AjBool rev)11675 __deprecated AjPSeq  ajSeqNewRange(const AjPStr seq,
11676 				  ajint offset, ajint offend, AjBool rev)
11677 {
11678     return ajSeqNewRangeS(seq, offset, offend, rev);
11679 }
11680 
11681 
11682 
11683 
11684 /* @obsolete ajSeqNewRangeCI
11685 ** @replace ajSeqNewRangeC (1,2,3,4,5/1,3,4,5)
11686 */
11687 
ajSeqNewRangeCI(const char * seq,ajint len,ajint offset,ajint offend,AjBool rev)11688 __deprecated AjPSeq  ajSeqNewRangeCI(const char* seq, ajint len,
11689 				    ajint offset, ajint offend, AjBool rev)
11690 {
11691     (void)len;
11692 
11693     return ajSeqNewRangeC(seq, offset, offend, rev);
11694 }
11695 
11696 
11697 
11698 
11699 /* @obsolete ajSeqNewL
11700 ** @rename ajSeqNewRes
11701 */
ajSeqNewL(size_t size)11702 __deprecated AjPSeq  ajSeqNewL(size_t size)
11703 {
11704     return ajSeqNewRes(size);
11705 }
11706 
11707 
11708 
11709 
11710 /* @obsolete ajSeqNewS
11711 ** @rename ajSeqNewSeq
11712 */
11713 
ajSeqNewS(const AjPSeq seq)11714 __deprecated AjPSeq  ajSeqNewS(const AjPSeq seq)
11715 {
11716     return ajSeqNewSeq(seq);
11717 }
11718 
11719 
11720 
11721 
11722 /* @obsolete ajSeqAssAccC
11723 ** @rename ajSeqAssignAccC
11724 */
11725 
ajSeqAssAccC(AjPSeq thys,const char * text)11726 __deprecated void  ajSeqAssAccC(AjPSeq thys, const char* text)
11727 {
11728     ajSeqAssignAccC(thys, text);
11729 
11730     return;
11731 }
11732 
11733 
11734 
11735 
11736 /* @obsolete ajSeqAssAcc
11737 ** @rename ajSeqAssignAccS
11738 */
11739 
ajSeqAssAcc(AjPSeq thys,const AjPStr str)11740 __deprecated void  ajSeqAssAcc(AjPSeq thys, const AjPStr str)
11741 {
11742     ajSeqAssignAccS(thys, str);
11743 
11744     return;
11745 }
11746 
11747 
11748 
11749 
11750 /* @obsolete ajSeqAssDescC
11751 ** @rename ajSeqAssignDescC
11752 */
11753 
ajSeqAssDescC(AjPSeq thys,const char * txt)11754 __deprecated void  ajSeqAssDescC(AjPSeq thys, const char* txt)
11755 {
11756     ajSeqAssignDescC(thys, txt);
11757 
11758     return;
11759 }
11760 
11761 
11762 
11763 
11764 /* @obsolete ajSeqAssDesc
11765 ** @rename ajSeqAssignDescS
11766 */
11767 
ajSeqAssDesc(AjPSeq thys,const AjPStr str)11768 __deprecated void  ajSeqAssDesc(AjPSeq thys, const AjPStr str)
11769 {
11770     ajSeqAssignDescS(thys, str);
11771 
11772     return;
11773 }
11774 
11775 
11776 
11777 
11778 /* @obsolete ajSeqAssEntryC
11779 ** @rename ajSeqAssignEntryC
11780 */
11781 
ajSeqAssEntryC(AjPSeq thys,const char * text)11782 __deprecated void  ajSeqAssEntryC(AjPSeq thys, const char* text)
11783 {
11784     ajSeqAssignEntryC(thys, text);
11785 
11786     return;
11787 }
11788 
11789 
11790 
11791 
11792 /* @obsolete ajSeqAssEntry
11793 ** @rename ajSeqAssignEntryS
11794 */
11795 
ajSeqAssEntry(AjPSeq thys,const AjPStr str)11796 __deprecated void  ajSeqAssEntry(AjPSeq thys, const AjPStr str)
11797 {
11798     ajSeqAssignEntryS(thys, str);
11799 
11800     return;
11801 }
11802 
11803 
11804 
11805 
11806 /* @obsolete ajSeqAssFileC
11807 ** @rename ajSeqAssignFileC
11808 */
11809 
ajSeqAssFileC(AjPSeq thys,const char * text)11810 __deprecated void  ajSeqAssFileC(AjPSeq thys, const char* text)
11811 {
11812     ajSeqAssignFileC(thys, text);
11813 
11814     return;
11815 }
11816 
11817 
11818 
11819 
11820 /* @obsolete ajSeqAssFile
11821 ** @rename ajSeqAssignFileS
11822 */
11823 
ajSeqAssFile(AjPSeq thys,const AjPStr str)11824 __deprecated void  ajSeqAssFile(AjPSeq thys, const AjPStr str)
11825 {
11826     ajSeqAssignFileS(thys, str);
11827 
11828     return;
11829 }
11830 
11831 
11832 
11833 
11834 /* @obsolete ajSeqAssFullC
11835 ** @rename ajSeqAssignFullC
11836 */
11837 
ajSeqAssFullC(AjPSeq thys,const char * text)11838 __deprecated void  ajSeqAssFullC(AjPSeq thys, const char* text)
11839 {
11840     ajSeqAssignFullC(thys, text);
11841 
11842     return;
11843 }
11844 
11845 
11846 
11847 
11848 /* @obsolete ajSeqAssFull
11849 ** @rename ajSeqAssignFullS
11850 */
11851 
ajSeqAssFull(AjPSeq thys,const AjPStr str)11852 __deprecated void  ajSeqAssFull(AjPSeq thys, const AjPStr str)
11853 {
11854     ajSeqAssignFullS(thys, str);
11855 
11856     return;
11857 }
11858 
11859 
11860 
11861 
11862 /* @obsolete ajSeqAssGiC
11863 ** @rename ajSeqAssignGiC
11864 */
11865 
ajSeqAssGiC(AjPSeq thys,const char * text)11866 __deprecated void  ajSeqAssGiC(AjPSeq thys, const char* text)
11867 {
11868     ajSeqAssignGiC(thys, text);
11869 
11870     return;
11871 }
11872 
11873 
11874 
11875 
11876 /* @obsolete ajSeqAssGi
11877 ** @rename ajSeqAssignGiS
11878 */
11879 
ajSeqAssGi(AjPSeq thys,const AjPStr str)11880 __deprecated void  ajSeqAssGi(AjPSeq thys, const AjPStr str)
11881 {
11882     ajSeqAssignGiS(thys, str);
11883 
11884     return;
11885 }
11886 
11887 
11888 
11889 
11890 /* @obsolete ajSeqAssName
11891 ** @rename ajSeqAssignNameS
11892 */
11893 
ajSeqAssName(AjPSeq thys,const AjPStr str)11894 __deprecated void  ajSeqAssName(AjPSeq thys, const AjPStr str)
11895 {
11896     ajSeqAssignNameS(thys, str);
11897 
11898     return;
11899 }
11900 
11901 
11902 
11903 
11904 /* @obsolete ajSeqAssNameC
11905 ** @rename ajSeqAssignNameS
11906 */
11907 
ajSeqAssNameC(AjPSeq thys,const char * str)11908 __deprecated void  ajSeqAssNameC(AjPSeq thys, const char* str)
11909 {
11910     ajSeqAssignNameC(thys, str);
11911 
11912     return;
11913 }
11914 
11915 
11916 
11917 
11918 /* @obsolete ajSeqAssSeq
11919 ** @rename ajSeqAssignSeqS
11920 */
ajSeqAssSeq(AjPSeq seq,const AjPStr str)11921 __deprecated void  ajSeqAssSeq(AjPSeq seq, const AjPStr str)
11922 {
11923     ajSeqAssignSeqS(seq, str);
11924 
11925     return;
11926 }
11927 
11928 
11929 
11930 
11931 /* @obsolete ajSeqAssSeqC
11932 ** @rename ajSeqAssignSeqC
11933 */
ajSeqAssSeqC(AjPSeq thys,const char * text)11934 __deprecated void  ajSeqAssSeqC (AjPSeq thys, const char* text)
11935 {
11936     ajSeqAssignSeqC(thys, text);
11937 
11938     return;
11939 }
11940 
11941 
11942 
11943 
11944 /* @obsolete ajSeqAssSeqCI
11945 ** @replace ajSeqAssignSeqC (1,2,3/1,2)
11946 */
ajSeqAssSeqCI(AjPSeq thys,const char * text,ajint ilen)11947 __deprecated void  ajSeqAssSeqCI (AjPSeq thys, const char* text, ajint ilen)
11948 {
11949 /*
11950     static ajint savelen;
11951     savelen = ilen;
11952 */
11953     (void) ilen;
11954     ajSeqAssignSeqC(thys, text);
11955 
11956     return;
11957 }
11958 
11959 
11960 
11961 
11962 /* @obsolete ajSeqAssSvC
11963 ** @rename ajSeqAssignSvC
11964 */
ajSeqAssSvC(AjPSeq thys,const char * text)11965 __deprecated void  ajSeqAssSvC(AjPSeq thys, const char* text)
11966 {
11967     ajSeqAssignSvC(thys, text);
11968 
11969     return;
11970 }
11971 
11972 
11973 
11974 
11975 /* @obsolete ajSeqAssSv
11976 ** @rename ajSeqAssignSvS
11977 */
ajSeqAssSv(AjPSeq thys,const AjPStr str)11978 __deprecated void  ajSeqAssSv(AjPSeq thys, const AjPStr str)
11979 {
11980     ajSeqAssignSvS(thys, str);
11981 
11982     return;
11983 }
11984 
11985 
11986 
11987 
11988 /* @obsolete ajSeqAssUfoC
11989 ** @rename ajSeqAssignUfoC
11990 */
ajSeqAssUfoC(AjPSeq thys,const char * text)11991 __deprecated void  ajSeqAssUfoC(AjPSeq thys, const char* text)
11992 {
11993     ajSeqAssignUfoC(thys, text);
11994 
11995     return;
11996 }
11997 
11998 
11999 
12000 
12001 /* @obsolete ajSeqAssUfo
12002 ** @rename ajSeqAssignUfoS
12003 */
ajSeqAssUfo(AjPSeq thys,const AjPStr str)12004 __deprecated void  ajSeqAssUfo(AjPSeq thys, const AjPStr str)
12005 {
12006     ajSeqAssignUfoS(thys, str);
12007 
12008     return;
12009 }
12010 
12011 
12012 
12013 
12014 /* @obsolete ajSeqAssUsaC
12015 ** @rename ajSeqAssignUsaC
12016 */
ajSeqAssUsaC(AjPSeq thys,const char * text)12017 __deprecated void  ajSeqAssUsaC(AjPSeq thys, const char* text)
12018 {
12019     ajSeqAssignUsaC(thys, text);
12020 
12021     return;
12022 }
12023 
12024 
12025 
12026 
12027 /* @obsolete ajSeqAssUsa
12028 ** @rename ajSeqAssignUsaS
12029 */
ajSeqAssUsa(AjPSeq thys,const AjPStr str)12030 __deprecated void  ajSeqAssUsa(AjPSeq thys, const AjPStr str)
12031 {
12032     ajSeqAssignUsaS(thys, str);
12033 
12034     return;
12035 }
12036 
12037 
12038 
12039 
12040 /* @obsolete ajSeqDefName
12041 ** @replace ajSeqSetName (1,2,ajFalse/1,2)
12042 ** @replace ajSeqSetNameMulti (1,2,ajTrue/1,2)
12043 
12044 */
ajSeqDefName(AjPSeq thys,const AjPStr setname,AjBool multi)12045 __deprecated void  ajSeqDefName(AjPSeq thys, const AjPStr setname, AjBool multi)
12046 {
12047     if(multi)
12048 	ajSeqSetNameMulti(thys, setname);
12049     else
12050 	ajSeqSetName(thys, setname);
12051 
12052     return;
12053 }
12054 
12055 
12056 
12057 
12058 /* @obsolete ajSeqSetRangeDir
12059 ** @replace ajSeqSetRange (1,2,3,ajFalse/1,2,3)
12060 ** @replace ajSeqSetRangeRev (1,2,3,ajTrue/1,2,3)
12061 */
ajSeqSetRangeDir(AjPSeq seq,ajint ibegin,ajint iend,AjBool rev)12062 __deprecated void  ajSeqSetRangeDir(AjPSeq seq,
12063 				   ajint ibegin, ajint iend, AjBool rev)
12064 {
12065     if(rev)
12066 	ajSeqSetRangeRev(seq, ibegin, iend);
12067     else
12068 	ajSeqSetRange(seq, ibegin, iend);
12069 
12070     return;
12071 }
12072 
12073 
12074 
12075 
12076 /* @obsolete ajSeqMod
12077 ** @rename ajSeqSetUnique
12078 */
ajSeqMod(AjPSeq seq)12079 __deprecated void  ajSeqMod(AjPSeq seq)
12080 {
12081     ajSeqSetUnique(seq);
12082 
12083     return;
12084 }
12085 
12086 
12087 
12088 
12089 /* @obsolete ajSeqReplace
12090 ** @rename ajSeqAssignSeqS
12091 */
ajSeqReplace(AjPSeq thys,const AjPStr seq)12092 __deprecated void  ajSeqReplace(AjPSeq thys, const AjPStr seq)
12093 {
12094     ajSeqAssignSeqS(thys, seq);
12095 
12096     return;
12097 }
12098 
12099 
12100 
12101 
12102 /* @obsolete ajSeqReplaceC
12103 ** @rename ajSeqAssignSeqC
12104 */
ajSeqReplaceC(AjPSeq thys,const char * seq)12105 __deprecated void  ajSeqReplaceC(AjPSeq thys, const char* seq)
12106 {
12107     ajSeqAssignSeqC(thys, seq);
12108 
12109     return;
12110 }
12111 
12112 
12113 
12114 
12115 /* @obsolete ajSeqMakeUsa
12116 ** @remove made static
12117 */
12118 
ajSeqMakeUsa(AjPSeq thys,const AjPSeqin seqin)12119 __deprecated void  ajSeqMakeUsa(AjPSeq thys, const AjPSeqin seqin)
12120 {
12121     (void)seqin;
12122     seqMakeUsa(thys, &thys->Usa);
12123 
12124     return;
12125 }
12126 
12127 
12128 
12129 
12130 /* @obsolete ajSeqMakeUsaS
12131 ** @remove made static
12132 */
12133 
ajSeqMakeUsaS(const AjPSeq thys,const AjPSeqin seqin,AjPStr * usa)12134 __deprecated void  ajSeqMakeUsaS(const AjPSeq thys,
12135 				const AjPSeqin seqin, AjPStr* usa)
12136 {
12137     (void)seqin;
12138     seqMakeUsa(thys, usa);
12139 
12140     return;
12141 }
12142 
12143 
12144 
12145 
12146 /* @obsolete ajSeqComplementOnly
12147 ** @rename ajSeqComplement
12148 */
ajSeqComplementOnly(AjPSeq pthis)12149 __deprecated void  ajSeqComplementOnly(AjPSeq pthis)
12150 {
12151     ajSeqComplement(pthis);
12152 
12153     return;
12154 }
12155 
12156 
12157 
12158 
12159 /* @obsolete ajSeqCompOnly
12160 ** @rename ajSeqComplement
12161 */
ajSeqCompOnly(AjPSeq seq)12162 __deprecated void  ajSeqCompOnly(AjPSeq seq)
12163 {
12164     ajSeqComplement(seq);
12165 
12166     return;
12167 }
12168 
12169 
12170 
12171 
12172 /* @obsolete ajSeqToLower
12173 ** @rename ajSeqFmtLower
12174 */
12175 
ajSeqToLower(AjPSeq seq)12176 __deprecated void  ajSeqToLower(AjPSeq seq)
12177 {
12178     ajStrFmtLower(&seq->Seq);
12179 
12180     return;
12181 }
12182 
12183 
12184 
12185 
12186 /* @obsolete ajSeqToUpper
12187 ** @rename ajSeqFmtUpper
12188 */
12189 
ajSeqToUpper(AjPSeq seq)12190 __deprecated void  ajSeqToUpper(AjPSeq seq)
12191 {
12192     ajStrFmtUpper(&seq->Seq);
12193 
12194     return;
12195 }
12196 
12197 
12198 
12199 
12200 /* @obsolete ajSeqFill
12201 ** @rename ajSeqGapFill
12202 */
ajSeqFill(AjPSeq seq,ajint len)12203 __deprecated ajint  ajSeqFill(AjPSeq seq, ajint len)
12204 {
12205     ajint ilen;
12206     ilen = ajSeqGetLen(seq);
12207     ajSeqGapFill(seq, len);
12208 
12209     return len-ilen;
12210 }
12211 
12212 
12213 
12214 
12215 /* @obsolete ajSeqReverse
12216 ** @rename ajSeqReverseDo
12217 */
ajSeqReverse(AjPSeq seq)12218 __deprecated AjBool  ajSeqReverse(AjPSeq seq)
12219 {
12220     if(!seq->Rev)
12221 	return ajFalse;
12222 
12223     ajSeqReverseDo(seq);
12224 
12225     return ajTrue;
12226 }
12227 
12228 
12229 
12230 
12231 /* @obsolete ajSeqRevOnly
12232 ** @rename ajSeqReverseOnly
12233 */
12234 
ajSeqRevOnly(AjPSeq seq)12235 __deprecated void  ajSeqRevOnly(AjPSeq seq)
12236 {
12237     ajSeqReverseOnly(seq);
12238 
12239     return;
12240 }
12241 
12242 
12243 
12244 
12245 /* @obsolete ajSeqGetAcc
12246 ** @rename ajSeqGetAccS
12247 */
ajSeqGetAcc(const AjPSeq seq)12248 __deprecated const AjPStr  ajSeqGetAcc(const AjPSeq seq)
12249 {
12250     return ajSeqGetAccS(seq);
12251 }
12252 
12253 
12254 
12255 
12256 /* @obsolete ajSeqBegin
12257 ** @rename ajSeqGetBegin
12258 */
12259 
ajSeqBegin(const AjPSeq seq)12260 __deprecated ajint  ajSeqBegin(const AjPSeq seq)
12261 {
12262     return ajSeqGetBegin(seq);
12263 }
12264 
12265 
12266 
12267 
12268 /* @obsolete ajSeqTrueBegin
12269 ** @rename ajSeqGetBeginTrue
12270 */
ajSeqTrueBegin(const AjPSeq seq)12271 __deprecated ajint  ajSeqTrueBegin(const AjPSeq seq)
12272 {
12273     return ajSeqGetBeginTrue(seq);
12274 }
12275 
12276 
12277 
12278 
12279 /* @obsolete ajSeqGetDesc
12280 ** @rename ajSeqGetDescS
12281 */
12282 
ajSeqGetDesc(const AjPSeq seq)12283 __deprecated const AjPStr  ajSeqGetDesc(const AjPSeq seq)
12284 
12285 {
12286     return seq->Desc;
12287 }
12288 
12289 
12290 
12291 
12292 /* @obsolete ajSeqEnd
12293 ** @rename ajSeqGetEnd
12294 */
ajSeqEnd(const AjPSeq seq)12295 __deprecated ajint  ajSeqEnd(const AjPSeq seq)
12296 {
12297     return ajSeqGetEnd(seq);
12298 }
12299 
12300 
12301 
12302 
12303 /* @obsolete ajSeqTrueEnd
12304 ** @rename ajSeqGetEndTrue
12305 */
ajSeqTrueEnd(const AjPSeq seq)12306 __deprecated ajint  ajSeqTrueEnd(const AjPSeq seq)
12307 {
12308     return ajSeqGetEndTrue(seq);
12309 }
12310 
12311 
12312 
12313 
12314 /* @obsolete ajSeqGetEntry
12315 ** @rename ajSeqGetEntryS
12316 */
ajSeqGetEntry(const AjPSeq seq)12317 __deprecated const AjPStr  ajSeqGetEntry(const AjPSeq seq)
12318 {
12319     return ajSeqGetEntryS(seq);
12320 }
12321 
12322 
12323 
12324 
12325 /* @obsolete ajSeqCopyFeat
12326 ** @rename ajSeqGetFeatCopy
12327 */
ajSeqCopyFeat(const AjPSeq seq)12328 __deprecated AjPFeattable  ajSeqCopyFeat(const AjPSeq seq)
12329 {
12330     return ajFeattableNewFtable(seq->Fttable);
12331 }
12332 
12333 
12334 
12335 
12336 /* @obsolete ajSeqGetGi
12337 ** @rename ajSeqGetGiS
12338 */
ajSeqGetGi(const AjPSeq seq)12339 __deprecated const AjPStr  ajSeqGetGi(const AjPSeq seq)
12340 {
12341     return seq->Gi;
12342 }
12343 
12344 
12345 
12346 
12347 /* @obsolete ajSeqLen
12348 ** @rename ajSeqGetLen
12349 */
ajSeqLen(const AjPSeq seq)12350 __deprecated ajint  ajSeqLen(const AjPSeq seq)
12351 {
12352     return ajStrGetLen(seq->Seq);
12353 }
12354 
12355 
12356 
12357 
12358 /* @obsolete ajSeqTrueLen
12359 ** @rename ajSeqGetLenTrue
12360 */
ajSeqTrueLen(const AjPSeq seq)12361 __deprecated ajint  ajSeqTrueLen(const AjPSeq seq)
12362 {
12363     return ajSeqGetLenTrue(seq);
12364 }
12365 
12366 
12367 
12368 
12369 /* @obsolete ajSeqName
12370 ** @rename ajSeqGetNameC
12371 */
ajSeqName(const AjPSeq seq)12372 __deprecated const char*  ajSeqName(const AjPSeq seq)
12373 {
12374     return ajStrGetPtr(seq->Name);
12375 }
12376 
12377 
12378 
12379 
12380 /* @obsolete ajSeqGetName
12381 ** @rename ajSeqGetNameS
12382 */
ajSeqGetName(const AjPSeq seq)12383 __deprecated const AjPStr  ajSeqGetName(const AjPSeq seq)
12384 {
12385     return seq->Name;
12386 }
12387 
12388 
12389 
12390 
12391 /* @obsolete ajSeqOffend
12392 ** @rename ajSeqGetOffend
12393 */
ajSeqOffend(const AjPSeq seq)12394 __deprecated ajint  ajSeqOffend(const AjPSeq seq)
12395 {
12396     return ajSeqGetOffend(seq);
12397 }
12398 
12399 
12400 
12401 
12402 /* @obsolete ajSeqOffset
12403 ** @rename ajSeqGetOffset
12404 */
ajSeqOffset(const AjPSeq seq)12405 __deprecated ajint  ajSeqOffset(const AjPSeq seq)
12406 {
12407     return ajSeqGetOffset(seq);
12408 }
12409 
12410 
12411 
12412 
12413 /* @obsolete ajSeqGetReverse
12414 ** @rename ajSeqGetRev
12415 */
ajSeqGetReverse(const AjPSeq seq)12416 __deprecated AjBool  ajSeqGetReverse(const AjPSeq seq)
12417 {
12418     return seq->Rev;
12419 }
12420 
12421 
12422 
12423 
12424 /* @obsolete ajSeqGetReversed
12425 ** @rename ajSeqIsReversed
12426 */
ajSeqGetReversed(const AjPSeq seq)12427 __deprecated AjBool  ajSeqGetReversed(const AjPSeq seq)
12428 {
12429     return seq->Reversed;
12430 }
12431 
12432 
12433 
12434 
12435 /* @obsolete ajSeqStr
12436 ** @rename ajSeqGetSeqS
12437 */
ajSeqStr(const AjPSeq seq)12438 __deprecated const AjPStr  ajSeqStr(const AjPSeq seq)
12439 {
12440     return ajSeqGetSeqS(seq);
12441 }
12442 
12443 
12444 
12445 
12446 /* @obsolete ajSeqChar
12447 ** @rename ajSeqGetSeqC
12448 */
ajSeqChar(const AjPSeq seq)12449 __deprecated const char*  ajSeqChar(const AjPSeq seq)
12450 {
12451     if(!seq)
12452 	return "";
12453 
12454     return ajStrGetPtr(seq->Seq);
12455 }
12456 
12457 
12458 
12459 
12460 /* @obsolete ajSeqCharCopy
12461 ** @rename ajSeqGetSeqCopyC
12462 */
ajSeqCharCopy(const AjPSeq seq)12463 __deprecated char*  ajSeqCharCopy(const AjPSeq seq)
12464 {
12465     return ajCharNewS(seq->Seq);
12466 }
12467 
12468 
12469 
12470 
12471 /* @obsolete ajSeqStrCopy
12472 ** @rename ajSeqGetSeqCopyS
12473 */
ajSeqStrCopy(const AjPSeq seq)12474 __deprecated AjPStr  ajSeqStrCopy(const AjPSeq seq)
12475 {
12476     return ajSeqGetSeqCopyS(seq);
12477 }
12478 
12479 
12480 
12481 
12482 /* @obsolete ajSeqCharCopyL
12483 ** @replace ajSeqGetSeqCopyC (1,2/1,ajSeqGetLen[2])
12484 */
ajSeqCharCopyL(const AjPSeq seq,size_t size)12485 __deprecated char*  ajSeqCharCopyL(const AjPSeq seq, size_t size)
12486 {
12487     return ajCharNewResS(seq->Seq, size);
12488 }
12489 
12490 
12491 
12492 
12493 /* @obsolete ajSeqGetSv
12494 ** @rename ajSeqGetSvS
12495 */
ajSeqGetSv(const AjPSeq seq)12496 __deprecated const AjPStr  ajSeqGetSv(const AjPSeq seq)
12497 {
12498     return seq->Sv;
12499 }
12500 
12501 
12502 
12503 
12504 /* @obsolete ajSeqGetTax
12505 ** @rename ajSeqGetTaxS
12506 */
ajSeqGetTax(const AjPSeq seq)12507 __deprecated const AjPStr  ajSeqGetTax(const AjPSeq seq)
12508 {
12509     return seq->Tax;
12510 }
12511 
12512 
12513 
12514 
12515 /* @obsolete ajSeqGetUsa
12516 ** @rename ajSeqGetUsaS
12517 */
ajSeqGetUsa(const AjPSeq seq)12518 __deprecated const AjPStr  ajSeqGetUsa(const AjPSeq seq)
12519 {
12520     return ajSeqGetUsaS(seq);
12521 }
12522 
12523 
12524 
12525 
12526 /* @obsolete ajSeqRev
12527 ** @rename ajSeqIsReversed
12528 */
ajSeqRev(const AjPSeq seq)12529 __deprecated AjBool  ajSeqRev(const AjPSeq seq)
12530 {
12531     return ajSeqIsReversed(seq);
12532 }
12533 
12534 
12535 
12536 
12537 /* @obsolete ajSeqNum
12538 ** @rename ajSeqConvertNum
12539 */
12540 
ajSeqNum(const AjPSeq seq,const AjPSeqCvt cvt,AjPStr * numseq)12541 __deprecated AjBool  ajSeqNum(const AjPSeq seq, const AjPSeqCvt cvt,
12542 			     AjPStr* numseq)
12543 {
12544     return ajSeqConvertNum(seq, cvt, numseq);
12545 }
12546 
12547 
12548 
12549 
12550 /* @obsolete ajSeqCheckGcg
12551 ** @rename ajSeqCalcCheckgcg
12552 */
ajSeqCheckGcg(const AjPSeq seq)12553 __deprecated ajint  ajSeqCheckGcg(const AjPSeq seq)
12554 {
12555     return ajSeqCalcCheckgcg(seq);
12556 }
12557 
12558 
12559 
12560 
12561 /* @obsolete ajSeqCount
12562 ** @rename ajSeqCalcCount
12563 */
ajSeqCount(const AjPSeq seq,ajint * b)12564 __deprecated void  ajSeqCount(const AjPSeq seq, ajint* b)
12565 {
12566     ajSeqCalcCount(seq, b);
12567 
12568     return;
12569 }
12570 
12571 
12572 
12573 
12574 /* @obsolete ajSeqPos
12575 ** @replace ajCvtSposToPos (1,2/'ajSeqGetLen[1]',2)
12576 */
12577 
ajSeqPos(const AjPSeq seq,ajint ipos)12578 __deprecated ajint  ajSeqPos(const AjPSeq seq, ajint ipos)
12579 {
12580     return 1+ajCvtSposToPosStart(ajSeqGetLen(seq), 0, ipos);
12581 }
12582 
12583 
12584 
12585 
12586 /* @obsolete ajSeqPosI
12587 ** @replace ajCvtSposToPosStart (1,2,3/'ajSeqGetLen[1]',2,3)
12588 */
ajSeqPosI(const AjPSeq seq,ajint imin,ajint ipos)12589 __deprecated ajint  ajSeqPosI(const AjPSeq seq, ajint imin, ajint ipos)
12590 {
12591     return 1+ajCvtSposToPosStart(ajSeqGetLen(seq), imin, ipos);
12592 }
12593 
12594 
12595 
12596 
12597 /* @obsolete ajSeqPosII
12598 ** @rename ajCvtSposToPosStart
12599 */
12600 
ajSeqPosII(ajint ilen,ajint imin,ajint ipos)12601 __deprecated ajint  ajSeqPosII(ajint ilen, ajint imin, ajint ipos)
12602 {
12603     ajint jpos;
12604 
12605     if(ipos < 0)
12606 	jpos = ilen + ipos + 1;
12607     else
12608     {
12609 	if(ipos)
12610 	    jpos = ipos;
12611 	else
12612 	    jpos = 1;
12613     }
12614 
12615     if(jpos > ilen)
12616 	jpos = ilen;
12617 
12618     if(jpos < imin)
12619 	jpos = imin;
12620 
12621     ajDebug("ajSeqPosII (ilen: %d imin: %d ipos: %d) = %d\n",
12622 	    ilen, imin, ipos, jpos);
12623 
12624     return jpos;
12625 }
12626 
12627 
12628 
12629 
12630 /* @obsolete ajSeqTruePos
12631 ** @rename ajSeqCalcTruepos
12632 */
ajSeqTruePos(const AjPSeq thys,ajint ipos)12633 __deprecated ajint  ajSeqTruePos(const AjPSeq thys, ajint ipos)
12634 {
12635     return ajSeqCalcTruepos(thys, ipos);
12636 }
12637 
12638 
12639 
12640 
12641 /* @obsolete ajSeqTruePosI
12642 ** @rename ajSeqCalcTrueposMin
12643 */
12644 
ajSeqTruePosI(const AjPSeq thys,ajint imin,ajint ipos)12645 __deprecated ajint  ajSeqTruePosI(const AjPSeq thys, ajint imin, ajint ipos)
12646 {
12647     return ajSeqCalcTrueposMin(thys, imin, ipos);
12648 }
12649 
12650 
12651 
12652 
12653 /* @obsolete ajSeqTruePosII
12654 ** @rename ajCvtSposToPosStart
12655 */
ajSeqTruePosII(ajint ilen,ajint imin,ajint ipos)12656 __deprecated ajint  ajSeqTruePosII(ajint ilen, ajint imin, ajint ipos)
12657 {
12658     return ajCvtSposToPosStart(ilen, imin, ipos);
12659 }
12660 
12661 
12662 
12663 
12664 /* @obsolete ajSeqGapCount
12665 * @rename ajSeqCountGaps
12666 */
12667 
ajSeqGapCount(const AjPSeq seq)12668 __deprecated ajint  ajSeqGapCount(const AjPSeq seq)
12669 {
12670     return ajSeqCountGaps(seq);
12671 }
12672 
12673 
12674 
12675 
12676 /* @obsolete ajSeqTraceT
12677 ** @rename ajSeqTraceTitle
12678 */
ajSeqTraceT(const AjPSeq seq,const char * title)12679 __deprecated void  ajSeqTraceT(const AjPSeq seq, const char* title)
12680 {
12681     ajSeqTraceTitle(seq, title);
12682 
12683     return;
12684 }
12685 
12686 
12687 
12688 
12689 /* @obsolete ajSeqallReverse
12690 ** @remove sequence processed separately after ajSeqallNext
12691 */
ajSeqallReverse(AjPSeqall seq)12692 __deprecated void  ajSeqallReverse(AjPSeqall seq)
12693 {
12694     ajint ibegin;
12695     ajint iend;
12696 
12697     ajDebug("ajSeqallReverse len: %d Begin: %d End: %d\n",
12698 	    ajSeqallGetseqLen(seq), seq->Begin, seq->End);
12699 
12700     ibegin = seq->Begin;
12701     iend   = seq->End;
12702 
12703     seq->End   = -(ibegin);
12704     seq->Begin = -(iend);
12705 
12706     ajSeqReverseDo(seq->Seq);
12707 
12708     ajDebug("  all result len: %d Begin: %d End: %d\n",
12709 	    ajSeqallGetseqLen(seq), seq->Begin, seq->End);
12710 
12711     return;
12712 }
12713 
12714 
12715 
12716 
12717 /* @obsolete ajSeqallToLower
12718 ** @remove done when sequence is read
12719 */
ajSeqallToLower(AjPSeqall seqall)12720 __deprecated void  ajSeqallToLower(AjPSeqall seqall)
12721 {
12722     ajSeqFmtLower(seqall->Seq);
12723 
12724     return;
12725 }
12726 
12727 
12728 
12729 
12730 /* @obsolete ajSeqallToUpper
12731 ** @remove done when sequence is read
12732 */
ajSeqallToUpper(AjPSeqall seqall)12733 __deprecated void  ajSeqallToUpper(AjPSeqall seqall)
12734 {
12735     ajSeqFmtUpper(seqall->Seq);
12736 
12737     return;
12738 }
12739 
12740 
12741 
12742 
12743 /* @obsolete ajSeqallBegin
12744 ** @rename ajSeqallGetseqBegin
12745 */
ajSeqallBegin(const AjPSeqall seq)12746 __deprecated ajint  ajSeqallBegin(const AjPSeqall seq)
12747 {
12748     return ajSeqallGetseqBegin(seq);
12749 }
12750 
12751 
12752 
12753 
12754 /* @obsolete ajSeqallEnd
12755 ** @rename ajSeqallGetseqEnd
12756 */
ajSeqallEnd(const AjPSeqall seq)12757 __deprecated ajint  ajSeqallEnd(const AjPSeqall seq)
12758 {
12759     return ajSeqallGetseqEnd(seq);
12760 }
12761 
12762 
12763 
12764 
12765 /* @obsolete ajSeqallLen
12766 ** @rename ajSeqallGetseqLen
12767 */
ajSeqallLen(const AjPSeqall seqall)12768 __deprecated ajint  ajSeqallLen(const AjPSeqall seqall)
12769 {
12770     return ajSeqallGetseqLen(seqall);
12771 }
12772 
12773 
12774 
12775 
12776 /* @obsolete ajSeqallGetNameSeq
12777 ** @rename ajSeqallGetseqName
12778 */
12779 
ajSeqallGetNameSeq(const AjPSeqall seq)12780 __deprecated const AjPStr  ajSeqallGetNameSeq(const AjPSeqall seq)
12781 {
12782     return ajSeqallGetseqName(seq);
12783 }
12784 
12785 
12786 
12787 
12788 /* @obsolete ajSeqallGetRange
12789 ** @rename   ajSeqallGetseqRange
12790 */
12791 
ajSeqallGetRange(const AjPSeqall seq,ajint * begin,ajint * end)12792 __deprecated ajint  ajSeqallGetRange(const AjPSeqall seq,
12793 				    ajint* begin, ajint* end)
12794 {
12795     return ajSeqallGetseqRange(seq, begin, end);
12796 }
12797 
12798 
12799 
12800 
12801 /* @obsolete ajSeqsetToLower
12802 ** @rename ajSeqsetFmtLower
12803 */
ajSeqsetToLower(AjPSeqset seqset)12804 __deprecated void  ajSeqsetToLower(AjPSeqset seqset)
12805 {
12806     ajSeqsetFmtLower(seqset);
12807 
12808     return;
12809 }
12810 
12811 
12812 
12813 
12814 /* @obsolete ajSeqsetToUpper
12815 ** @rename ajSeqsetFmtUpper
12816 */
ajSeqsetToUpper(AjPSeqset seqset)12817 __deprecated void  ajSeqsetToUpper(AjPSeqset seqset)
12818 {
12819     ajSeqsetFmtUpper(seqset);
12820 
12821     return;
12822 }
12823 
12824 
12825 
12826 
12827 /* @obsolete ajSeqsetBegin
12828 ** @rename ajSeqsetGetBegin
12829 */
ajSeqsetBegin(const AjPSeqset seq)12830 __deprecated ajint  ajSeqsetBegin(const AjPSeqset seq)
12831 {
12832     return ajSeqsetGetBegin(seq);
12833 }
12834 
12835 
12836 
12837 
12838 /* @obsolete ajSeqsetEnd
12839 ** @rename ajSeqsetGetEnd
12840 */
ajSeqsetEnd(const AjPSeqset seq)12841 __deprecated ajint  ajSeqsetEnd(const AjPSeqset seq)
12842 {
12843     return ajSeqsetGetEnd(seq);
12844 }
12845 
12846 
12847 
12848 
12849 /* @obsolete ajSeqsetLen
12850 ** @rename ajSeqsetGetLen
12851 */
12852 
ajSeqsetLen(const AjPSeqset seq)12853 __deprecated ajint  ajSeqsetLen(const AjPSeqset seq)
12854 {
12855     return ajSeqsetGetLen(seq);
12856 }
12857 
12858 
12859 
12860 
12861 /* @obsolete ajSeqsetGetName
12862 ** @rename ajSeqsetGetNameS
12863 */
ajSeqsetGetName(const AjPSeqset thys)12864 __deprecated const AjPStr  ajSeqsetGetName(const AjPSeqset thys)
12865 {
12866     return ajSeqsetGetNameS(thys);
12867 }
12868 
12869 
12870 
12871 
12872 /* @obsolete ajSeqsetGetSeqArray
12873 ** @rename ajSeqsetGetSeqarray
12874 */
ajSeqsetGetSeqArray(const AjPSeqset thys)12875 __deprecated AjPSeq*  ajSeqsetGetSeqArray(const AjPSeqset thys)
12876 {
12877     return ajSeqsetGetSeqarray(thys);
12878 }
12879 
12880 
12881 
12882 
12883 /* @obsolete ajSeqsetSize
12884 ** @rename ajSeqsetGetSize
12885 */
12886 
ajSeqsetSize(const AjPSeqset seq)12887 __deprecated ajint  ajSeqsetSize(const AjPSeqset seq)
12888 {
12889     return ajSeqsetGetSize(seq);
12890 }
12891 
12892 
12893 
12894 
12895 /* @obsolete ajSeqsetTotweight
12896 ** @rename ajSeqsetGetTotweight
12897 */
ajSeqsetTotweight(const AjPSeqset seq)12898 __deprecated float  ajSeqsetTotweight(const AjPSeqset seq)
12899 {
12900     return ajSeqsetGetTotweight(seq);
12901 }
12902 
12903 
12904 
12905 
12906 /* @obsolete ajSeqsetAcc
12907 ** @rename ajSeqsetGetseqAccS
12908 */
ajSeqsetAcc(const AjPSeqset seq,ajint i)12909 __deprecated const AjPStr  ajSeqsetAcc(const AjPSeqset seq, ajint i)
12910 {
12911     return ajSeqsetGetseqAccS(seq, i);
12912 }
12913 
12914 
12915 
12916 
12917 /* @obsolete ajSeqsetName
12918 ** @rename ajSeqsetGetseqNameS
12919 */
ajSeqsetName(const AjPSeqset seq,ajint i)12920 __deprecated const AjPStr  ajSeqsetName(const AjPSeqset seq, ajint i)
12921 {
12922     return ajSeqsetGetseqNameS(seq, i);
12923 }
12924 
12925 
12926 
12927 
12928 /* @obsolete ajSeqsetGetSeq
12929 ** @rename ajSeqsetGetseqSeq
12930 */
ajSeqsetGetSeq(const AjPSeqset thys,ajint i)12931 __deprecated const AjPSeq  ajSeqsetGetSeq(const AjPSeqset thys, ajint i)
12932 {
12933     return ajSeqsetGetseqSeq(thys, i);
12934 }
12935 
12936 
12937 
12938 
12939 /* @obsolete ajSeqsetSeq
12940 ** @rename ajSeqsetGetseqSeqC
12941 */
ajSeqsetSeq(const AjPSeqset thys,ajint i)12942 __deprecated const char*   ajSeqsetSeq(const AjPSeqset thys, ajint i)
12943 {
12944     return ajSeqsetGetseqSeqC(thys, i);
12945 }
12946 
12947 
12948 
12949 
12950 /* @obsolete ajSeqsetWeight
12951 ** @rename ajSeqsetGetseqWeight
12952 */
ajSeqsetWeight(const AjPSeqset seq,ajint i)12953 __deprecated float  ajSeqsetWeight(const AjPSeqset seq, ajint i)
12954 {
12955     return ajSeqsetGetseqWeight(seq, i);
12956 }
12957 
12958 
12959 
12960 
12961 /* @obsolete ajSeqNumS
12962 ** @rename ajSeqstrConvertNum
12963 */
12964 
ajSeqNumS(const AjPStr seqstr,const AjPSeqCvt cvt,AjPStr * numseq)12965 __deprecated AjBool  ajSeqNumS(const AjPStr seqstr,
12966 			     const AjPSeqCvt cvt,
12967 			     AjPStr* numseq)
12968 {
12969     return ajSeqstrConvertNum(seqstr, cvt, numseq);
12970 }
12971 
12972 
12973 
12974 
12975 /* @obsolete ajSeqCvtTrace
12976 ** @rename ajSeqcvtTrace
12977 */
ajSeqCvtTrace(const AjPSeqCvt cvt)12978 __deprecated void  ajSeqCvtTrace(const AjPSeqCvt cvt)
12979 {
12980     ajSeqcvtTrace(cvt);
12981 
12982     return;
12983 }
12984 
12985 
12986 
12987 
12988 /* @obsolete ajSeqCvtNewZero
12989 ** @rename ajSeqcvtNewC
12990 */
ajSeqCvtNewZero(const char * bases)12991 __deprecated AjPSeqCvt  ajSeqCvtNewZero(const char* bases)
12992 {
12993     return ajSeqcvtNewC(bases);
12994 }
12995 
12996 
12997 
12998 
12999 /* @obsolete ajSeqCvtNew
13000 ** @rename ajSeqcvtNewEndC
13001 */
ajSeqCvtNew(const char * bases)13002 __deprecated AjPSeqCvt  ajSeqCvtNew(const char* bases)
13003 {
13004     return ajSeqcvtNewEndC(bases);
13005 }
13006 
13007 
13008 
13009 
13010 /* @obsolete ajSeqCvtNewText
13011 ** @rename ajSeqcvtNewNumberC
13012 */
ajSeqCvtNewText(const char * bases)13013 __deprecated AjPSeqCvt  ajSeqCvtNewText(const char* bases)
13014 {
13015     return ajSeqcvtNewNumberC(bases);
13016 }
13017 
13018 
13019 
13020 
13021 /* @obsolete ajSeqCvtNewZeroS
13022 ** @rename ajSeqcvtNewStr
13023 */
ajSeqCvtNewZeroS(const AjPPStr bases,ajint n)13024 __deprecated AjPSeqCvt  ajSeqCvtNewZeroS (const AjPPStr bases, ajint n)
13025 {
13026     return ajSeqcvtNewStr(bases, n);
13027 }
13028 
13029 
13030 
13031 
13032 /* @obsolete ajSeqCvtNewZeroSS
13033 ** @rename ajSeqcvtNewStrAsym
13034 */
ajSeqCvtNewZeroSS(const AjPPStr bases,int n,const AjPPStr rbases,int rn)13035 __deprecated AjPSeqCvt  ajSeqCvtNewZeroSS (const AjPPStr bases, int n,
13036 			     const AjPPStr rbases, int rn)
13037 {
13038     return ajSeqcvtNewStrAsym (bases, n, rbases, rn);
13039 }
13040 
13041 
13042 
13043 
13044 /* @obsolete ajSeqCvtDel
13045 ** @rename ajSeqcvtDel
13046 */
ajSeqCvtDel(AjPSeqCvt * Pcvt)13047 __deprecated void  ajSeqCvtDel (AjPSeqCvt* Pcvt)
13048 {
13049     ajSeqcvtDel(Pcvt);
13050 
13051     return;
13052 }
13053 
13054 
13055 
13056 
13057 /* @obsolete ajSeqCvtK
13058 ** @rename ajSeqcvtGetCodeK
13059 */
ajSeqCvtK(const AjPSeqCvt cvt,char ch)13060 __deprecated ajint  ajSeqCvtK(const AjPSeqCvt cvt, char ch)
13061 {
13062     return ajSeqcvtGetCodeK(cvt, ch);
13063 }
13064 
13065 
13066 
13067 
13068 /* @obsolete ajSeqCvtKS
13069 ** @rename ajSeqcvtGetCodeS
13070 */
ajSeqCvtKS(const AjPSeqCvt cvt,const AjPStr ch)13071 __deprecated ajint  ajSeqCvtKS (const AjPSeqCvt cvt, const AjPStr ch)
13072 {
13073     return(ajSeqcvtGetCodeS(cvt, ch));
13074 }
13075 
13076 
13077 
13078 
13079 /* @obsolete ajSeqCvtKSRow
13080 ** @rename ajSeqcvtGetCodeS
13081 */
ajSeqCvtKSRow(const AjPSeqCvt cvt,const AjPStr ch)13082 __deprecated ajint  ajSeqCvtKSRow (const AjPSeqCvt cvt, const AjPStr ch)
13083 {
13084     return(ajSeqcvtGetCodeS(cvt, ch));
13085 }
13086 
13087 
13088 
13089 
13090 /* @obsolete ajSeqCvtKSColumn
13091 ** @rename ajSeqcvtGetCodeAsymS
13092 */
ajSeqCvtKSColumn(const AjPSeqCvt cvt,const AjPStr ch)13093 __deprecated ajint  ajSeqCvtKSColumn (const AjPSeqCvt cvt, const AjPStr ch)
13094 {
13095     return ajSeqcvtGetCodeAsymS(cvt, ch);
13096 }
13097 
13098 
13099 
13100 
13101 /* @obsolete ajSeqCvtLen
13102 ** @rename ajSeqcvtGetLen
13103 */
ajSeqCvtLen(const AjPSeqCvt cvt)13104 __deprecated ajint  ajSeqCvtLen(const AjPSeqCvt cvt)
13105 {
13106     return ajSeqcvtGetLen(cvt);
13107 }
13108 
13109 
13110 
13111 
13112 /* @obsolete ajIsAccession
13113 ** @rename ajSeqtestIsAccession
13114 */
ajIsAccession(const AjPStr accnum)13115 __deprecated AjBool  ajIsAccession(const AjPStr accnum)
13116 {
13117     return ajSeqtestIsAccession(accnum);
13118 }
13119 
13120 
13121 
13122 
13123 /* @obsolete ajIsSeqversion
13124 ** @rename ajSeqtestIsSeqversion
13125 */
ajIsSeqversion(const AjPStr sv)13126 __deprecated const AjPStr  ajIsSeqversion(const AjPStr sv)
13127 {
13128     return ajSeqtestIsSeqversion(sv);
13129 }
13130 
13131 
13132 
13133 
13134 /* @obsolete ajSeqMW
13135 ** @rename ajSeqstrCalcMolwt
13136 */
ajSeqMW(const AjPStr seq)13137 __deprecated float  ajSeqMW(const AjPStr seq)
13138 {
13139     return ajSeqstrCalcMolwt(seq);
13140 }
13141 
13142 
13143 
13144 
13145 /* @obsolete ajSeqGapCountS
13146 ** @rename ajSeqstrCountGaps
13147 */
ajSeqGapCountS(const AjPStr str)13148 __deprecated ajint  ajSeqGapCountS(const AjPStr str)
13149 {
13150     return ajSeqstrCountGaps(str);
13151 }
13152 
13153 
13154 
13155 
13156 /* @obsolete ajSeqstrComplementOnly
13157 ** @rename ajSeqstrComplement
13158 */
ajSeqstrComplementOnly(AjPStr * pthis)13159 __deprecated void  ajSeqstrComplementOnly(AjPStr* pthis)
13160 {
13161     ajSeqstrComplement(pthis);
13162     return;
13163 }
13164 
13165 
13166 
13167 
13168 /* @obsolete ajSeqCompOnlyStr
13169 ** @rename ajSeqstrComplement
13170 */
ajSeqCompOnlyStr(AjPStr * pthis)13171 __deprecated void  ajSeqCompOnlyStr(AjPStr* pthis)
13172 {
13173     ajSeqstrComplement(pthis);
13174 
13175     return;
13176 }
13177 
13178 
13179 
13180 
13181 /* @obsolete ajSeqReverseStr
13182 ** @rename ajSeqstrReverse
13183 */
ajSeqReverseStr(AjPStr * pthis)13184 __deprecated void  ajSeqReverseStr(AjPStr* pthis)
13185 {
13186     ajSeqstrReverse(pthis);
13187 
13188     return;
13189 }
13190 
13191 
13192 
13193 
13194 /* @obsolete ajSeqCrc
13195 ** @rename ajSeqstrCalcCrc
13196 */
ajSeqCrc(const AjPStr seq)13197 __deprecated ajuint  ajSeqCrc(const AjPStr seq)
13198 {
13199     (void) seq;				/* just so it is used */
13200 
13201     return 0;
13202 }
13203 
13204 
13205 
13206 
13207 /* @obsolete ajSeqGapStandardS
13208 ** @remove only used internally
13209 */
ajSeqGapStandardS(AjPStr thys,char gapch)13210 __deprecated void  ajSeqGapStandardS(AjPStr thys, char gapch)
13211 {
13212     char newgap = '-';
13213     static char testchars[] = "-~.? "; /* all known gap characters */
13214     char *testgap;
13215 
13216     testgap = testchars;
13217 
13218     if(gapch)
13219 	newgap = gapch;
13220 
13221     /*ajDebug("ajSeqGapStandardS '%c'=>'%c' '%S'\n",
13222             gapch, newgap, thys->Seq);*/
13223 
13224     while(*testgap)
13225     {
13226 	if(newgap != *testgap)
13227 	{
13228 	    ajStrExchangeKK(&thys, *testgap, newgap);
13229 	    /*ajDebug(" ajSeqGapStandardS replaced         '%c'=>'%c' '%S'\n",
13230 		    *testgap, newgap, thys);*/
13231 	}
13232 
13233         testgap++;
13234     }
13235 
13236     return;
13237 }
13238 
13239 
13240 
13241 
13242 /* @obsolete ajSeqCalcCrc
13243 ** @remove use 64bit call
13244 */
ajSeqCalcCrc(const AjPSeq seq)13245 __deprecated ajuint  ajSeqCalcCrc(const AjPSeq seq)
13246 {
13247     (void) seq;				/* just so it is used */
13248 
13249     return 0;
13250 }
13251 
13252 #endif /* AJ_COMPILE_DEPRECATED */
13253