CLUSTAL Alignment (several examples)


Sample code :


/**
  * Here is some samples of how to use the functions
  * @param SequenceAlignmentInterface $sequenceAlignmentManager
  * @return Response
  * @throws \Exception
  */
public function clustalseqalignment(SequenceAlignmentInterface $sequenceAlignmentManager)
{
    set_time_limit(0); // we never know ...
    $sequenceAlignmentManager->setFilename("data/clustal.txt");
    $sequenceAlignmentManager->setFormat("CLUSTAL");
    $sequenceAlignmentManager->parseFile();
 
    // You wanna sort your array ? :)
    $sequenceAlignmentManager->sortAlpha("ASC");
    $sequenceAlSort = $sequenceAlignmentManager->getSeqSet();
    // You wanna fetch something ?
    $oOffset13 = $sequenceAlignmentManager->getSeqSet()->offsetGet(13);
    // You wanna know the longest sequence ?
    $iMaxLength = $sequenceAlignmentManager->getMaxiLength();
    // You wanna know the number of gaps ?
    $iNumberGaps = $sequenceAlignmentManager->getGapCount();
    // Have the same length ?
    $bIsFlush = $sequenceAlignmentManager->getIsFlush();
    // Char at res 10 (10th sequence)
    $sCharAtRes = $sequenceAlignmentManager->charAtRes(10, 10);
    // Substring between two residues in a sequence
    $sSubstrBwRes = $sequenceAlignmentManager->substrBwRes(10,10);
    // Converts a column number to a residue number in a sequence
    $iColToRes = $sequenceAlignmentManager->colToRes(10, 50);
    // Converts a residue number to a column number in a sequence
    $iResToCol = $sequenceAlignmentManager->resToCol(10, 47);
    // Creates a new alignment set from index 5 to 10
    $sequenceAlignmentManager->subalign(5, 10);
    $oSubALign = $sequenceAlignmentManager;
    // Creates a new alignment with selected indexes
    $sequenceAlignmentManager->select(1,2,3);
    $oSelectAlign = $sequenceAlignmentManager;
 
    // Determines the index position of both variant and invariant residues according
    // to a given "percentage threshold" similar to that in the consensus() method.
    $aResVar = $sequenceAlignmentManager->resVar();
 
    // Returns the consensus string for an alignment set
    $aConsensus = $sequenceAlignmentManager->consensus();
 
    // Adding a new sequence object
    $sequenceAlignmentManager->addSequence($oOffset13);
    $sequenceAlignmentManagerAdd = $sequenceAlignmentManager;
    // Dropping a sequence
    $sequenceAlignmentManager->deleteSequence("sp|P04637|P53_HUMAN");
    $sequenceAlignmentManagerDel = $sequenceAlignmentManager;
 
 
    return $this->render('default/clustalseqalignment.html.twig',
        [
            'sequenceAlSort'              => $sequenceAlSort,
            'offset13'                    => $oOffset13,
            'maxLength'                   => $iMaxLength,
            'numberGaps'                  => $iNumberGaps,
            'isFlush'                     => $bIsFlush,
            'sCharAtRes'                  => $sCharAtRes,
            'sSubstrBwRes'                => $sSubstrBwRes,
            'colToRes'                    => $iColToRes,
            'resToCol'                    => $iResToCol,
            'subALign'                    => $oSubALign,
            'selectAlign'                 => $oSelectAlign,
            'resVar'                      => $aResVar,
            'consensus'                   => $aConsensus,
            'sequenceAlignmentManagerAdd' => $sequenceAlignmentManagerAdd,
            'sequenceAlignmentManagerDel' => $sequenceAlignmentManagerDel
        ]
    );
}

Result :

Sort sequences :

  • 0 : {}
  • 1 : {}
  • 2 : {}
  • 3 : {}
  • 4 : {}
  • 5 : {}
  • 6 : {}
  • 7 : {}
  • 8 : {}
  • 9 : {}
  • 10 : {}
  • 11 : {}
  • 12 : {}
  • 13 : {}
  • 14 : {}
  • 15 : {}
  • 16 : {}
  • 17 : {}
  • 18 : {}
  • 19 : {}
  • 20 : {}
  • 21 : {}
  • 22 : {}
  • 23 : {}
  • 24 : {}
  • 25 : {}
  • 26 : {}
  • 27 : {}
  • 28 : {}
  • 29 : {}
  • 30 : {}
  • 31 : {}
  • 32 : {}
  • 33 : {}

13th sequence

Length of the longuest sequence

Number of gaps

Do the sequences have the same length ?

Char at res 10 (10th sequence)

Substring between two residues in a sequence

Converts a column number to a residue number in a sequence

Converts a residue number to a column number in a sequence

Creates a new alignment set from index 5 to 10

Creates a new alignment with selected indexes

