| 1 | <HTML> |
| 2 | |
| 3 | <HEAD> |
| 4 | <TITLE> |
| 5 | EMBOSS: preg |
| 6 | </TITLE> |
| 7 | </HEAD> |
| 8 | <BODY BGCOLOR="#FFFFFF" text="#000000"> |
| 9 | |
| 10 | <table align=center border=0 cellspacing=0 cellpadding=0> |
| 11 | <tr><td valign=top> |
| 12 | <A HREF="/" ONMOUSEOVER="self.status='Go to the EMBOSS home page';return true"><img border=0 src="/images/emboss_icon.jpg" alt="" width=150 height=48></a> |
| 13 | </td> |
| 14 | <td align=left valign=middle> |
| 15 | <b><font size="+6"> |
| 16 | preg |
| 17 | </font></b> |
| 18 | </td></tr> |
| 19 | </table> |
| 20 | <br> |
| 21 | <p> |
| 22 | |
| 23 | |
| 24 | <H2> |
| 25 | Wiki |
| 26 | </H2> |
| 27 | |
| 28 | The master copies of EMBOSS documentation are available |
| 29 | at <a href="http://emboss.open-bio.org/wiki/Appdocs"> |
| 30 | http://emboss.open-bio.org/wiki/Appdocs</a> |
| 31 | on the EMBOSS Wiki. |
| 32 | |
| 33 | <p> |
| 34 | Please help by correcting and extending the Wiki pages. |
| 35 | |
| 36 | <H2> |
| 37 | Function |
| 38 | </H2> |
| 39 | Regular expression search of protein sequence(s) |
| 40 | |
| 41 | <H2> |
| 42 | Description |
| 43 | </H2> |
| 44 | |
| 45 | |
| 46 | <p><b>preg</b> searches for matches of the supplied regular expression to the input protein sequence(s). A regular expression is a way of specifying an ambiguous pattern to search for. The output is a standard EMBOSS report file with details of any matches.</p> |
| 47 | |
| 48 | |
| 49 | |
| 50 | <H2> |
| 51 | Usage |
| 52 | </H2> |
| 53 | Here is a sample session with <b>preg</b> |
| 54 | <p> |
| 55 | |
| 56 | <p> |
| 57 | <table width="90%"><tr><td bgcolor="#CCFFFF"><pre> |
| 58 | |
| 59 | % <b>preg </b> |
| 60 | Regular expression search of protein sequence(s) |
| 61 | Input protein sequence(s): <b>tsw:*_rat</b> |
| 62 | Regular expression pattern: <b>IA[QWF]A</b> |
| 63 | Output report [arf3_rat.preg]: <b></b> |
| 64 | |
| 65 | </pre></td></tr></table><p> |
| 66 | <p> |
| 67 | <a href="#input.1">Go to the input files for this example</a><br><a href="#output.1">Go to the output files for this example</a><p><p> |
| 68 | |
| 69 | |
| 70 | <H2> |
| 71 | Command line arguments |
| 72 | </H2> |
| 73 | <table CELLSPACING=0 CELLPADDING=3 BGCOLOR="#f5f5ff" ><tr><td> |
| 74 | <pre> |
| 75 | Regular expression search of protein sequence(s) |
| 76 | Version: EMBOSS:6.6.0.0 |
| 77 | |
| 78 | Standard (Mandatory) qualifiers: |
| 79 | [-sequence] seqall Protein sequence(s) filename and optional |
| 80 | format, or reference (input USA) |
| 81 | [-pattern] regexp Any regular expression pattern is accepted) |
| 82 | [-outfile] report [*.preg] Output report file name (default |
| 83 | -rformat seqtable) |
| 84 | |
| 85 | Additional (Optional) qualifiers: (none) |
| 86 | Advanced (Unprompted) qualifiers: (none) |
| 87 | Associated qualifiers: |
| 88 | |
| 89 | "-sequence" associated qualifiers |
| 90 | -sbegin1 integer Start of each sequence to be used |
| 91 | -send1 integer End of each sequence to be used |
| 92 | -sreverse1 boolean Reverse (if DNA) |
| 93 | -sask1 boolean Ask for begin/end/reverse |
| 94 | -snucleotide1 boolean Sequence is nucleotide |
| 95 | -sprotein1 boolean Sequence is protein |
| 96 | -slower1 boolean Make lower case |
| 97 | -supper1 boolean Make upper case |
| 98 | -scircular1 boolean Sequence is circular |
| 99 | -squick1 boolean Read id and sequence only |
| 100 | -sformat1 string Input sequence format |
| 101 | -iquery1 string Input query fields or ID list |
| 102 | -ioffset1 integer Input start position offset |
| 103 | -sdbname1 string Database name |
| 104 | -sid1 string Entryname |
| 105 | -ufo1 string UFO features |
| 106 | -fformat1 string Features format |
| 107 | -fopenfile1 string Features file name |
| 108 | |
| 109 | "-pattern" associated qualifiers |
| 110 | -pformat2 string File format |
| 111 | -pname2 string Pattern base name |
| 112 | |
| 113 | "-outfile" associated qualifiers |
| 114 | -rformat3 string Report format |
| 115 | -rname3 string Base file name |
| 116 | -rextension3 string File name extension |
| 117 | -rdirectory3 string Output directory |
| 118 | -raccshow3 boolean Show accession number in the report |
| 119 | -rdesshow3 boolean Show description in the report |
| 120 | -rscoreshow3 boolean Show the score in the report |
| 121 | -rstrandshow3 boolean Show the nucleotide strand in the report |
| 122 | -rusashow3 boolean Show the full USA in the report |
| 123 | -rmaxall3 integer Maximum total hits to report |
| 124 | -rmaxseq3 integer Maximum hits to report for one sequence |
| 125 | |
| 126 | General qualifiers: |
| 127 | -auto boolean Turn off prompts |
| 128 | -stdout boolean Write first file to standard output |
| 129 | -filter boolean Read first file from standard input, write |
| 130 | first file to standard output |
| 131 | -options boolean Prompt for standard and additional values |
| 132 | -debug boolean Write debug output to program.dbg |
| 133 | -verbose boolean Report some/full command line options |
| 134 | -help boolean Report command line options and exit. More |
| 135 | information on associated and general |
| 136 | qualifiers can be found with -help -verbose |
| 137 | -warning boolean Report warnings |
| 138 | -error boolean Report errors |
| 139 | -fatal boolean Report fatal errors |
| 140 | -die boolean Report dying program messages |
| 141 | -version boolean Report version number and exit |
| 142 | |
| 143 | </pre> |
| 144 | </td></tr></table> |
| 145 | <P> |
| 146 | |
| 147 | <table border cellspacing=0 cellpadding=3 bgcolor="#ccccff"> |
| 148 | <tr bgcolor="#FFFFCC"> |
| 149 | <th align="left">Qualifier</th> |
| 150 | <th align="left">Type</th> |
| 151 | <th align="left">Description</th> |
| 152 | <th align="left">Allowed values</th> |
| 153 | <th align="left">Default</th> |
| 154 | </tr> |
| 155 | |
| 156 | <tr bgcolor="#FFFFCC"> |
| 157 | <th align="left" colspan=5>Standard (Mandatory) qualifiers</th> |
| 158 | </tr> |
| 159 | |
| 160 | <tr bgcolor="#FFFFCC"> |
| 161 | <td>[-sequence]<br>(Parameter 1)</td> |
| 162 | <td>seqall</td> |
| 163 | <td>Protein sequence(s) filename and optional format, or reference (input USA)</td> |
| 164 | <td>Readable sequence(s)</td> |
| 165 | <td><b>Required</b></td> |
| 166 | </tr> |
| 167 | |
| 168 | <tr bgcolor="#FFFFCC"> |
| 169 | <td>[-pattern]<br>(Parameter 2)</td> |
| 170 | <td>regexp</td> |
| 171 | <td>Regular expression pattern</td> |
| 172 | <td>Any regular expression pattern is accepted</td> |
| 173 | <td><b>Required</b></td> |
| 174 | </tr> |
| 175 | |
| 176 | <tr bgcolor="#FFFFCC"> |
| 177 | <td>[-outfile]<br>(Parameter 3)</td> |
| 178 | <td>report</td> |
| 179 | <td>Output report file name</td> |
| 180 | <td>(default -rformat seqtable)</td> |
| 181 | <td><i><*></i>.preg</td> |
| 182 | </tr> |
| 183 | |
| 184 | <tr bgcolor="#FFFFCC"> |
| 185 | <th align="left" colspan=5>Additional (Optional) qualifiers</th> |
| 186 | </tr> |
| 187 | |
| 188 | <tr> |
| 189 | <td colspan=5>(none)</td> |
| 190 | </tr> |
| 191 | |
| 192 | <tr bgcolor="#FFFFCC"> |
| 193 | <th align="left" colspan=5>Advanced (Unprompted) qualifiers</th> |
| 194 | </tr> |
| 195 | |
| 196 | <tr> |
| 197 | <td colspan=5>(none)</td> |
| 198 | </tr> |
| 199 | |
| 200 | <tr bgcolor="#FFFFCC"> |
| 201 | <th align="left" colspan=5>Associated qualifiers</th> |
| 202 | </tr> |
| 203 | |
| 204 | <tr bgcolor="#FFFFCC"> |
| 205 | <td align="left" colspan=5>"-sequence" associated seqall qualifiers |
| 206 | </td> |
| 207 | </tr> |
| 208 | |
| 209 | <tr bgcolor="#FFFFCC"> |
| 210 | <td> -sbegin1<br>-sbegin_sequence</td> |
| 211 | <td>integer</td> |
| 212 | <td>Start of each sequence to be used</td> |
| 213 | <td>Any integer value</td> |
| 214 | <td>0</td> |
| 215 | </tr> |
| 216 | |
| 217 | <tr bgcolor="#FFFFCC"> |
| 218 | <td> -send1<br>-send_sequence</td> |
| 219 | <td>integer</td> |
| 220 | <td>End of each sequence to be used</td> |
| 221 | <td>Any integer value</td> |
| 222 | <td>0</td> |
| 223 | </tr> |
| 224 | |
| 225 | <tr bgcolor="#FFFFCC"> |
| 226 | <td> -sreverse1<br>-sreverse_sequence</td> |
| 227 | <td>boolean</td> |
| 228 | <td>Reverse (if DNA)</td> |
| 229 | <td>Boolean value Yes/No</td> |
| 230 | <td>N</td> |
| 231 | </tr> |
| 232 | |
| 233 | <tr bgcolor="#FFFFCC"> |
| 234 | <td> -sask1<br>-sask_sequence</td> |
| 235 | <td>boolean</td> |
| 236 | <td>Ask for begin/end/reverse</td> |
| 237 | <td>Boolean value Yes/No</td> |
| 238 | <td>N</td> |
| 239 | </tr> |
| 240 | |
| 241 | <tr bgcolor="#FFFFCC"> |
| 242 | <td> -snucleotide1<br>-snucleotide_sequence</td> |
| 243 | <td>boolean</td> |
| 244 | <td>Sequence is nucleotide</td> |
| 245 | <td>Boolean value Yes/No</td> |
| 246 | <td>N</td> |
| 247 | </tr> |
| 248 | |
| 249 | <tr bgcolor="#FFFFCC"> |
| 250 | <td> -sprotein1<br>-sprotein_sequence</td> |
| 251 | <td>boolean</td> |
| 252 | <td>Sequence is protein</td> |
| 253 | <td>Boolean value Yes/No</td> |
| 254 | <td>N</td> |
| 255 | </tr> |
| 256 | |
| 257 | <tr bgcolor="#FFFFCC"> |
| 258 | <td> -slower1<br>-slower_sequence</td> |
| 259 | <td>boolean</td> |
| 260 | <td>Make lower case</td> |
| 261 | <td>Boolean value Yes/No</td> |
| 262 | <td>N</td> |
| 263 | </tr> |
| 264 | |
| 265 | <tr bgcolor="#FFFFCC"> |
| 266 | <td> -supper1<br>-supper_sequence</td> |
| 267 | <td>boolean</td> |
| 268 | <td>Make upper case</td> |
| 269 | <td>Boolean value Yes/No</td> |
| 270 | <td>N</td> |
| 271 | </tr> |
| 272 | |
| 273 | <tr bgcolor="#FFFFCC"> |
| 274 | <td> -scircular1<br>-scircular_sequence</td> |
| 275 | <td>boolean</td> |
| 276 | <td>Sequence is circular</td> |
| 277 | <td>Boolean value Yes/No</td> |
| 278 | <td>N</td> |
| 279 | </tr> |
| 280 | |
| 281 | <tr bgcolor="#FFFFCC"> |
| 282 | <td> -squick1<br>-squick_sequence</td> |
| 283 | <td>boolean</td> |
| 284 | <td>Read id and sequence only</td> |
| 285 | <td>Boolean value Yes/No</td> |
| 286 | <td>N</td> |
| 287 | </tr> |
| 288 | |
| 289 | <tr bgcolor="#FFFFCC"> |
| 290 | <td> -sformat1<br>-sformat_sequence</td> |
| 291 | <td>string</td> |
| 292 | <td>Input sequence format</td> |
| 293 | <td>Any string</td> |
| 294 | <td> </td> |
| 295 | </tr> |
| 296 | |
| 297 | <tr bgcolor="#FFFFCC"> |
| 298 | <td> -iquery1<br>-iquery_sequence</td> |
| 299 | <td>string</td> |
| 300 | <td>Input query fields or ID list</td> |
| 301 | <td>Any string</td> |
| 302 | <td> </td> |
| 303 | </tr> |
| 304 | |
| 305 | <tr bgcolor="#FFFFCC"> |
| 306 | <td> -ioffset1<br>-ioffset_sequence</td> |
| 307 | <td>integer</td> |
| 308 | <td>Input start position offset</td> |
| 309 | <td>Any integer value</td> |
| 310 | <td>0</td> |
| 311 | </tr> |
| 312 | |
| 313 | <tr bgcolor="#FFFFCC"> |
| 314 | <td> -sdbname1<br>-sdbname_sequence</td> |
| 315 | <td>string</td> |
| 316 | <td>Database name</td> |
| 317 | <td>Any string</td> |
| 318 | <td> </td> |
| 319 | </tr> |
| 320 | |
| 321 | <tr bgcolor="#FFFFCC"> |
| 322 | <td> -sid1<br>-sid_sequence</td> |
| 323 | <td>string</td> |
| 324 | <td>Entryname</td> |
| 325 | <td>Any string</td> |
| 326 | <td> </td> |
| 327 | </tr> |
| 328 | |
| 329 | <tr bgcolor="#FFFFCC"> |
| 330 | <td> -ufo1<br>-ufo_sequence</td> |
| 331 | <td>string</td> |
| 332 | <td>UFO features</td> |
| 333 | <td>Any string</td> |
| 334 | <td> </td> |
| 335 | </tr> |
| 336 | |
| 337 | <tr bgcolor="#FFFFCC"> |
| 338 | <td> -fformat1<br>-fformat_sequence</td> |
| 339 | <td>string</td> |
| 340 | <td>Features format</td> |
| 341 | <td>Any string</td> |
| 342 | <td> </td> |
| 343 | </tr> |
| 344 | |
| 345 | <tr bgcolor="#FFFFCC"> |
| 346 | <td> -fopenfile1<br>-fopenfile_sequence</td> |
| 347 | <td>string</td> |
| 348 | <td>Features file name</td> |
| 349 | <td>Any string</td> |
| 350 | <td> </td> |
| 351 | </tr> |
| 352 | |
| 353 | <tr bgcolor="#FFFFCC"> |
| 354 | <td align="left" colspan=5>"-pattern" associated regexp qualifiers |
| 355 | </td> |
| 356 | </tr> |
| 357 | |
| 358 | <tr bgcolor="#FFFFCC"> |
| 359 | <td> -pformat2<br>-pformat_pattern</td> |
| 360 | <td>string</td> |
| 361 | <td>File format</td> |
| 362 | <td>Any string</td> |
| 363 | <td> </td> |
| 364 | </tr> |
| 365 | |
| 366 | <tr bgcolor="#FFFFCC"> |
| 367 | <td> -pname2<br>-pname_pattern</td> |
| 368 | <td>string</td> |
| 369 | <td>Pattern base name</td> |
| 370 | <td>Any string</td> |
| 371 | <td> </td> |
| 372 | </tr> |
| 373 | |
| 374 | <tr bgcolor="#FFFFCC"> |
| 375 | <td align="left" colspan=5>"-outfile" associated report qualifiers |
| 376 | </td> |
| 377 | </tr> |
| 378 | |
| 379 | <tr bgcolor="#FFFFCC"> |
| 380 | <td> -rformat3<br>-rformat_outfile</td> |
| 381 | <td>string</td> |
| 382 | <td>Report format</td> |
| 383 | <td>Any string</td> |
| 384 | <td>seqtable</td> |
| 385 | </tr> |
| 386 | |
| 387 | <tr bgcolor="#FFFFCC"> |
| 388 | <td> -rname3<br>-rname_outfile</td> |
| 389 | <td>string</td> |
| 390 | <td>Base file name</td> |
| 391 | <td>Any string</td> |
| 392 | <td> </td> |
| 393 | </tr> |
| 394 | |
| 395 | <tr bgcolor="#FFFFCC"> |
| 396 | <td> -rextension3<br>-rextension_outfile</td> |
| 397 | <td>string</td> |
| 398 | <td>File name extension</td> |
| 399 | <td>Any string</td> |
| 400 | <td> </td> |
| 401 | </tr> |
| 402 | |
| 403 | <tr bgcolor="#FFFFCC"> |
| 404 | <td> -rdirectory3<br>-rdirectory_outfile</td> |
| 405 | <td>string</td> |
| 406 | <td>Output directory</td> |
| 407 | <td>Any string</td> |
| 408 | <td> </td> |
| 409 | </tr> |
| 410 | |
| 411 | <tr bgcolor="#FFFFCC"> |
| 412 | <td> -raccshow3<br>-raccshow_outfile</td> |
| 413 | <td>boolean</td> |
| 414 | <td>Show accession number in the report</td> |
| 415 | <td>Boolean value Yes/No</td> |
| 416 | <td>N</td> |
| 417 | </tr> |
| 418 | |
| 419 | <tr bgcolor="#FFFFCC"> |
| 420 | <td> -rdesshow3<br>-rdesshow_outfile</td> |
| 421 | <td>boolean</td> |
| 422 | <td>Show description in the report</td> |
| 423 | <td>Boolean value Yes/No</td> |
| 424 | <td>N</td> |
| 425 | </tr> |
| 426 | |
| 427 | <tr bgcolor="#FFFFCC"> |
| 428 | <td> -rscoreshow3<br>-rscoreshow_outfile</td> |
| 429 | <td>boolean</td> |
| 430 | <td>Show the score in the report</td> |
| 431 | <td>Boolean value Yes/No</td> |
| 432 | <td>Y</td> |
| 433 | </tr> |
| 434 | |
| 435 | <tr bgcolor="#FFFFCC"> |
| 436 | <td> -rstrandshow3<br>-rstrandshow_outfile</td> |
| 437 | <td>boolean</td> |
| 438 | <td>Show the nucleotide strand in the report</td> |
| 439 | <td>Boolean value Yes/No</td> |
| 440 | <td>Y</td> |
| 441 | </tr> |
| 442 | |
| 443 | <tr bgcolor="#FFFFCC"> |
| 444 | <td> -rusashow3<br>-rusashow_outfile</td> |
| 445 | <td>boolean</td> |
| 446 | <td>Show the full USA in the report</td> |
| 447 | <td>Boolean value Yes/No</td> |
| 448 | <td>N</td> |
| 449 | </tr> |
| 450 | |
| 451 | <tr bgcolor="#FFFFCC"> |
| 452 | <td> -rmaxall3<br>-rmaxall_outfile</td> |
| 453 | <td>integer</td> |
| 454 | <td>Maximum total hits to report</td> |
| 455 | <td>Any integer value</td> |
| 456 | <td>0</td> |
| 457 | </tr> |
| 458 | |
| 459 | <tr bgcolor="#FFFFCC"> |
| 460 | <td> -rmaxseq3<br>-rmaxseq_outfile</td> |
| 461 | <td>integer</td> |
| 462 | <td>Maximum hits to report for one sequence</td> |
| 463 | <td>Any integer value</td> |
| 464 | <td>0</td> |
| 465 | </tr> |
| 466 | |
| 467 | <tr bgcolor="#FFFFCC"> |
| 468 | <th align="left" colspan=5>General qualifiers</th> |
| 469 | </tr> |
| 470 | |
| 471 | <tr bgcolor="#FFFFCC"> |
| 472 | <td> -auto</td> |
| 473 | <td>boolean</td> |
| 474 | <td>Turn off prompts</td> |
| 475 | <td>Boolean value Yes/No</td> |
| 476 | <td>N</td> |
| 477 | </tr> |
| 478 | |
| 479 | <tr bgcolor="#FFFFCC"> |
| 480 | <td> -stdout</td> |
| 481 | <td>boolean</td> |
| 482 | <td>Write first file to standard output</td> |
| 483 | <td>Boolean value Yes/No</td> |
| 484 | <td>N</td> |
| 485 | </tr> |
| 486 | |
| 487 | <tr bgcolor="#FFFFCC"> |
| 488 | <td> -filter</td> |
| 489 | <td>boolean</td> |
| 490 | <td>Read first file from standard input, write first file to standard output</td> |
| 491 | <td>Boolean value Yes/No</td> |
| 492 | <td>N</td> |
| 493 | </tr> |
| 494 | |
| 495 | <tr bgcolor="#FFFFCC"> |
| 496 | <td> -options</td> |
| 497 | <td>boolean</td> |
| 498 | <td>Prompt for standard and additional values</td> |
| 499 | <td>Boolean value Yes/No</td> |
| 500 | <td>N</td> |
| 501 | </tr> |
| 502 | |
| 503 | <tr bgcolor="#FFFFCC"> |
| 504 | <td> -debug</td> |
| 505 | <td>boolean</td> |
| 506 | <td>Write debug output to program.dbg</td> |
| 507 | <td>Boolean value Yes/No</td> |
| 508 | <td>N</td> |
| 509 | </tr> |
| 510 | |
| 511 | <tr bgcolor="#FFFFCC"> |
| 512 | <td> -verbose</td> |
| 513 | <td>boolean</td> |
| 514 | <td>Report some/full command line options</td> |
| 515 | <td>Boolean value Yes/No</td> |
| 516 | <td>Y</td> |
| 517 | </tr> |
| 518 | |
| 519 | <tr bgcolor="#FFFFCC"> |
| 520 | <td> -help</td> |
| 521 | <td>boolean</td> |
| 522 | <td>Report command line options and exit. More information on associated and general qualifiers can be found with -help -verbose</td> |
| 523 | <td>Boolean value Yes/No</td> |
| 524 | <td>N</td> |
| 525 | </tr> |
| 526 | |
| 527 | <tr bgcolor="#FFFFCC"> |
| 528 | <td> -warning</td> |
| 529 | <td>boolean</td> |
| 530 | <td>Report warnings</td> |
| 531 | <td>Boolean value Yes/No</td> |
| 532 | <td>Y</td> |
| 533 | </tr> |
| 534 | |
| 535 | <tr bgcolor="#FFFFCC"> |
| 536 | <td> -error</td> |
| 537 | <td>boolean</td> |
| 538 | <td>Report errors</td> |
| 539 | <td>Boolean value Yes/No</td> |
| 540 | <td>Y</td> |
| 541 | </tr> |
| 542 | |
| 543 | <tr bgcolor="#FFFFCC"> |
| 544 | <td> -fatal</td> |
| 545 | <td>boolean</td> |
| 546 | <td>Report fatal errors</td> |
| 547 | <td>Boolean value Yes/No</td> |
| 548 | <td>Y</td> |
| 549 | </tr> |
| 550 | |
| 551 | <tr bgcolor="#FFFFCC"> |
| 552 | <td> -die</td> |
| 553 | <td>boolean</td> |
| 554 | <td>Report dying program messages</td> |
| 555 | <td>Boolean value Yes/No</td> |
| 556 | <td>Y</td> |
| 557 | </tr> |
| 558 | |
| 559 | <tr bgcolor="#FFFFCC"> |
| 560 | <td> -version</td> |
| 561 | <td>boolean</td> |
| 562 | <td>Report version number and exit</td> |
| 563 | <td>Boolean value Yes/No</td> |
| 564 | <td>N</td> |
| 565 | </tr> |
| 566 | |
| 567 | </table> |
| 568 | |
| 569 | |
| 570 | |
| 571 | |
| 572 | |
| 573 | <H2> |
| 574 | Input file format |
| 575 | </H2> |
| 576 | |
| 577 | |
| 578 | <b>preg</b> reads one or more protein sequences. |
| 579 | <p> |
| 580 | <p> |
| 581 | |
| 582 | The input is a standard EMBOSS sequence query (also known as a 'USA'). |
| 583 | |
| 584 | <p> |
| 585 | Major sequence database sources defined as standard in EMBOSS |
| 586 | installations include srs:embl, srs:uniprot and ensembl |
| 587 | |
| 588 | <p> |
| 589 | |
| 590 | Data can also be read from sequence output in any supported format |
| 591 | written by an EMBOSS or third-party application. |
| 592 | |
| 593 | <p> |
| 594 | The input format can be specified by using the |
| 595 | command-line qualifier <tt>-sformat xxx</tt>, where 'xxx' is replaced |
| 596 | by the name of the required format. The available format names are: |
| 597 | gff (gff3), gff2, embl (em), genbank (gb, refseq), ddbj, refseqp, pir |
| 598 | (nbrf), swissprot (swiss, sw), dasgff and debug. |
| 599 | |
| 600 | <p> |
| 601 | |
| 602 | See: |
| 603 | <A href="http://emboss.sf.net/docs/themes/SequenceFormats.html"> |
| 604 | http://emboss.sf.net/docs/themes/SequenceFormats.html</A> |
| 605 | for further information on sequence formats. |
| 606 | |
| 607 | <p> |
| 608 | |
| 609 | |
| 610 | <a name="input.1"></a> |
| 611 | <h3>Input files for usage example </h3> |
| 612 | |
| 613 | 'tsw:*_rat' is a sequence entry in the example protein database 'tsw' |
| 614 | <p> |
| 615 | |
| 616 | |
| 617 | <H2> |
| 618 | Output file format |
| 619 | </H2> |
| 620 | |
| 621 | <p> |
| 622 | |
| 623 | The output is a standard EMBOSS report file. |
| 624 | |
| 625 | <p> |
| 626 | |
| 627 | The results can be output in one of several styles by using the |
| 628 | command-line qualifier <tt>-rformat xxx</tt>, where 'xxx' is replaced |
| 629 | by the name of the required format. The available format names are: |
| 630 | embl, genbank, gff, pir, swiss, dasgff, debug, listfile, dbmotif, |
| 631 | diffseq, draw, restrict, excel, feattable, motif, nametable, regions, |
| 632 | seqtable, simple, srs, table, tagseq. |
| 633 | |
| 634 | <p> |
| 635 | |
| 636 | See: |
| 637 | <A href="http://emboss.sf.net/docs/themes/ReportFormats.html"> |
| 638 | http://emboss.sf.net/docs/themes/ReportFormats.html</A> |
| 639 | for further information on report formats. |
| 640 | |
| 641 | <p> |
| 642 | |
| 643 | <p> |
| 644 | By default, the report is in 'seqtable' format. |
| 645 | |
| 646 | |
| 647 | <a name="output.1"></a> |
| 648 | <h3>Output files for usage example </h3> |
| 649 | <p><h3>File: arf3_rat.preg</h3> |
| 650 | <table width="90%"><tr><td bgcolor="#CCFFCC"> |
| 651 | <pre> |
| 652 | ######################################## |
| 653 | # Program: preg |
| 654 | # Rundate: Mon 15 Jul 2013 12:00:00 |
| 655 | # Commandline: preg |
| 656 | # -sequence "tsw:*_rat" |
| 657 | # -pattern "IA[QWF]A" |
| 658 | # Report_format: seqtable |
| 659 | # Report_file: arf3_rat.preg |
| 660 | ######################################## |
| 661 | |
| 662 | #======================================= |
| 663 | # |
| 664 | # Sequence: UBR5_RAT from: 1 to: 2788 |
| 665 | # HitCount: 1 |
| 666 | # |
| 667 | # Pattern: IA[QWF]A |
| 668 | # |
| 669 | #======================================= |
| 670 | |
| 671 | Start End Pattern Sequence |
| 672 | 2289 2292 regex:IA[QWF]A IAQA |
| 673 | |
| 674 | #--------------------------------------- |
| 675 | #--------------------------------------- |
| 676 | |
| 677 | #--------------------------------------- |
| 678 | # Total_sequences: 2 |
| 679 | # Total_length: 2969 |
| 680 | # Reported_sequences: 1 |
| 681 | # Reported_hitcount: 1 |
| 682 | #--------------------------------------- |
| 683 | </pre> |
| 684 | </td></tr></table><p> |
| 685 | |
| 686 | |
| 687 | <H2> |
| 688 | Data files |
| 689 | </H2> |
| 690 | |
| 691 | None. |
| 692 | |
| 693 | <H2> |
| 694 | Notes |
| 695 | </H2> |
| 696 | |
| 697 | <p> |
| 698 | The following is a short guide to regular expressions in EMBOSS: |
| 699 | |
| 700 | |
| 701 | <dl> |
| 702 | <dt>^</dt><dd> |
| 703 | use this at the start of a pattern to insist that the pattern can only |
| 704 | match at the start of a sequence. (eg. '^M' matches a methionine at |
| 705 | the start of the sequence) |
| 706 | |
| 707 | |
| 708 | <dt>$</dt><dd> |
| 709 | use this at the end of a pattern to insist that the pattern can only |
| 710 | match at the end of a sequence (eg. 'R$' matches an arginine at |
| 711 | the end of the sequence) |
| 712 | |
| 713 | <dt>()</dt><dd> |
| 714 | groups a pattern. This is commonly used with '|' (eg. '(ACD)|(VWY)' |
| 715 | matches either the first 'ACD' or the second 'VWY' pattern ) |
| 716 | |
| 717 | <dt>|</dt><dd> |
| 718 | This is the OR operator to enable a match to be made to either one |
| 719 | pattern OR another. There is no AND operator in this version of regular |
| 720 | expressions. |
| 721 | </dl> |
| 722 | |
| 723 | <p> |
| 724 | |
| 725 | The following quantifier characters specify the number of time that |
| 726 | the character before (in this case 'x') matches: |
| 727 | |
| 728 | <dl> |
| 729 | <dt>x?</dt><dd> |
| 730 | matches 0 or 1 times (ie, '' or 'x') |
| 731 | <dt>x*</dt><dd> |
| 732 | matches 0 or more times (ie, '' or 'x' or 'xx' or 'xxx', etc) |
| 733 | <dt>x+</dt><dd> |
| 734 | matches 1 or more times (ie, 'x' or 'xx' or 'xxx', etc) |
| 735 | |
| 736 | |
| 737 | <p> |
| 738 | |
| 739 | <dt>{min,max}</dt><dd> |
| 740 | Braces can enclose the specification of the minimum and maximum number |
| 741 | of matches. A match of 'x' of between 3 and 6 times is: 'x{3,6}' |
| 742 | |
| 743 | </dl> |
| 744 | |
| 745 | <p> |
| 746 | Quantifiers can follow any of the following types of character specification: |
| 747 | |
| 748 | <dl> |
| 749 | <dt>x</dt><dd> |
| 750 | any character (ie 'A') |
| 751 | |
| 752 | <dt>\x</dt><dd> |
| 753 | the character after the backslash is used instead of its normal |
| 754 | regular expression meaning. This is commonly used to turn off the |
| 755 | special meaning of the characters '^$()|?*+[]-.'. It may be especially |
| 756 | useful when searching for gap characters in a sequence (eg '\.' matches |
| 757 | only a dot character '.') |
| 758 | |
| 759 | <dt>[xy]</dt><dd> |
| 760 | match one of the characters 'x' or 'y'. You may have one or more |
| 761 | characters in this set. |
| 762 | |
| 763 | <dt>[x-z]</dt><dd> |
| 764 | match any one of the set of characters starting with 'x' and |
| 765 | ending in 'y' in ASCII order (eg '[A-G]' matches any one of: 'A', 'B', |
| 766 | 'C', 'D', 'E', 'F', 'G') |
| 767 | |
| 768 | <dt>[^x-z]</dt><dd> |
| 769 | matches anything except any one of the group of characters in |
| 770 | ASCII order (eg '[^A-G]' matches anything EXCEPT any one of: 'A', 'B', |
| 771 | 'C', 'D', 'E', 'F', 'G') |
| 772 | |
| 773 | <dt>.</dt><dd> |
| 774 | the dot character matches any other character (eg: 'A.G' matches |
| 775 | 'AAG', 'AaG', 'AZG', 'A-G' 'A G', etc.) |
| 776 | </dl> |
| 777 | |
| 778 | <p> |
| 779 | Combining some of these features gives these examples from the PROSITE |
| 780 | patterns database: |
| 781 | |
| 782 | <pre> |
| 783 | '[STAGCN][RKH][LIVMAFY]$' |
| 784 | </pre> |
| 785 | |
| 786 | <p> |
| 787 | which is the 'Microbodies C-terminal targeting |
| 788 | signal'. |
| 789 | |
| 790 | <pre> |
| 791 | 'LP.TG[STGAVDE]' |
| 792 | </pre> |
| 793 | |
| 794 | <p> |
| 795 | which is the 'Gram-positive cocci surface proteins |
| 796 | anchoring hexapeptide'. |
| 797 | |
| 798 | <p> |
| 799 | Regular expressions are case-sensitive. |
| 800 | The pattern 'AAAA' will not match the sequence 'aaaa'. |
| 801 | For this reason, both your pattern and the input sequences are |
| 802 | converted to upper-case. |
| 803 | |
| 804 | |
| 805 | <H2>The syntax in detail</H2> |
| 806 | |
| 807 | |
| 808 | EMBOSS uses the publicly available PCRE code library to do regular |
| 809 | expressions. |
| 810 | |
| 811 | <p> |
| 812 | |
| 813 | The full documentation of the PCRE system can be seen at |
| 814 | <a href="http://www.pcre.org/pcre.txt">http://www.pcre.org/pcre.txt</a> |
| 815 | |
| 816 | <p> |
| 817 | |
| 818 | A condensed description of the syntax of PCRE follows, without features |
| 819 | that are thought not to be required for searching for patterns in |
| 820 | sequences (e.g. matching non-printing characters, atomic grouping, |
| 821 | back-references, assertion, conditional sub-patterns, recursive |
| 822 | patterns, subpatterns as subroutines, callouts). If you do neot see a |
| 823 | required function described below, please see the full description on |
| 824 | the <a href="http://www.pcre.org/pcre.txt">PCRE web site</a>. |
| 825 | |
| 826 | <p> |
| 827 | |
| 828 | <H3>PCRE REGULAR EXPRESSION DETAILS</H3> |
| 829 | |
| 830 | The syntax and semantics of the regular expressions supported by PCRE are described below. Regular expressions are |
| 831 | also described in the Perl documentation and in a number of |
| 832 | other books, some of which have copious examples. Jeffrey |
| 833 | Friedl's "Mastering Regular Expressions", published by |
| 834 | O'Reilly, covers them in great detail. The description here |
| 835 | is intended as reference documentation. |
| 836 | |
| 837 | <p> |
| 838 | |
| 839 | |
| 840 | A regular expression is a pattern that is matched against a |
| 841 | subject string from left to right. Most characters stand for |
| 842 | themselves in a pattern, and match the corresponding characters in the subject. As a trivial example, the pattern |
| 843 | |
| 844 | <p> |
| 845 | |
| 846 | |
| 847 | The quick brown fox |
| 848 | <p> |
| 849 | |
| 850 | matches a portion of a subject string that is identical to |
| 851 | itself. The power of regular expressions comes from the |
| 852 | ability to include alternatives and repetitions in the pattern. These are encoded in the pattern by the use of meta-characters, which do not stand for themselves but instead |
| 853 | are interpreted in some special way. |
| 854 | |
| 855 | <p> |
| 856 | |
| 857 | There are two different sets of meta-characters: those that |
| 858 | are recognized anywhere in the pattern except within square |
| 859 | brackets, and those that are recognized in square brackets. |
| 860 | Outside square brackets, the meta-characters are as follows: |
| 861 | |
| 862 | <p> |
| 863 | |
| 864 | <pre> |
| 865 | \ general escape character with several uses |
| 866 | ^ assert start of string (or line, in multiline mode) |
| 867 | $ assert end of string (or line, in multiline mode) |
| 868 | . match any character except newline (by default) |
| 869 | [ start character class definition |
| 870 | | start of alternative branch |
| 871 | ( start subpattern |
| 872 | ) end subpattern |
| 873 | ? extends the meaning of ( |
| 874 | also 0 or 1 quantifier |
| 875 | also quantifier minimizer |
| 876 | * 0 or more quantifier |
| 877 | + 1 or more quantifier |
| 878 | also "possessive quantifier" |
| 879 | { start min/max quantifier |
| 880 | |
| 881 | </pre> |
| 882 | |
| 883 | <p> |
| 884 | |
| 885 | Part of a pattern that is in square brackets is called a |
| 886 | "character class". In a character class the only meta-characters are: |
| 887 | |
| 888 | <p> |
| 889 | |
| 890 | <pre> |
| 891 | \ general escape character |
| 892 | ^ negate the class, but only if the first character |
| 893 | - indicates character range |
| 894 | [ POSIX character class (only if followed by POSIX |
| 895 | syntax) |
| 896 | ] terminates the character class |
| 897 | </pre> |
| 898 | |
| 899 | <p> |
| 900 | |
| 901 | The following sections describe the use of each of the |
| 902 | meta-characters. |
| 903 | |
| 904 | |
| 905 | <h4>BACKSLASH</H4> |
| 906 | |
| 907 | The backslash character has several uses. Firstly, if it is |
| 908 | followed by a non-alphameric character, it takes away any |
| 909 | special meaning that character may have. This use of |
| 910 | backslash as an escape character applies both inside and |
| 911 | outside character classes. |
| 912 | |
| 913 | <p> |
| 914 | |
| 915 | For example, if you want to match a * character, you write |
| 916 | \* in the pattern. This escaping action applies whether or |
| 917 | not the following character would otherwise be interpreted |
| 918 | as a meta-character, so it is always safe to precede a nonalphameric with backslash to specify that it stands for |
| 919 | itself. In particular, if you want to match a backslash, you |
| 920 | write \\. |
| 921 | |
| 922 | <p> |
| 923 | |
| 924 | The third use of backslash is for specifying generic character types: |
| 925 | |
| 926 | <p> |
| 927 | |
| 928 | <pre> |
| 929 | \d any decimal digit |
| 930 | \D any character that is not a decimal digit |
| 931 | \s any whitespace character |
| 932 | \S any character that is not a whitespace character |
| 933 | \w any "word" character |
| 934 | W any "non-word" character |
| 935 | </pre> |
| 936 | |
| 937 | <p> |
| 938 | |
| 939 | Each pair of escape sequences partitions the complete set of |
| 940 | characters into two disjoint sets. Any given character |
| 941 | matches one, and only one, of each pair. |
| 942 | |
| 943 | <p> |
| 944 | |
| 945 | A "word" character is any letter or digit or the underscore |
| 946 | character, that is, any character which can be part of a |
| 947 | Perl "word". The definition of letters and digits is controlled by PCRE's character tables, and may vary if locale- |
| 948 | specific matching is taking place (see "Locale support" in |
| 949 | the pcreapi page). For example, in the "fr" (French) locale, |
| 950 | some character codes greater than 128 are used for accented |
| 951 | letters, and these are matched by \w. |
| 952 | |
| 953 | <p> |
| 954 | |
| 955 | These character type sequences can appear both inside and |
| 956 | outside character classes. They each match one character of |
| 957 | the appropriate type. If the current matching point is at |
| 958 | the end of the subject string, all of them fail, since there |
| 959 | is no character to match. |
| 960 | |
| 961 | <p> |
| 962 | |
| 963 | The fourth use of backslash is for certain simple assertions. An assertion specifies a condition that has to be met |
| 964 | at a particular point in a match, without consuming any |
| 965 | characters from the subject string. The use of subpatterns |
| 966 | for more complicated assertions is described below. The |
| 967 | backslashed assertions are |
| 968 | |
| 969 | <p> |
| 970 | |
| 971 | <pre> |
| 972 | \b matches at a word boundary |
| 973 | \B matches when not at a word boundary |
| 974 | \A matches at start of subject |
| 975 | \Z matches at end of subject or before newline at end |
| 976 | \z matches at end of subject |
| 977 | \G matches at first matching position in subject |
| 978 | </pre> |
| 979 | |
| 980 | <p> |
| 981 | |
| 982 | These assertions may not appear in character classes (but |
| 983 | note that \b has a different meaning, namely the backspace |
| 984 | character, inside a character class). |
| 985 | |
| 986 | <p> |
| 987 | |
| 988 | A word boundary is a position in the subject string where |
| 989 | the current character and the previous character do not both |
| 990 | match \w or \W (i.e. one matches \w and the other matches |
| 991 | \W), or the start or end of the string if the first or last |
| 992 | character matches \w, respectively. |
| 993 | The \A, \Z, and \z assertions differ from the traditional |
| 994 | circumflex and dollar (described below) in that they only |
| 995 | ever match at the very start and end of the subject string, |
| 996 | whatever options are set. Thus, they are independent of multiline mode. |
| 997 | |
| 998 | |
| 999 | <H4>CIRCUMFLEX AND DOLLAR</H4> |
| 1000 | |
| 1001 | Outside a character class, in the default matching mode, the |
| 1002 | circumflex character is an assertion which is true only if |
| 1003 | the current matching point is at the start of the subject |
| 1004 | string. Inside a character class, circumflex has an |
| 1005 | entirely different meaning (see below). |
| 1006 | |
| 1007 | <p> |
| 1008 | |
| 1009 | Circumflex need not be the first character of the pattern if |
| 1010 | a number of alternatives are involved, but it should be the |
| 1011 | first thing in each alternative in which it appears if the |
| 1012 | pattern is ever to match that branch. If all possible alternatives start with a circumflex, that is, if the pattern is |
| 1013 | constrained to match only at the start of the subject, it is |
| 1014 | said to be an "anchored" pattern. (There are also other constructs that can cause a pattern to be anchored.) |
| 1015 | |
| 1016 | <p> |
| 1017 | |
| 1018 | A dollar character is an assertion which is true only if the |
| 1019 | current matching point is at the end of the subject string, |
| 1020 | or immediately before a newline character that is the last |
| 1021 | character in the string (by default). Dollar need not be the |
| 1022 | last character of the pattern if a number of alternatives |
| 1023 | are involved, but it should be the last item in any branch |
| 1024 | in which it appears. Dollar has no special meaning in a |
| 1025 | character class. |
| 1026 | |
| 1027 | |
| 1028 | <H4>FULL STOP (PERIOD, DOT)</H4> |
| 1029 | |
| 1030 | Outside a character class, a dot in the pattern matches any |
| 1031 | one character in the subject, including a non-printing character, |
| 1032 | but not (by default) newline. The |
| 1033 | handling of dot is entirely independent of the handling of |
| 1034 | circumflex and dollar, the only relationship being that they |
| 1035 | both involve newline characters. Dot has no special meaning |
| 1036 | in a character class. |
| 1037 | |
| 1038 | |
| 1039 | |
| 1040 | <H4>SQUARE BRACKETS</H4> |
| 1041 | |
| 1042 | An opening square bracket introduces a character class, terminated |
| 1043 | by a closing square bracket. A closing square |
| 1044 | bracket on its own is not special. If a closing square |
| 1045 | bracket is required as a member of the class, it should be |
| 1046 | the first data character in the class (after an initial circumflex, |
| 1047 | if present) or escaped with a backslash. |
| 1048 | |
| 1049 | <p> |
| 1050 | |
| 1051 | A character class matches a single character in the subject. |
| 1052 | A matched character must be in the set of characters defined |
| 1053 | by the class, unless the first character in the class definition is |
| 1054 | a circumflex, in which case the subject character |
| 1055 | must not be in the set defined by the class. If a circumflex |
| 1056 | is actually required as a member of the class, ensure it is |
| 1057 | not the first character, or escape it with a backslash. |
| 1058 | |
| 1059 | <p> |
| 1060 | |
| 1061 | For example, the character class [aeiou] matches any lower |
| 1062 | case vowel, while [^aeiou] matches any character that is not |
| 1063 | a lower case vowel. Note that a circumflex is just a convenient |
| 1064 | notation for specifying the characters which are in |
| 1065 | the class by enumerating those that are not. It is not an |
| 1066 | assertion: it still consumes a character from the subject |
| 1067 | string, and fails if the current pointer is at the end of |
| 1068 | the string. |
| 1069 | |
| 1070 | <p> |
| 1071 | |
| 1072 | When caseless matching is set, any letters in a class |
| 1073 | represent both their upper case and lower case versions, so |
| 1074 | for example, a caseless [aeiou] matches "A" as well as "a", |
| 1075 | and a caseless [^aeiou] does not match "A", whereas a caseful version would. PCRE does not support the concept of case |
| 1076 | for characters with values greater than 255. |
| 1077 | A class such as [^a] will |
| 1078 | always match a newline. |
| 1079 | |
| 1080 | <p> |
| 1081 | |
| 1082 | The minus (hyphen) character can be used to specify a range |
| 1083 | of characters in a character class. For example, [d-m] |
| 1084 | matches any letter between d and m, inclusive. If a minus |
| 1085 | character is required in a class, it must be escaped with a |
| 1086 | backslash or appear in a position where it cannot be interpreted as indicating a range, typically as the first or last |
| 1087 | character in the class. |
| 1088 | |
| 1089 | <p> |
| 1090 | |
| 1091 | It is not possible to have the literal character "]" as the |
| 1092 | end character of a range. A pattern such as [W-]46] is |
| 1093 | interpreted as a class of two characters ("W" and "-") followed by a literal string "46]", so it would match "W46]" or |
| 1094 | "-46]". However, if the "]" is escaped with a backslash it |
| 1095 | is interpreted as the end of range, so [W-\]46] is interpreted as a single class containing a range followed by two |
| 1096 | separate characters. The octal or hexadecimal representation |
| 1097 | of "]" can also be used to end a range. |
| 1098 | |
| 1099 | <p> |
| 1100 | |
| 1101 | The character types \d, \D, \s, \S, \w, and \W may also |
| 1102 | appear in a character class, and add the characters that |
| 1103 | they match to the class. For example, [\dABCDEF] matches any |
| 1104 | hexadecimal digit. A circumflex can conveniently be used |
| 1105 | with the upper case character types to specify a more restricted set of characters than the matching lower case type. |
| 1106 | For example, the class [^\W_] matches any letter or digit, |
| 1107 | but not underscore. |
| 1108 | |
| 1109 | <p> |
| 1110 | |
| 1111 | All non-alphameric characters other than \, -, ^ (at the |
| 1112 | start) and the terminating ] are non-special in character |
| 1113 | classes, but it does no harm if they are escaped. |
| 1114 | |
| 1115 | |
| 1116 | <H4>VERTICAL BAR</H4> |
| 1117 | |
| 1118 | Vertical bar characters are used to separate alternative |
| 1119 | patterns. For example, the pattern |
| 1120 | |
| 1121 | <p> |
| 1122 | |
| 1123 | gilbert|sullivan |
| 1124 | |
| 1125 | <p> |
| 1126 | |
| 1127 | matches either "gilbert" or "sullivan". Any number of alternatives may appear, and an empty alternative is permitted |
| 1128 | (matching the empty string). The matching process tries |
| 1129 | each alternative in turn, from left to right, and the first |
| 1130 | one that succeeds is used. If the alternatives are within a |
| 1131 | subpattern (defined below), "succeeds" means matching the |
| 1132 | rest of the main pattern as well as the alternative in the |
| 1133 | subpattern. |
| 1134 | |
| 1135 | |
| 1136 | <H4>INTERNAL OPTION SETTING</H4> |
| 1137 | |
| 1138 | The settings of the PCRE_CASELESS, PCRE_MULTILINE, |
| 1139 | PCRE_DOTALL, and PCRE_EXTENDED options can be changed from |
| 1140 | within the pattern by a sequence of Perl option letters |
| 1141 | enclosed between "(?" and ")". The option letters are |
| 1142 | |
| 1143 | <p> |
| 1144 | <pre> |
| 1145 | i for PCRE_CASELESS |
| 1146 | m for PCRE_MULTILINE |
| 1147 | s for PCRE_DOTALL |
| 1148 | x for PCRE_EXTENDED |
| 1149 | </pre> |
| 1150 | |
| 1151 | <p> |
| 1152 | |
| 1153 | For example, (?im) sets caseless, multiline matching. It is |
| 1154 | also possible to unset these options by preceding the letter |
| 1155 | with a hyphen, and a combined setting and unsetting such as |
| 1156 | (?im-sx), which sets PCRE_CASELESS and PCRE_MULTILINE while |
| 1157 | unsetting PCRE_DOTALL and PCRE_EXTENDED, is also permitted. |
| 1158 | If a letter appears both before and after the hyphen, the |
| 1159 | option is unset. |
| 1160 | |
| 1161 | <p> |
| 1162 | |
| 1163 | When an option change occurs at top level (that is, not |
| 1164 | inside subpattern parentheses), the change applies to the |
| 1165 | remainder of the pattern that follows. If the change is |
| 1166 | placed right at the start of a pattern, PCRE extracts it |
| 1167 | into the global options (and it will therefore show up in |
| 1168 | data extracted by the pcre_fullinfo() function). |
| 1169 | |
| 1170 | <p> |
| 1171 | |
| 1172 | An option change within a subpattern affects only that part |
| 1173 | of the current pattern that follows it, so |
| 1174 | |
| 1175 | <p> |
| 1176 | |
| 1177 | (a(?i)b)c |
| 1178 | |
| 1179 | <p> |
| 1180 | |
| 1181 | matches abc and aBc and no other strings (assuming |
| 1182 | PCRE_CASELESS is not used). By this means, options can be |
| 1183 | made to have different settings in different parts of the |
| 1184 | pattern. Any changes made in one alternative do carry on |
| 1185 | into subsequent branches within the same subpattern. For |
| 1186 | example, |
| 1187 | |
| 1188 | <p> |
| 1189 | |
| 1190 | (a(?i)b|c) |
| 1191 | |
| 1192 | <p> |
| 1193 | |
| 1194 | matches "ab", "aB", "c", and "C", even though when matching |
| 1195 | "C" the first branch is abandoned before the option setting. |
| 1196 | This is because the effects of option settings happen at |
| 1197 | compile time. There would be some very weird behaviour otherwise. |
| 1198 | |
| 1199 | <p> |
| 1200 | |
| 1201 | The PCRE-specific options PCRE_UNGREEDY and PCRE_EXTRA can |
| 1202 | be changed in the same way as the Perl-compatible options by |
| 1203 | using the characters U and X respectively. The (?X) flag |
| 1204 | setting is special in that it must always occur earlier in |
| 1205 | the pattern than any of the additional features it turns on, |
| 1206 | even when it is at top level. It is best put at the start. |
| 1207 | |
| 1208 | |
| 1209 | <H4>SUBPATTERNS</H4> |
| 1210 | |
| 1211 | Subpatterns are delimited by parentheses (round brackets), |
| 1212 | which can be nested. Marking part of a pattern as a subpattern |
| 1213 | does two things: |
| 1214 | |
| 1215 | <p> |
| 1216 | |
| 1217 | 1. It localizes a set of alternatives. For example, the pattern |
| 1218 | |
| 1219 | <p> |
| 1220 | |
| 1221 | cat(aract|erpillar|) |
| 1222 | <p> |
| 1223 | |
| 1224 | matches one of the words "cat", "cataract", or "caterpillar". Without the parentheses, it would match "cataract", |
| 1225 | "erpillar" or the empty string. |
| 1226 | |
| 1227 | <p> |
| 1228 | |
| 1229 | 2. It sets up the subpattern as a capturing subpattern (as |
| 1230 | defined above). When the whole pattern matches, that portion of the subject string that matched the subpattern is |
| 1231 | passed back to the caller via the ovector argument of |
| 1232 | pcre_exec(). Opening parentheses are counted from left to |
| 1233 | right (starting from 1) to obtain the numbers of the capturing subpatterns. |
| 1234 | |
| 1235 | <p> |
| 1236 | |
| 1237 | For example, if the string "the red king" is matched against |
| 1238 | the pattern |
| 1239 | |
| 1240 | <p> |
| 1241 | |
| 1242 | the ((red|white) (king|queen)) |
| 1243 | |
| 1244 | <p> |
| 1245 | |
| 1246 | the captured substrings are "red king", "red", and "king", |
| 1247 | and are numbered 1, 2, and 3, respectively. |
| 1248 | |
| 1249 | <p> |
| 1250 | |
| 1251 | The fact that plain parentheses fulfil two functions is not |
| 1252 | always helpful. There are often times when a grouping subpattern is required without a capturing requirement. If an |
| 1253 | opening parenthesis is followed by a question mark and a |
| 1254 | colon, the subpattern does not do any capturing, and is not |
| 1255 | counted when computing the number of any subsequent capturing subpatterns. For example, if the string "the white |
| 1256 | queen" is matched against the pattern |
| 1257 | |
| 1258 | <p> |
| 1259 | |
| 1260 | the ((?:red|white) (king|queen)) |
| 1261 | |
| 1262 | <p> |
| 1263 | |
| 1264 | the captured substrings are "white queen" and "queen", and |
| 1265 | are numbered 1 and 2. The maximum number of capturing subpatterns is 65535, and the maximum depth of nesting of all |
| 1266 | subpatterns, both capturing and non-capturing, is 200. |
| 1267 | |
| 1268 | <p> |
| 1269 | |
| 1270 | As a convenient shorthand, if any option settings are |
| 1271 | required at the start of a non-capturing subpattern, the |
| 1272 | option letters may appear between the "?" and the ":". Thus |
| 1273 | the two patterns |
| 1274 | |
| 1275 | <p> |
| 1276 | <pre> |
| 1277 | (?i:saturday|sunday) |
| 1278 | (?:(?i)saturday|sunday) |
| 1279 | </pre> |
| 1280 | |
| 1281 | <p> |
| 1282 | |
| 1283 | match exactly the same set of strings. Because alternative |
| 1284 | branches are tried from left to right, and options are not |
| 1285 | reset until the end of the subpattern is reached, an option |
| 1286 | setting in one branch does affect subsequent branches, so |
| 1287 | the above patterns match "SUNDAY" as well as "Saturday". |
| 1288 | |
| 1289 | |
| 1290 | <H4>REPETITION</H4> |
| 1291 | |
| 1292 | Repetition is specified by quantifiers, which can follow any |
| 1293 | of the following items: |
| 1294 | |
| 1295 | <p> |
| 1296 | |
| 1297 | <pre> |
| 1298 | a literal data character |
| 1299 | the . meta-character |
| 1300 | the \C escape sequence |
| 1301 | escapes such as \d that match single characters |
| 1302 | a character class |
| 1303 | a back reference (see next section) |
| 1304 | a parenthesized subpattern (unless it is an assertion) |
| 1305 | </pre> |
| 1306 | |
| 1307 | <p> |
| 1308 | |
| 1309 | |
| 1310 | The general repetition quantifier specifies a minimum and |
| 1311 | maximum number of permitted matches, by giving the two |
| 1312 | numbers in curly brackets (braces), separated by a comma. |
| 1313 | The numbers must be less than 65536, and the first must be |
| 1314 | less than or equal to the second. For example: |
| 1315 | |
| 1316 | <p> |
| 1317 | |
| 1318 | |
| 1319 | z{2,4} |
| 1320 | |
| 1321 | |
| 1322 | <p> |
| 1323 | |
| 1324 | matches "zz", "zzz", or "zzzz". A closing brace on its own |
| 1325 | is not a special character. If the second number is omitted, |
| 1326 | but the comma is present, there is no upper limit; if the |
| 1327 | second number and the comma are both omitted, the quantifier |
| 1328 | specifies an exact number of required matches. Thus |
| 1329 | |
| 1330 | <p> |
| 1331 | |
| 1332 | |
| 1333 | [aeiou]{3,} |
| 1334 | |
| 1335 | <p> |
| 1336 | |
| 1337 | |
| 1338 | matches at least 3 successive vowels, but may match many |
| 1339 | more, while |
| 1340 | |
| 1341 | <p> |
| 1342 | |
| 1343 | |
| 1344 | \d{8} |
| 1345 | |
| 1346 | |
| 1347 | <p> |
| 1348 | |
| 1349 | matches exactly 8 digits. An opening curly bracket that |
| 1350 | appears in a position where a quantifier is not allowed, or |
| 1351 | one that does not match the syntax of a quantifier, is taken |
| 1352 | as a literal character. For example, {,6} is not a quantifier, but a literal string of four characters. |
| 1353 | |
| 1354 | <p> |
| 1355 | |
| 1356 | |
| 1357 | The quantifier {0} is permitted, causing the expression to |
| 1358 | behave as if the previous item and the quantifier were not |
| 1359 | present. |
| 1360 | |
| 1361 | <p> |
| 1362 | |
| 1363 | |
| 1364 | For convenience (and historical compatibility) the three |
| 1365 | most common quantifiers have single-character abbreviations: |
| 1366 | |
| 1367 | <p> |
| 1368 | |
| 1369 | <pre> |
| 1370 | * is equivalent to {0,} |
| 1371 | + is equivalent to {1,} |
| 1372 | ? is equivalent to {0,1} |
| 1373 | </pre> |
| 1374 | |
| 1375 | <p> |
| 1376 | |
| 1377 | |
| 1378 | It is possible to construct infinite loops by following a |
| 1379 | subpattern that can match no characters with a quantifier |
| 1380 | that has no upper limit, for example: |
| 1381 | |
| 1382 | <p> |
| 1383 | |
| 1384 | |
| 1385 | (a?)* |
| 1386 | |
| 1387 | <p> |
| 1388 | |
| 1389 | |
| 1390 | Earlier versions of Perl and PCRE used to give an error at |
| 1391 | compile time for such patterns. However, because there are |
| 1392 | cases where this can be useful, such patterns are now |
| 1393 | accepted, but if any repetition of the subpattern does in |
| 1394 | fact match no characters, the loop is forcibly broken. |
| 1395 | |
| 1396 | <p> |
| 1397 | |
| 1398 | |
| 1399 | By default, the quantifiers are "greedy", that is, they |
| 1400 | match as much as possible (up to the maximum number of permitted times), without causing the rest of the pattern to |
| 1401 | fail. The classic example of where this gives problems is in |
| 1402 | trying to match comments in C programs. These appear between |
| 1403 | the sequences /* and */ and within the sequence, individual |
| 1404 | * and / characters may appear. An attempt to match C comments by applying the pattern |
| 1405 | |
| 1406 | <p> |
| 1407 | |
| 1408 | |
| 1409 | /\*.*\*/ |
| 1410 | |
| 1411 | <p> |
| 1412 | |
| 1413 | |
| 1414 | to the string |
| 1415 | |
| 1416 | <p> |
| 1417 | |
| 1418 | <pre> |
| 1419 | /* first command */ not comment /* second comment */ |
| 1420 | </pre> |
| 1421 | |
| 1422 | <p> |
| 1423 | |
| 1424 | |
| 1425 | fails, because it matches the entire string owing to the |
| 1426 | greediness of the .* item. |
| 1427 | |
| 1428 | <p> |
| 1429 | |
| 1430 | |
| 1431 | However, if a quantifier is followed by a question mark, it |
| 1432 | ceases to be greedy, and instead matches the minimum number |
| 1433 | of times possible, so the pattern |
| 1434 | |
| 1435 | <p> |
| 1436 | |
| 1437 | |
| 1438 | /\*.*?\*/ |
| 1439 | |
| 1440 | <p> |
| 1441 | |
| 1442 | |
| 1443 | does the right thing with the C comments. The meaning of the |
| 1444 | various quantifiers is not otherwise changed, just the preferred number of matches. Do not confuse this use of question mark with its use as a quantifier in its own right. |
| 1445 | Because it has two uses, it can sometimes appear doubled, as |
| 1446 | in |
| 1447 | |
| 1448 | <p> |
| 1449 | |
| 1450 | |
| 1451 | \d??\d |
| 1452 | |
| 1453 | <p> |
| 1454 | |
| 1455 | |
| 1456 | which matches one digit by preference, but can match two if |
| 1457 | that is the only way the rest of the pattern matches. |
| 1458 | |
| 1459 | <p> |
| 1460 | |
| 1461 | |
| 1462 | If the PCRE_UNGREEDY option is set (an option which is not |
| 1463 | available in Perl), the quantifiers are not greedy by |
| 1464 | default, but individual ones can be made greedy by following |
| 1465 | them with a question mark. In other words, it inverts the |
| 1466 | default behaviour. |
| 1467 | |
| 1468 | <p> |
| 1469 | |
| 1470 | |
| 1471 | When a parenthesized subpattern is quantified with a minimum |
| 1472 | repeat count that is greater than 1 or with a limited maximum, more store is required for the compiled pattern, in |
| 1473 | proportion to the size of the minimum or maximum. |
| 1474 | If a pattern starts with .* or .{0,} and the PCRE_DOTALL |
| 1475 | option (equivalent to Perl's /s) is set, thus allowing the . |
| 1476 | to match newlines, the pattern is implicitly anchored, |
| 1477 | because whatever follows will be tried against every character position in the subject string, so there is no point in |
| 1478 | retrying the overall match at any position after the first. |
| 1479 | PCRE normally treats such a pattern as though it were preceded by \A. |
| 1480 | |
| 1481 | <p> |
| 1482 | |
| 1483 | |
| 1484 | In cases where it is known that the subject string contains |
| 1485 | no newlines, it is worth setting PCRE_DOTALL in order to |
| 1486 | obtain this optimization, or alternatively using ^ to indicate anchoring explicitly. |
| 1487 | |
| 1488 | <p> |
| 1489 | |
| 1490 | |
| 1491 | However, there is one situation where the optimization cannot be used. When .* is inside capturing parentheses that |
| 1492 | are the subject of a backreference elsewhere in the pattern, |
| 1493 | a match at the start may fail, and a later one succeed. Consider, for example: |
| 1494 | |
| 1495 | <p> |
| 1496 | |
| 1497 | |
| 1498 | (.*)abc\1 |
| 1499 | |
| 1500 | <p> |
| 1501 | |
| 1502 | |
| 1503 | If the subject is "xyz123abc123" the match point is the |
| 1504 | fourth character. For this reason, such a pattern is not |
| 1505 | implicitly anchored. |
| 1506 | |
| 1507 | <p> |
| 1508 | |
| 1509 | |
| 1510 | When a capturing subpattern is repeated, the value captured |
| 1511 | is the substring that matched the final iteration. For example, after |
| 1512 | |
| 1513 | <p> |
| 1514 | |
| 1515 | |
| 1516 | (tweedle[dume]{3}\s*)+ |
| 1517 | |
| 1518 | <p> |
| 1519 | |
| 1520 | |
| 1521 | has matched "tweedledum tweedledee" the value of the captured substring is "tweedledee". However, if there are |
| 1522 | nested capturing subpatterns, the corresponding captured |
| 1523 | values may have been set in previous iterations. For example, after |
| 1524 | |
| 1525 | <p> |
| 1526 | |
| 1527 | <pre> |
| 1528 | /(a|(b))+/ |
| 1529 | </pre> |
| 1530 | |
| 1531 | <p> |
| 1532 | |
| 1533 | |
| 1534 | <H3>PCRE PERFORMANCE</H3> |
| 1535 | |
| 1536 | Certain items that may appear in regular expression patterns |
| 1537 | are more efficient than others. It is more efficient to use |
| 1538 | a character class like [aeiou] than a set of alternatives |
| 1539 | such as (a|e|i|o|u). In general, the simplest construction |
| 1540 | that provides the required behaviour is usually the most |
| 1541 | efficient. Jeffrey Friedl's book contains a lot of discussion about optimizing regular expressions for efficient performance. |
| 1542 | |
| 1543 | <p> |
| 1544 | |
| 1545 | |
| 1546 | When a pattern begins with .* not in parentheses, or in |
| 1547 | parentheses that are not the subject of a backreference, and |
| 1548 | the PCRE_DOTALL option is set, the pattern is implicitly |
| 1549 | anchored by PCRE, since it can match only at the start of a |
| 1550 | subject string. However, if PCRE_DOTALL is not set, PCRE |
| 1551 | cannot make this optimization, because the . meta-character |
| 1552 | does not then match a newline, and if the subject string |
| 1553 | contains newlines, the pattern may match from the character |
| 1554 | immediately following one of them instead of from the very |
| 1555 | start. For example, the pattern |
| 1556 | |
| 1557 | <p> |
| 1558 | |
| 1559 | |
| 1560 | .*second |
| 1561 | |
| 1562 | <p> |
| 1563 | |
| 1564 | |
| 1565 | matches the subject "first\nand second" (where \n stands for |
| 1566 | a newline character), with the match starting at the seventh |
| 1567 | character. In order to do this, PCRE has to retry the match |
| 1568 | starting after every newline in the subject. |
| 1569 | |
| 1570 | |
| 1571 | <p> |
| 1572 | |
| 1573 | If you are using such a pattern with subject strings that do |
| 1574 | not contain newlines, the best performance is obtained by |
| 1575 | setting PCRE_DOTALL, or starting the pattern with ^.* to |
| 1576 | indicate explicit anchoring. That saves PCRE from having to |
| 1577 | scan along the subject looking for a newline to restart at. |
| 1578 | |
| 1579 | |
| 1580 | <p> |
| 1581 | |
| 1582 | Beware of patterns that contain nested indefinite repeats. |
| 1583 | These can take a long time to run when applied to a string |
| 1584 | that does not match. Consider the pattern fragment |
| 1585 | |
| 1586 | <p> |
| 1587 | |
| 1588 | |
| 1589 | (a+)* |
| 1590 | |
| 1591 | <p> |
| 1592 | |
| 1593 | |
| 1594 | This can match "aaaa" in 33 different ways, and this number |
| 1595 | increases very rapidly as the string gets longer. (The * |
| 1596 | repeat can match 0, 1, 2, 3, or 4 times, and for each of |
| 1597 | those cases other than 0, the + repeats can match different |
| 1598 | numbers of times.) When the remainder of the pattern is such |
| 1599 | that the entire match is going to fail, PCRE has in principle to try every possible variation, and this can take an |
| 1600 | extremely long time. |
| 1601 | An optimization catches some of the more simple cases such |
| 1602 | as |
| 1603 | |
| 1604 | <p> |
| 1605 | |
| 1606 | |
| 1607 | (a+)*b |
| 1608 | |
| 1609 | |
| 1610 | <p> |
| 1611 | |
| 1612 | where a literal character follows. Before embarking on the |
| 1613 | standard matching procedure, PCRE checks that there is a "b" |
| 1614 | later in the subject string, and if there is not, it fails |
| 1615 | the match immediately. However, when there is no following |
| 1616 | literal this optimization cannot be used. You can see the |
| 1617 | difference by comparing the behaviour of |
| 1618 | |
| 1619 | <p> |
| 1620 | |
| 1621 | |
| 1622 | (a+)*\d |
| 1623 | |
| 1624 | <p> |
| 1625 | |
| 1626 | |
| 1627 | with the pattern above. The former gives a failure almost |
| 1628 | instantly when applied to a whole line of "a" characters, |
| 1629 | whereas the latter takes an appreciable time with strings |
| 1630 | longer than about 20 characters. |
| 1631 | |
| 1632 | |
| 1633 | <H2> |
| 1634 | References |
| 1635 | </H2> |
| 1636 | |
| 1637 | None. |
| 1638 | |
| 1639 | <H2> |
| 1640 | Warnings |
| 1641 | </H2> |
| 1642 | |
| 1643 | |
| 1644 | Regular expressions are case-sensitive. |
| 1645 | The pattern 'AAAA' will not match the sequence 'aaaa'. |
| 1646 | For this reason, both your pattern and the input sequences are |
| 1647 | converted to upper-case. |
| 1648 | |
| 1649 | |
| 1650 | <H2> |
| 1651 | Diagnostic Error Messages |
| 1652 | </H2> |
| 1653 | |
| 1654 | None. |
| 1655 | |
| 1656 | <H2> |
| 1657 | Exit status |
| 1658 | </H2> |
| 1659 | |
| 1660 | It always exits with a status of 0. |
| 1661 | Always returns 0. |
| 1662 | |
| 1663 | <H2> |
| 1664 | Known bugs |
| 1665 | </H2> |
| 1666 | |
| 1667 | None. |
| 1668 | |
| 1669 | <h2><a name="See also">See also</a></h2> |
| 1670 | <table border cellpadding=4 bgcolor="#FFFFF0"> |
| 1671 | <tr><th>Program name</th> |
| 1672 | <th>Description</th></tr> |
| 1673 | <tr> |
| 1674 | <td><a href="antigenic.html">antigenic</a></td> |
| 1675 | <td>Find antigenic sites in proteins</td> |
| 1676 | </tr> |
| 1677 | |
| 1678 | <tr> |
| 1679 | <td><a href="epestfind.html">epestfind</a></td> |
| 1680 | <td>Find PEST motifs as potential proteolytic cleavage sites</td> |
| 1681 | </tr> |
| 1682 | |
| 1683 | <tr> |
| 1684 | <td><a href="fuzzpro.html">fuzzpro</a></td> |
| 1685 | <td>Search for patterns in protein sequences</td> |
| 1686 | </tr> |
| 1687 | |
| 1688 | <tr> |
| 1689 | <td><a href="fuzztran.html">fuzztran</a></td> |
| 1690 | <td>Search for patterns in protein sequences (translated)</td> |
| 1691 | </tr> |
| 1692 | |
| 1693 | <tr> |
| 1694 | <td><a href="patmatdb.html">patmatdb</a></td> |
| 1695 | <td>Search protein sequences with a sequence motif</td> |
| 1696 | </tr> |
| 1697 | |
| 1698 | <tr> |
| 1699 | <td><a href="patmatmotifs.html">patmatmotifs</a></td> |
| 1700 | <td>Scan a protein sequence with motifs from the PROSITE database</td> |
| 1701 | </tr> |
| 1702 | |
| 1703 | <tr> |
| 1704 | <td><a href="pscan.html">pscan</a></td> |
| 1705 | <td>Scan protein sequence(s) with fingerprints from the PRINTS database</td> |
| 1706 | </tr> |
| 1707 | |
| 1708 | <tr> |
| 1709 | <td><a href="sigcleave.html">sigcleave</a></td> |
| 1710 | <td>Report on signal cleavage sites in a protein sequence</td> |
| 1711 | </tr> |
| 1712 | |
| 1713 | </table> |
| 1714 | |
| 1715 | <H2> |
| 1716 | Author(s) |
| 1717 | </H2> |
| 1718 | |
| 1719 | |
| 1720 | Peter Rice |
| 1721 | <br> |
| 1722 | European Bioinformatics Institute, Wellcome Trust Genome Campus, Hinxton, Cambridge CB10 1SD, UK |
| 1723 | |
| 1724 | <p> |
| 1725 | Please report all bugs to the EMBOSS bug team (emboss-bug © emboss.open-bio.org) not to the original author. |
| 1726 | |
| 1727 | <H2> |
| 1728 | History |
| 1729 | </H2> |
| 1730 | |
| 1731 | Written (1999) - Peter Rice |
| 1732 | |
| 1733 | <H2> |
| 1734 | Target users |
| 1735 | </H2> |
| 1736 | This program is intended to be used by everyone and everything, from naive users to embedded scripts. |
| 1737 | |
| 1738 | |
| 1739 | <H2> |
| 1740 | Comments |
| 1741 | </H2> |
| 1742 | None |
| 1743 | |
| 1744 | </BODY> |
| 1745 | </HTML> |
| 1746 |