1 /* -*- mode: c; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
3 /*********************************************************************
4 * Clustal Omega - Multiple sequence alignment
6 * Copyright (C) 2010 University College Dublin
8 * Clustal-Omega is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of the
11 * License, or (at your option) any later version.
13 * This file is part of Clustal-Omega.
15 ********************************************************************/
18 * RCS $Id: hhalignment.h 154 2010-11-09 18:29:05Z fabian $
26 int L; // number of match states of alignment
27 int N_in; // total number of sequences in alignment
28 int N_filtered; /* number of sequences after sequence identity
30 int N_ss; // number of >ss_ or >sa sequences
32 int kss_dssp; /* index of sequence with secondary structure
33 by dssp -1:no >ss_dssp line found */
34 int ksa_dssp; /* index of sequence with solvent accessibility
35 by dssp -1:no >sa_dssp line found */
36 int kss_pred; /* index of sequence with predicted secondary
37 structure -1:no >ss_pred line found */
38 int kss_conf; /* index of sequence with confidence values of
39 prediction -1:no >ss_conf line found */
40 int kfirst; // index of first real sequence
42 char* longname; /* Full name of first sequence of original alignment
44 char name[NAMELEN]; // HMM name = first word in longname in lower case
45 char fam[NAMELEN]; // family ID (derived from name) (FAM field)
46 char file[NAMELEN]; /* Rootname (w/o path, with extension) of alignment
47 file that is used to construct the HMM */
49 int n_display; /* number of sequences to be displayed
50 (INCLUDING >ss_pred, >ss_conf, >ss_dssp sequences) */
51 char** sname; // names of display sequences (first seq=0, first char=0)
52 char** seq; // residues of display sequences (first char=1)
53 int* l; // l[i] = position of i'th match state in alignment
55 char* keep; /* keep[k]=1 if sequence is included in amino acid
56 frequencies; 0 otherwise (first=0) */
58 double *pdExWeight; /* external sequence weight as given by tree FIXME (FS) */
60 Alignment(int maxseq=MAXSEQ, int maxres=/*MAXRES*/par.maxResLen);
63 // Read alignment into X (uncompressed) in ASCII characters
64 void Read(FILE* inf, char infile[NAMELEN], char* line=NULL);
66 void Transfer(char **ppcProf, int iCnt);
70 /* Convert ASCII to numbers between 0 and 20, throw out all insert states,
71 record their number in I[k][i] and store sequences to be displayed
72 in sname[k] and seq[k] */
73 void Compress(const char infile[NAMELEN]);
75 // Apply sequence identity filter
76 inline int FilterForDisplay(int max_seqid, int coverage=0, int qid=0, float qsc=0, int N=0);
77 inline int Filter(int max_seqid, int coverage=0, int qid=0, float qsc=0, int N=0);
78 int Filter2(char keep[], int coverage, int qid, float qsc, int seqid1, int seqid2, int Ndiff);
80 bool FilterNeff(); /* MR1 */
81 float filter_by_qsc(float qsc, char* dummy); /* MR1 */
83 // Filter alignment for min score per column with core query profile, defined by min_coverage_core and min_seqid_core
84 int HomologyFilter(int coverage_core, float qsc_core, float coresc);
86 // Calculate AA frequencies q.p[i][a] and transition probabilities q.tr[i][a] from alignment
87 void FrequenciesAndTransitions(HMM& q, char* in=NULL);
89 // Calculate freqs q.f[i][a] and transitions q.tr[i][a] (a=MM,MI,MD) with pos-specific subalignments
90 void Amino_acid_frequencies_and_transitions_from_M_state(HMM& q, char* in);
92 // Calculate transitions q.tr[i][a] (a=DM,DD) with pos-specific subalignments
93 void Transitions_from_D_state(HMM& q, char* in);
95 // Calculate transitions q.tr[i][a] (a=DM,DD) with pos-specific subalignments
96 void Transitions_from_I_state(HMM& q, char* in);
98 // Write alignment without insert states to alignment file
99 void WriteWithoutInsertsToFile(char* alnfile);
101 // Write alignment to alignment file
102 void WriteToFile(char* alnfile, const char format[]=NULL);
104 // Read a3m slave alignment of hit from ta3mfile and merge into (query) master alignment
105 void MergeMasterSlave(Hit& hit, char ta3mfile[]);
107 // Read a3m alignment of hit from ta3mfile and merge-combine with query alignment
108 void Merge(Hit& hit, char ta3mfile[]);
110 // Add a sequence to Qali
111 void AddSequence(char Xk[], int Ik[]=NULL);
113 // Determine matrix of position-specific weights w[k][i] for multiple alignment
114 void GetPositionSpecificWeights(float* w[]);
116 char readCommentLine; // Set to 1, if a comment line with '#' is read /* MR1 */
119 char** X; // X[k][i] contains column i of sequence k in alignment (first seq=0, first char=1) (0-3: ARND ..., 20:X, 21:GAP)
120 short unsigned int** I; // I[k][i] contains the number of inserts AFTER match state i (first=0)
121 char* display; // display[k]=1 if sequence will be displayed in output alignments; 0 otherwise (first=0)
122 float* wg; // w[k] = global weight of sequence k
123 int* nseqs; // number of sequences in subalignment i (only for DEBUGGING)
124 int* nres; // number of residues in sequence k
125 int* first; // first residue in sequence k
126 int* last; // last residue in sequence k
127 int* ksort; // index for sorting sequences: X[ksort[k]]
128 int FilterWithCoreHMM(char in[], float coresc, HMM& qcore);