Determines the index position of both variant and invariant residues according to a given "percentage threshold" similar to that in the consensus() method.

  • INVARIANT
    • 0 : 2
    • 1 : 11
    • 2 : 17
    • 3 : 19
    • 4 : 21
    • 5 : 22
    • 6 : 23
    • 7 : 26
    • 8 : 27
    • 9 : 38
    • 10 : 41
    • 11 : 67
    • 12 : 85
    • 13 : 86
    • 14 : 87
    • 15 : 88
    • 16 : 89
    • 17 : 90
    • 18 : 91
    • 19 : 106
    • 20 : 109
    • 21 : 110
    • 22 : 111
    • 23 : 115
    • 24 : 117
    • 25 : 125
    • 26 : 129
    • 27 : 130
    • 28 : 131
    • 29 : 132
    • 30 : 133
    • 31 : 134
    • 32 : 135
    • 33 : 136
    • 34 : 137
    • 35 : 138
    • 36 : 139
    • 37 : 140
    • 38 : 142
    • 39 : 143
    • 40 : 144
    • 41 : 147
    • 42 : 149
    • 43 : 150
    • 44 : 151
    • 45 : 153
    • 46 : 154
    • 47 : 159
    • 48 : 163
    • 49 : 164
    • 50 : 166
    • 51 : 170
    • 52 : 171
    • 53 : 173
    • 54 : 175
    • 55 : 176
    • 56 : 178
    • 57 : 180
    • 58 : 183
    • 59 : 184
    • 60 : 185
    • 61 : 187
    • 62 : 188
    • 63 : 189
    • 64 : 190
    • 65 : 191
    • 66 : 192
    • 67 : 193
    • 68 : 202
    • 69 : 203
    • 70 : 206
    • 71 : 207
    • 72 : 209
    • 73 : 210
    • 74 : 211
    • 75 : 212
    • 76 : 213
    • 77 : 218
    • 78 : 221
    • 79 : 226
    • 80 : 227
    • 81 : 228
    • 82 : 229
    • 83 : 231
    • 84 : 232
    • 85 : 233
    • 86 : 234
    • 87 : 236
    • 88 : 238
    • 89 : 239
    • 90 : 242
    • 91 : 243
    • 92 : 244
    • 93 : 247
    • 94 : 248
    • 95 : 250
    • 96 : 251
    • 97 : 252
    • 98 : 253
    • 99 : 254
    • 100 : 255
    • 101 : 256
    • 102 : 257
    • 103 : 258
    • 104 : 259
    • 105 : 260
    • 106 : 261
    • 107 : 262
    • 108 : 263
    • 109 : 264
    • 110 : 265
    • 111 : 266
    • 112 : 267
    • 113 : 269
    • 114 : 270
    • 115 : 271
    • 116 : 275
    • 117 : 277
    • 118 : 278
    • 119 : 279
    • 120 : 280
    • 121 : 283
    • 122 : 284
    • 123 : 285
    • 124 : 286
    • 125 : 287
    • 126 : 288
    • 127 : 289
    • 128 : 290
    • 129 : 291
    • 130 : 292
    • 131 : 293
    • 132 : 294
    • 133 : 295
    • 134 : 298
    • 135 : 299
    • 136 : 301
    • 137 : 304
    • 138 : 314
    • 139 : 315
    • 140 : 316
    • 141 : 321
    • 142 : 322
    • 143 : 327
    • 144 : 328
    • 145 : 333
    • 146 : 336
    • 147 : 341
    • 148 : 350
    • 149 : 352
    • 150 : 354
    • 151 : 356
    • 152 : 360
    • 153 : 361
    • 154 : 363
    • 155 : 365
    • 156 : 366
    • 157 : 371
    • 158 : 373
    • 159 : 374
    • 160 : 376
    • 161 : 399
    • 162 : 400
    • 163 : 412
    • 164 : 413
    • 165 : 414
    • 166 : 417
    • 167 : 425
  • VARIANT
    • 0 : 0
    • 1 : 1
    • 2 : 3
    • 3 : 4
    • 4 : 5
    • 5 : 6
    • 6 : 7
    • 7 : 8
    • 8 : 9
    • 9 : 10
    • 10 : 12
    • 11 : 13
    • 12 : 14
    • 13 : 15
    • 14 : 16
    • 15 : 18
    • 16 : 20
    • 17 : 24
    • 18 : 25
    • 19 : 28
    • 20 : 29
    • 21 : 30
    • 22 : 31
    • 23 : 32
    • 24 : 33
    • 25 : 34
    • 26 : 35
    • 27 : 36
    • 28 : 37
    • 29 : 39
    • 30 : 40
    • 31 : 42
    • 32 : 43
    • 33 : 44
    • 34 : 45
    • 35 : 46
    • 36 : 47
    • 37 : 48
    • 38 : 49
    • 39 : 50
    • 40 : 51
    • 41 : 52
    • 42 : 53
    • 43 : 54
    • 44 : 55
    • 45 : 56
    • 46 : 57
    • 47 : 58
    • 48 : 59
    • 49 : 60
    • 50 : 61
    • 51 : 62
    • 52 : 63
    • 53 : 64
    • 54 : 65
    • 55 : 66
    • 56 : 68
    • 57 : 69
    • 58 : 70
    • 59 : 71
    • 60 : 72
    • 61 : 73
    • 62 : 74
    • 63 : 75
    • 64 : 76
    • 65 : 77
    • 66 : 78
    • 67 : 79
    • 68 : 80
    • 69 : 81
    • 70 : 82
    • 71 : 83
    • 72 : 84
    • 73 : 92
    • 74 : 93
    • 75 : 94
    • 76 : 95
    • 77 : 96
    • 78 : 97
    • 79 : 98
    • 80 : 99
    • 81 : 100
    • 82 : 101
    • 83 : 102
    • 84 : 103
    • 85 : 104
    • 86 : 105
    • 87 : 107
    • 88 : 108
    • 89 : 112
    • 90 : 113
    • 91 : 114
    • 92 : 116
    • 93 : 118
    • 94 : 119
    • 95 : 120
    • 96 : 121
    • 97 : 122
    • 98 : 123
    • 99 : 124
    • 100 : 126
    • 101 : 127
    • 102 : 128
    • 103 : 141
    • 104 : 145
    • 105 : 146
    • 106 : 148
    • 107 : 152
    • 108 : 155
    • 109 : 156
    • 110 : 157
    • 111 : 158
    • 112 : 160
    • 113 : 161
    • 114 : 162
    • 115 : 165
    • 116 : 167
    • 117 : 168
    • 118 : 169
    • 119 : 172
    • 120 : 174
    • 121 : 177
    • 122 : 179
    • 123 : 181
    • 124 : 182
    • 125 : 186
    • 126 : 194
    • 127 : 195
    • 128 : 196
    • 129 : 197
    • 130 : 198
    • 131 : 199
    • 132 : 200
    • 133 : 201
    • 134 : 204
    • 135 : 205
    • 136 : 208
    • 137 : 214
    • 138 : 215
    • 139 : 216
    • 140 : 217
    • 141 : 219
    • 142 : 220
    • 143 : 222
    • 144 : 223
    • 145 : 224
    • 146 : 225
    • 147 : 230
    • 148 : 235
    • 149 : 237
    • 150 : 240
    • 151 : 241
    • 152 : 245
    • 153 : 246
    • 154 : 249
    • 155 : 268
    • 156 : 272
    • 157 : 273
    • 158 : 274
    • 159 : 276
    • 160 : 281
    • 161 : 282
    • 162 : 296
    • 163 : 297
    • 164 : 300
    • 165 : 302
    • 166 : 303
    • 167 : 305
    • 168 : 306
    • 169 : 307
    • 170 : 308
    • 171 : 309
    • 172 : 310
    • 173 : 311
    • 174 : 312
    • 175 : 313
    • 176 : 317
    • 177 : 318
    • 178 : 319
    • 179 : 320
    • 180 : 323
    • 181 : 324
    • 182 : 325
    • 183 : 326
    • 184 : 329
    • 185 : 330
    • 186 : 331
    • 187 : 332
    • 188 : 334
    • 189 : 335
    • 190 : 337
    • 191 : 338
    • 192 : 339
    • 193 : 340
    • 194 : 342
    • 195 : 343
    • 196 : 344
    • 197 : 345
    • 198 : 346
    • 199 : 347
    • 200 : 348
    • 201 : 349
    • 202 : 351
    • 203 : 353
    • 204 : 355
    • 205 : 357
    • 206 : 358
    • 207 : 359
    • 208 : 362
    • 209 : 364
    • 210 : 367
    • 211 : 368
    • 212 : 369
    • 213 : 370
    • 214 : 372
    • 215 : 375
    • 216 : 377
    • 217 : 378
    • 218 : 379
    • 219 : 380
    • 220 : 381
    • 221 : 382
    • 222 : 383
    • 223 : 384
    • 224 : 385
    • 225 : 386
    • 226 : 387
    • 227 : 388
    • 228 : 389
    • 229 : 390
    • 230 : 391
    • 231 : 392
    • 232 : 393
    • 233 : 394
    • 234 : 395
    • 235 : 396
    • 236 : 397
    • 237 : 398
    • 238 : 401
    • 239 : 402
    • 240 : 403
    • 241 : 404
    • 242 : 405
    • 243 : 406
    • 244 : 407
    • 245 : 408
    • 246 : 409
    • 247 : 410
    • 248 : 411
    • 249 : 415
    • 250 : 416
    • 251 : 418
    • 252 : 419
    • 253 : 420
    • 254 : 421
    • 255 : 422
    • 256 : 423
    • 257 : 424

Returns the consensus string for an alignment set

Adding a new sequence object

Dropping a sequence