]> git.donarmstrong.com Git - biopieces.git/blob - bp_doc/biotools_cookbook.lyx~
2f10d7e51d816323c6a87bc6282a0893c23b4504
[biopieces.git] / bp_doc / biotools_cookbook.lyx~
1 #LyX 1.5.1 created this file. For more info see http://www.lyx.org/
2 \lyxformat 276
3 \begin_document
4 \begin_header
5 \textclass scrartcl
6 \begin_preamble
7 \usepackage[colorlinks=true, urlcolor=blue, linkcolor=black]{hyperref}
8 \end_preamble
9 \language english
10 \inputencoding auto
11 \font_roman default
12 \font_sans default
13 \font_typewriter default
14 \font_default_family default
15 \font_sc false
16 \font_osf false
17 \font_sf_scale 100
18 \font_tt_scale 100
19 \graphics default
20 \paperfontsize default
21 \spacing single
22 \papersize default
23 \use_geometry false
24 \use_amsmath 1
25 \use_esint 1
26 \cite_engine basic
27 \use_bibtopic false
28 \paperorientation portrait
29 \secnumdepth 3
30 \tocdepth 3
31 \paragraph_separation skip
32 \defskip medskip
33 \quotes_language english
34 \papercolumns 1
35 \papersides 1
36 \paperpagestyle default
37 \tracking_changes false
38 \output_changes false
39 \author "" 
40 \author "" 
41 \end_header
42
43 \begin_body
44
45 \begin_layout Title
46 Biotools Cookbook
47 \end_layout
48
49 \begin_layout Author
50 Martin Asser Hansen
51 \end_layout
52
53 \begin_layout Publishers
54 John Mattick Group
55 \newline
56 Institute for Molecular Bioscience
57 \newline
58 University of Queensland
59 \newline
60 Aust
61 ralia
62 \newline
63 E-mail: mail@maasha.dk
64 \end_layout
65
66 \begin_layout Standard
67 \begin_inset ERT
68 status open
69
70 \begin_layout Standard
71
72
73 \backslash
74 thispagestyle{empty}
75 \end_layout
76
77 \end_inset
78
79
80 \end_layout
81
82 \begin_layout Standard
83
84 \newpage
85
86 \end_layout
87
88 \begin_layout Standard
89 \begin_inset LatexCommand tableofcontents
90
91 \end_inset
92
93
94 \end_layout
95
96 \begin_layout Standard
97 \begin_inset FloatList figure
98
99 \end_inset
100
101
102 \end_layout
103
104 \begin_layout Standard
105
106 \newpage
107
108 \end_layout
109
110 \begin_layout Section
111 Introduction
112 \end_layout
113
114 \begin_layout Standard
115 Biotools is a selection of simple tools that can be linked together (piped
116  as we shall call it) in a very flexible manner to perform both simple and
117  complex tasks.
118  The fundamental idea is that biotools work on a data stream that will only
119  terminate at the end of an analysis and that this data stream can be passed
120  through several different biotools, each performing one specific task.
121  The advantage of this approach is that a user can perform simple and complex
122  tasks without having to write advanced code.
123  Moreover, since the data format used to pass data between biotools is text
124  based, biotools can be written by different developers in their favorite
125  programming language --- and still the biotools will be able to work together.
126 \end_layout
127
128 \begin_layout Standard
129 In the most simple form bioools can be piped together on the command line
130  like this (using the pipe character '|'):
131 \end_layout
132
133 \begin_layout LyX-Code
134 read_data | calculate_something | write_result
135 \end_layout
136
137 \begin_layout Standard
138 However, a more comprehensive analysis could be composed:
139 \end_layout
140
141 \begin_layout LyX-Code
142 read_data | select_entries | convert_entries | search_database  
143 \end_layout
144
145 \begin_layout LyX-Code
146 evaluate_results | plot_diagram | plot_another_diagram |
147 \end_layout
148
149 \begin_layout LyX-Code
150 load_to_database
151 \end_layout
152
153 \begin_layout Standard
154 The data stream that is piped through the biotools consists of records of
155  key/value pairs in the same way a hash does in order to keep as simple
156  a structure as possible.
157  An example record can be seen below:
158 \end_layout
159
160 \begin_layout LyX-Code
161
162 \end_layout
163
164 \begin_layout LyX-Code
165
166 \size scriptsize
167 REC_TYPE: PATSCAN
168 \end_layout
169
170 \begin_layout LyX-Code
171
172 \size scriptsize
173 MATCH: AGATCAAGTG
174 \end_layout
175
176 \begin_layout LyX-Code
177
178 \size scriptsize
179 S_BEG: 7
180 \end_layout
181
182 \begin_layout LyX-Code
183
184 \size scriptsize
185 S_END: 16
186 \end_layout
187
188 \begin_layout LyX-Code
189
190 \size scriptsize
191 ALIGN_LEN: 9
192 \end_layout
193
194 \begin_layout LyX-Code
195
196 \size scriptsize
197 S_ID: piR-t6
198 \end_layout
199
200 \begin_layout LyX-Code
201
202 \size scriptsize
203 STRAND: +
204 \end_layout
205
206 \begin_layout LyX-Code
207
208 \size scriptsize
209 PATTERN: AGATCAAGTG
210 \end_layout
211
212 \begin_layout LyX-Code
213
214 \size scriptsize
215 ---
216 \end_layout
217
218 \begin_layout Standard
219 The '
220 \begin_inset ERT
221 status collapsed
222
223 \begin_layout Standard
224
225 -
226 \backslash
227 /-
228 \backslash
229 /-
230 \end_layout
231
232 \end_inset
233
234 ' denotes the delimiter of the records, and each key is a word followed
235  by a ':' and a white-space and then the value.
236  By convention the biotools only uses upper case keys (a list of used keys
237  can be seen in Appendix\InsetSpace ~
238
239 \begin_inset LatexCommand ref
240 reference "sec:Keys"
241
242 \end_inset
243
244 ).
245  Since the records basically are hash structures this mean that the order
246  of the keys in the stream is unordered, and in the above example it is
247  pure coincidence that HIT_BEG is displayed before HIT_END, however, when
248  the order of the keys is importent, the biotools will automagically see
249  to that.
250 \end_layout
251
252 \begin_layout Standard
253 All of the biotools are able to read and write a data stream to and from
254  file as long as the records are in the biotools format.
255  This means that if you are undertaking a lengthy analysis where one of
256  the steps is time consuming, you may save the stream after this step, and
257  subsequently start one or more analysis from that last step
258 \begin_inset Foot
259 status collapsed
260
261 \begin_layout Standard
262 It is a goal that the biotools at some point will be able to dump the data
263  stream to file in case one of the tools fail critically.
264 \end_layout
265
266 \end_inset
267
268 .
269  If you are running a lengthy analysis it is highly recommended that you
270  create a small test sample of the data and run that through the pipeline
271  --- and once you are satisfied with the result proceed with the full data
272  set (see\InsetSpace ~
273
274 \begin_inset LatexCommand ref
275 reference "sub:How-to-select-a-few-records"
276
277 \end_inset
278
279 ).
280 \end_layout
281
282 \begin_layout Standard
283 All of the biotools can be supplied with long arguments prefixed with 
284 \begin_inset ERT
285 status collapsed
286
287 \begin_layout Standard
288
289 -
290 \backslash
291 /-
292 \end_layout
293
294 \end_inset
295
296  switches or single character arguments prefixed with - switches that can
297  be grouped together (e.g.
298  -xok).
299  In this cookbook only the long switches are used to emphasize what these
300  switches do.
301 \end_layout
302
303 \begin_layout Section
304 Setup
305 \end_layout
306
307 \begin_layout Standard
308 In order to get the biotools to work, you need to add environment settings
309  to include the code binaries, scripts, and modules that constitute the
310  biotools package.
311  Assuming that you are using bash, add the following to your '~/.bashrc'
312  file using your favorite editor.
313  After the changes has been saved you need to either run 'source ~/.bashrc'
314  or relogin.
315 \end_layout
316
317 \begin_layout LyX-Code
318
319 \size scriptsize
320 # >>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<
321 \end_layout
322
323 \begin_layout LyX-Code
324
325 \end_layout
326
327 \begin_layout LyX-Code
328
329 \size scriptsize
330 # Stuff that enables biotools.
331 \end_layout
332
333 \begin_layout LyX-Code
334
335 \end_layout
336
337 \begin_layout LyX-Code
338
339 \size scriptsize
340 export TOOLS_DIR="/home/m.hansen/tools"      # Contains binaries for BLAST
341  and Vmatch.
342 \end_layout
343
344 \begin_layout LyX-Code
345
346 \size scriptsize
347 export  INST_DIR="/home/m.hansen/maasha"     # Contains scripts and modules.
348 \end_layout
349
350 \begin_layout LyX-Code
351
352 \size scriptsize
353 export  DATA_DIR="/home/m.hansen/DATA"       # Contains genomic data etc.
354 \end_layout
355
356 \begin_layout LyX-Code
357
358 \size scriptsize
359 export   TMP_DIR="/home/m.hansen/maasha/tmp" # Required temporary directory.
360 \end_layout
361
362 \begin_layout LyX-Code
363
364 \end_layout
365
366 \begin_layout LyX-Code
367
368 \size scriptsize
369 export     PATH="$PATH:$TOOLS_DIR/blast-2.2.17/bin:$TOOLS_DIR/vmatch.distribution"
370 \end_layout
371
372 \begin_layout LyX-Code
373
374 \size scriptsize
375 export     PATH="$INST_DIR/bin/:$INST_DIR/perl_scripts/:$INST_DIR/perl_scripts/b
376 iotools:$PATH"  
377 \end_layout
378
379 \begin_layout LyX-Code
380
381 \size scriptsize
382 export PERL5LIB="$PERL5LIB:$INST_DIR" 
383 \end_layout
384
385 \begin_layout LyX-Code
386
387 \end_layout
388
389 \begin_layout LyX-Code
390
391 \size scriptsize
392 # Alias allowing power scripting with biotools
393 \end_layout
394
395 \begin_layout LyX-Code
396
397 \end_layout
398
399 \begin_layout LyX-Code
400
401 \size scriptsize
402 alias bioscript="perl -I $INST_DIR/Maasha -MBiotools=read_stream,get_recor
403 d,put_record -e"
404 \end_layout
405
406 \begin_layout LyX-Code
407
408 \end_layout
409
410 \begin_layout LyX-Code
411
412 \size scriptsize
413 # >>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<
414 \end_layout
415
416 \begin_layout Section
417 Getting Started
418 \end_layout
419
420 \begin_layout Standard
421 The biotool 
422 \series bold
423 list_biotools
424 \series default
425  lists all the biotools along with a description:
426 \end_layout
427
428 \begin_layout LyX-Code
429
430 \size scriptsize
431 list_biotools
432 \end_layout
433
434 \begin_layout LyX-Code
435
436 \size scriptsize
437 align_seq             Align sequences in stream using Muscle.
438 \end_layout
439
440 \begin_layout LyX-Code
441
442 \size scriptsize
443 analyze_seq           Analysis the residue composition of each sequence
444  in stream.
445 \end_layout
446
447 \begin_layout LyX-Code
448
449 \size scriptsize
450 analyze_vals          Determine type, count, min, max, sum and mean for
451  values in stream.
452 \end_layout
453
454 \begin_layout LyX-Code
455
456 \size scriptsize
457 blast_seq             BLAST sequences in stream against a specified database.
458 \end_layout
459
460 \begin_layout LyX-Code
461
462 \size scriptsize
463 blat_seq              BLAT sequences in stream against a specified genome.
464 \end_layout
465
466 \begin_layout LyX-Code
467
468 \size scriptsize
469 complement_seq        Complement sequences in stream.
470 \end_layout
471
472 \begin_layout LyX-Code
473
474 \size scriptsize
475 count_records         Count the number of records in stream.
476 \end_layout
477
478 \begin_layout LyX-Code
479
480 \size scriptsize
481 count_seq             Count sequences in stream.
482 \end_layout
483
484 \begin_layout LyX-Code
485
486 \size scriptsize
487 count_vals            Count the number of times values of given keys exists
488  in stream.
489 \end_layout
490
491 \begin_layout LyX-Code
492
493 \size scriptsize
494 create_blast_db       Create a BLAST database from sequences in stream for
495  use with BLAST.
496 \end_layout
497
498 \begin_layout LyX-Code
499
500 \size scriptsize
501 ...
502 \end_layout
503
504 \begin_layout Standard
505 To list the biotools for writing different formats, you can use unix's grep
506  like this:
507 \end_layout
508
509 \begin_layout LyX-Code
510
511 \size scriptsize
512 list_biotools | grep write
513 \end_layout
514
515 \begin_layout LyX-Code
516
517 \size scriptsize
518 write_align           Write aligned sequences in pretty alignment format.
519 \end_layout
520
521 \begin_layout LyX-Code
522
523 \size scriptsize
524 write_bed             Write records from stream as BED lines.
525 \end_layout
526
527 \begin_layout LyX-Code
528
529 \size scriptsize
530 write_blast           Write BLAST records from stream in BLAST tabular format
531  (-m8 and 9).
532 \end_layout
533
534 \begin_layout LyX-Code
535
536 \size scriptsize
537 write_fasta           Write sequences in FASTA format.
538 \end_layout
539
540 \begin_layout LyX-Code
541
542 \size scriptsize
543 write_psl             Write records from stream in PSL format.
544 \end_layout
545
546 \begin_layout LyX-Code
547
548 \size scriptsize
549 write_tab             Write records from stream as tab separated table.
550 \end_layout
551
552 \begin_layout Standard
553 In order to find out how a specific biotool works, you just type the program
554  name without any arguments and press return and the usage of the biotool
555  will be displayed.
556  E.g.
557  
558 \series bold
559 read_fasta
560 \series default
561  <return>:
562 \end_layout
563
564 \begin_layout Standard
565 \begin_inset Box Frameless
566 position "t"
567 hor_pos "c"
568 has_inner_box 1
569 inner_pos "t"
570 use_parbox 0
571 width "100col%"
572 special "none"
573 height "1in"
574 height_special "totalheight"
575 status open
576
577 \begin_layout LyX-Code
578
579 \size scriptsize
580 Program name:   read_fasta
581 \end_layout
582
583 \begin_layout LyX-Code
584
585 \size scriptsize
586 Author:         Martin Asser Hansen - Copyright (C) - All rights reserved
587 \end_layout
588
589 \begin_layout LyX-Code
590
591 \size scriptsize
592 Contact:        mail@maasha.dk
593 \end_layout
594
595 \begin_layout LyX-Code
596
597 \size scriptsize
598 Date:           August 2007
599 \end_layout
600
601 \begin_layout LyX-Code
602
603 \size scriptsize
604 License:        GNU General Public License version 2 (http://www.gnu.org/copyleft/
605 gpl.html)
606 \end_layout
607
608 \begin_layout LyX-Code
609
610 \size scriptsize
611 Description:    Read FASTA entries.
612 \end_layout
613
614 \begin_layout LyX-Code
615
616 \size scriptsize
617 Usage:          read_fasta [options] -i <FASTA file(s)>
618 \end_layout
619
620 \begin_layout LyX-Code
621
622 \size scriptsize
623 Options:
624 \end_layout
625
626 \begin_layout LyX-Code
627
628 \size scriptsize
629    [-i <file(s)> | --data_in=<file(s)>]  -  Comma separated list of files
630  to read.
631 \end_layout
632
633 \begin_layout LyX-Code
634
635 \size scriptsize
636    [-n <int>     | --num=<int>]          -  Limit number of records to read.
637 \end_layout
638
639 \begin_layout LyX-Code
640
641 \size scriptsize
642    [-I <file>    | --stream_in=<file>]   -  Read input stream from file
643   -  Default=STDIN
644 \end_layout
645
646 \begin_layout LyX-Code
647
648 \size scriptsize
649    [-O <file>    | --stream_out=<file>]  -  Write output stream to file
650   -  Default=STDOUT
651 \end_layout
652
653 \begin_layout LyX-Code
654
655 \end_layout
656
657 \begin_layout LyX-Code
658
659 \size scriptsize
660 Examples:
661 \end_layout
662
663 \begin_layout LyX-Code
664
665 \size scriptsize
666    read_fasta -i test.fna             -  Read FASTA entries from file.
667 \end_layout
668
669 \begin_layout LyX-Code
670
671 \size scriptsize
672    read_fasta -i test1.fna,test2,fna  -  Read FASTA entries from files.
673 \end_layout
674
675 \begin_layout LyX-Code
676
677 \size scriptsize
678    read_fasta -i '*.fna'              -  Read FASTA entries from files.
679 \end_layout
680
681 \begin_layout LyX-Code
682
683 \size scriptsize
684    read_fasta -i test.fna -n 10       -  Read first 10 FASTA entries from
685  file.
686 \end_layout
687
688 \end_inset
689
690
691 \end_layout
692
693 \begin_layout Section
694 The Data Stream
695 \end_layout
696
697 \begin_layout Subsection
698 How to read the data stream from file?
699 \begin_inset LatexCommand label
700 name "sub:How-to-read-stream"
701
702 \end_inset
703
704
705 \end_layout
706
707 \begin_layout Standard
708 You want to read a data stream that you previously have saved to file in
709  biotools format.
710  This can be done implicetly or explicitly.
711  The implicit way uses the 'stdout' stream of the Unix terminal:
712 \end_layout
713
714 \begin_layout LyX-Code
715 cat | <biotool>
716 \end_layout
717
718 \begin_layout Standard
719 cat is the Unix command that reads a file and output the result to 'stdout'
720  --- which in this case is piped to any biotool represented by the <biotool>.
721  It is also possible to read the data stream using '<' to direct the 'stdout'
722  stream into the biotool like this:
723 \end_layout
724
725 \begin_layout LyX-Code
726 <biotool> < <file>
727 \end_layout
728
729 \begin_layout Standard
730 However, that will not work if you pipe more biotools together.
731  Then it is much safer to read the stream from a file explicitly like this:
732 \end_layout
733
734 \begin_layout LyX-Code
735 <biotool> --stream_in=<file>
736 \end_layout
737
738 \begin_layout Standard
739 Here the filename <file> is explicetly given to the biotool <biotool> with
740  the switch 
741 \begin_inset ERT
742 status collapsed
743
744 \begin_layout Standard
745
746 -
747 \backslash
748 /-
749 \end_layout
750
751 \end_inset
752
753 stream_in.
754  This switch works with all biotools.
755  It is also possible to read in data from multiple sources by repeating
756  the explicit read step:
757 \end_layout
758
759 \begin_layout LyX-Code
760 <biotool> --stream_in=<file1> | <biotool> --stream_in=<file2>
761 \end_layout
762
763 \begin_layout Subsection
764 How to write the data stream to file?
765 \begin_inset LatexCommand label
766 name "sub:How-to-write-stream"
767
768 \end_inset
769
770
771 \end_layout
772
773 \begin_layout Standard
774 In order to save the output stream from a biotool to file, so you can read
775  in the stream again at a later time, you can do one of two things:
776 \end_layout
777
778 \begin_layout LyX-Code
779 <biotool> > <file>
780 \end_layout
781
782 \begin_layout Standard
783 All, the biotools write the data stream to 'stdout' by default which can
784  be written to a file by redirecting 'stdout' to file using '>' , however,
785  if one of the biotools for writing other formats is used then the both
786  the biotools records as well as the result output will go to 'stdout' in
787  a mixture causing havock! To avoid this you must use the switch 
788 \begin_inset ERT
789 status collapsed
790
791 \begin_layout Standard
792
793 -
794 \backslash
795 /-
796 \end_layout
797
798 \end_inset
799
800 stream_out that explictly tells the biotool to write the output stream to
801  file:
802 \end_layout
803
804 \begin_layout LyX-Code
805 <biotool> --stream_out=<file>
806 \end_layout
807
808 \begin_layout Standard
809 The 
810 \begin_inset ERT
811 status collapsed
812
813 \begin_layout Standard
814
815 -
816 \backslash
817 /-
818 \end_layout
819
820 \end_inset
821
822 stream_out switch works with all biotools.
823 \end_layout
824
825 \begin_layout Subsection
826 How to terminate the data stream?
827 \end_layout
828
829 \begin_layout Standard
830 The data stream is never stops unless the user want to save the stream or
831  by supplying the 
832 \begin_inset ERT
833 status collapsed
834
835 \begin_layout Standard
836
837 -
838 \backslash
839 /-
840 \end_layout
841
842 \end_inset
843
844 no_stream switch that will terminate the stream:
845 \end_layout
846
847 \begin_layout LyX-Code
848 <biotool> --no_stream
849 \end_layout
850
851 \begin_layout Standard
852 The 
853 \begin_inset ERT
854 status collapsed
855
856 \begin_layout Standard
857
858 -
859 \backslash
860 /-
861 \end_layout
862
863 \end_inset
864
865 no_stream switch only works with those biotools where it makes sense that
866  the user might want to terminale the data stream, 
867 \emph on
868 i.e
869 \emph default
870 .
871  after an analysis step where the user wants to output the result, but not
872  the data stream.
873 \end_layout
874
875 \begin_layout Subsection
876 How to write my results to file?
877 \begin_inset LatexCommand label
878 name "sub:How-to-write-result"
879
880 \end_inset
881
882
883 \end_layout
884
885 \begin_layout Standard
886 Saving the result of an analysis to file can be done implicitly or explicitly.
887  The implicit way:
888 \end_layout
889
890 \begin_layout LyX-Code
891 <biotool> --no_stream > <file>
892 \end_layout
893
894 \begin_layout Standard
895 If you use '>' to redirect 'stdout' to file then it is important to use
896  the 
897 \begin_inset ERT
898 status collapsed
899
900 \begin_layout Standard
901
902 -
903 \backslash
904 /-
905 \end_layout
906
907 \end_inset
908
909 no_stream switch to avoid writing a mix of biotools records and result to
910  the same file causing havock.
911  The safe way is to use the 
912 \begin_inset ERT
913 status open
914
915 \begin_layout Standard
916
917 -
918 \backslash
919 /-
920 \end_layout
921
922 \end_inset
923
924 result_out switch which explicetly tells the biotool to write the result
925  to a given file:
926 \end_layout
927
928 \begin_layout LyX-Code
929 <biotool> --result_out=<file>
930 \end_layout
931
932 \begin_layout Standard
933 Using the above method will not terminate the stream, so it is possible
934  to pipe that into another biotool generating different results:
935 \end_layout
936
937 \begin_layout LyX-Code
938 <biotool1> --result_out=<file1> | <biotool2> --result_out=<file2>
939 \end_layout
940
941 \begin_layout Standard
942 And still the data stream will continue unless terminated with 
943 \begin_inset ERT
944 status collapsed
945
946 \begin_layout Standard
947
948 -
949 \backslash
950 /-
951 \end_layout
952
953 \end_inset
954
955 no_stream:
956 \end_layout
957
958 \begin_layout LyX-Code
959 <biotool> --result_out=<file> --no_stream
960 \end_layout
961
962 \begin_layout Standard
963 Or written to file using implicitly or explicity 
964 \begin_inset LatexCommand eqref
965 reference "sub:How-to-write-result"
966
967 \end_inset
968
969 .
970  The explicit way:
971 \end_layout
972
973 \begin_layout LyX-Code
974 <biotool> --result_out=<file1> --stream_out=<file2>
975 \end_layout
976
977 \begin_layout Subsection
978 How to read data from multiple sources?
979 \end_layout
980
981 \begin_layout Standard
982 To read multiple data sources, with the same type or different type of data
983  do:
984 \end_layout
985
986 \begin_layout LyX-Code
987 <biotool1> --data_in=<file1> | <biotool2> --data_in=<file2>
988 \end_layout
989
990 \begin_layout Standard
991 where type is the data type a specific biotool reads.
992 \end_layout
993
994 \begin_layout Section
995 Reading input
996 \end_layout
997
998 \begin_layout Subsection
999 How to read biotools input?
1000 \end_layout
1001
1002 \begin_layout Standard
1003 See 
1004 \begin_inset LatexCommand eqref
1005 reference "sub:How-to-read-stream"
1006
1007 \end_inset
1008
1009 .
1010 \end_layout
1011
1012 \begin_layout Subsection
1013 How to read in data?
1014 \end_layout
1015
1016 \begin_layout Standard
1017 Data in different formats can be read with the appropriate biotool for that
1018  format.
1019  The biotools are typicalled named 'read_<data type>' such as 
1020 \series bold
1021 read_fasta
1022 \series default
1023
1024 \series bold
1025 read_bed
1026 \series default
1027
1028 \series bold
1029 read_tab
1030 \series default
1031 , etc., and all behave in a similar manner.
1032  Data can be read by supplying the 
1033 \begin_inset ERT
1034 status collapsed
1035
1036 \begin_layout Standard
1037
1038 -
1039 \backslash
1040 /-
1041 \end_layout
1042
1043 \end_inset
1044
1045 data_in switch and a file name to the file containing the data:
1046 \end_layout
1047
1048 \begin_layout LyX-Code
1049 <biotool> --data_in=<file>
1050 \end_layout
1051
1052 \begin_layout Standard
1053 It is also possible to read in a saved biotools stream (see 
1054 \begin_inset LatexCommand ref
1055 reference "sub:How-to-read-stream"
1056
1057 \end_inset
1058
1059 ) as well as reading data in one go:
1060 \end_layout
1061
1062 \begin_layout LyX-Code
1063 <biotool> --stream_in=<file1> --data_in=<file2>
1064 \end_layout
1065
1066 \begin_layout Standard
1067 If you want to read data from several files you can do this:
1068 \end_layout
1069
1070 \begin_layout LyX-Code
1071 <biotool> --data_in=<file1> | <biotool> --data_in=<file2>
1072 \end_layout
1073
1074 \begin_layout Standard
1075 If you have several data files you can read in all explicitly with a comma
1076  separated list:
1077 \end_layout
1078
1079 \begin_layout LyX-Code
1080 <biotool> --data_in=file1,file2,file3
1081 \end_layout
1082
1083 \begin_layout Standard
1084 And it is also possible to use file globbing
1085 \begin_inset Foot
1086 status open
1087
1088 \begin_layout Standard
1089 using the short option will only work if you quote the argument -i '*.fna'
1090 \end_layout
1091
1092 \end_inset
1093
1094 :
1095 \end_layout
1096
1097 \begin_layout LyX-Code
1098 <biotool> --data_in=*.fna
1099 \end_layout
1100
1101 \begin_layout Standard
1102 Or in a combination:
1103 \end_layout
1104
1105 \begin_layout LyX-Code
1106 <biotool> --data_in=file1,/dir/*.fna
1107 \end_layout
1108
1109 \begin_layout Standard
1110 Finally, it is possible to read in data in different formats using the appropria
1111 te biotool for each format:
1112 \end_layout
1113
1114 \begin_layout LyX-Code
1115 <biotool1> --data_in=<file1> | <biotool2> --data_in=<file2> ...
1116 \end_layout
1117
1118 \begin_layout Subsection
1119 How to read FASTA input?
1120 \end_layout
1121
1122 \begin_layout Standard
1123 Sequences in FASTA format can be read explicitly using 
1124 \series bold
1125 read_fasta
1126 \series default
1127 :
1128 \end_layout
1129
1130 \begin_layout LyX-Code
1131 read_fasta --data_in=<file>
1132 \end_layout
1133
1134 \begin_layout Subsection
1135 How to read alignment input?
1136 \end_layout
1137
1138 \begin_layout Standard
1139 If your alignment if FASTA formatted then you can 
1140 \series bold
1141 read_align
1142 \series default
1143 .
1144  It is also possible to use 
1145 \series bold
1146 read_fasta
1147 \series default
1148  since the data is FASTA formatted, however, with 
1149 \series bold
1150 read_fasta
1151 \series default
1152  the key ALIGN will be omitted.
1153  The ALIGN key is used to determine which sequences belong to what alignment
1154  which is required for 
1155 \series bold
1156 write_align
1157 \series default
1158 .
1159 \end_layout
1160
1161 \begin_layout LyX-Code
1162 read_align --data_in=<file>
1163 \end_layout
1164
1165 \begin_layout Subsection
1166 How to read tabular input?
1167 \begin_inset LatexCommand label
1168 name "sub:How-to-read-table"
1169
1170 \end_inset
1171
1172
1173 \end_layout
1174
1175 \begin_layout Standard
1176 Tabular input can be read with 
1177 \series bold
1178 read_tab
1179 \series default
1180  which will read in all rows and chosen columns (separated by a given delimter)
1181  from a table in text format.
1182 \end_layout
1183
1184 \begin_layout Standard
1185 The table below:
1186 \end_layout
1187
1188 \begin_layout Standard
1189 \noindent
1190 \align center
1191 \begin_inset Tabular
1192 <lyxtabular version="3" rows="4" columns="3">
1193 <features>
1194 <column alignment="left" valignment="top" width="0">
1195 <column alignment="left" valignment="top" width="0">
1196 <column alignment="left" valignment="top" width="0">
1197 <row>
1198 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1199 \begin_inset Text
1200
1201 \begin_layout Standard
1202 Human
1203 \end_layout
1204
1205 \end_inset
1206 </cell>
1207 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1208 \begin_inset Text
1209
1210 \begin_layout Standard
1211 ATACGTCAG
1212 \end_layout
1213
1214 \end_inset
1215 </cell>
1216 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1217 \begin_inset Text
1218
1219 \begin_layout Standard
1220 23524
1221 \end_layout
1222
1223 \end_inset
1224 </cell>
1225 </row>
1226 <row>
1227 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1228 \begin_inset Text
1229
1230 \begin_layout Standard
1231 Dog
1232 \end_layout
1233
1234 \end_inset
1235 </cell>
1236 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1237 \begin_inset Text
1238
1239 \begin_layout Standard
1240 AGCATGAC
1241 \end_layout
1242
1243 \end_inset
1244 </cell>
1245 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1246 \begin_inset Text
1247
1248 \begin_layout Standard
1249 2442
1250 \end_layout
1251
1252 \end_inset
1253 </cell>
1254 </row>
1255 <row>
1256 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1257 \begin_inset Text
1258
1259 \begin_layout Standard
1260 Mouse
1261 \end_layout
1262
1263 \end_inset
1264 </cell>
1265 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1266 \begin_inset Text
1267
1268 \begin_layout Standard
1269 GACTG
1270 \end_layout
1271
1272 \end_inset
1273 </cell>
1274 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1275 \begin_inset Text
1276
1277 \begin_layout Standard
1278 234
1279 \end_layout
1280
1281 \end_inset
1282 </cell>
1283 </row>
1284 <row>
1285 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1286 \begin_inset Text
1287
1288 \begin_layout Standard
1289 Cat
1290 \end_layout
1291
1292 \end_inset
1293 </cell>
1294 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1295 \begin_inset Text
1296
1297 \begin_layout Standard
1298 AAATGCA
1299 \end_layout
1300
1301 \end_inset
1302 </cell>
1303 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1304 \begin_inset Text
1305
1306 \begin_layout Standard
1307 2342
1308 \end_layout
1309
1310 \end_inset
1311 </cell>
1312 </row>
1313 </lyxtabular>
1314
1315 \end_inset
1316
1317
1318 \end_layout
1319
1320 \begin_layout Standard
1321 Can be read using the command:
1322 \end_layout
1323
1324 \begin_layout LyX-Code
1325 read_tab --data_in=<file>
1326 \end_layout
1327
1328 \begin_layout Standard
1329 Which will result in four records, one for each row, where the keys V0,
1330  V1, V2 are the default keys for the organism, sequence, and count, respectively.
1331  It is possible to select a subset of colums to read by using the 
1332 \begin_inset ERT
1333 status collapsed
1334
1335 \begin_layout Standard
1336
1337 -
1338 \backslash
1339 /-
1340 \end_layout
1341
1342 \end_inset
1343
1344 cols switch which takes a comma separated list of columns numbers (first
1345  column is designated 0) as argument.
1346  So to read in only the sequence and the count so that the count comes before
1347  the sequence do:
1348 \end_layout
1349
1350 \begin_layout LyX-Code
1351 read_tab --data_in=<file> --cols=2,1
1352 \end_layout
1353
1354 \begin_layout Standard
1355 It is also possible to name the columns with the 
1356 \begin_inset ERT
1357 status collapsed
1358
1359 \begin_layout Standard
1360
1361 -
1362 \backslash
1363 /-
1364 \end_layout
1365
1366 \end_inset
1367
1368 keys switch:
1369 \end_layout
1370
1371 \begin_layout LyX-Code
1372 read_tab --data_in=<file> --cols=2,1 --keys=COUNT,SEQ
1373 \end_layout
1374
1375 \begin_layout Subsection
1376 How to read BED input?
1377 \end_layout
1378
1379 \begin_layout Standard
1380 The BED (Browser Extensible Data
1381 \begin_inset Foot
1382 status open
1383
1384 \begin_layout Standard
1385 \begin_inset LatexCommand url
1386 target "http://genome.ucsc.edu/FAQ/FAQformat"
1387
1388 \end_inset
1389
1390
1391 \end_layout
1392
1393 \end_inset
1394
1395 ) format is a tabular format for data pertaining to one of the Eukaryotic
1396  genomes in the UCSC genome brower
1397 \begin_inset Foot
1398 status collapsed
1399
1400 \begin_layout Standard
1401 \begin_inset LatexCommand url
1402 target "http://genome.ucsc.edu/"
1403
1404 \end_inset
1405
1406
1407 \end_layout
1408
1409 \end_inset
1410
1411 .
1412  The BED format consists of up to 12 columns, where the first three are
1413  mandatory CHR, CHR_BEG, and CHR_END.
1414  The mandatory columns and any of the optional columns can all be read in
1415  easily with the 
1416 \series bold
1417 read_bed
1418 \series default
1419  biotool.
1420 \end_layout
1421
1422 \begin_layout LyX-Code
1423 read_bed --data_in=<file>
1424 \end_layout
1425
1426 \begin_layout Standard
1427 It is also possible to read the BED file with 
1428 \series bold
1429 read_tab
1430 \series default
1431  (see\InsetSpace ~
1432
1433 \begin_inset LatexCommand ref
1434 reference "sub:How-to-read-table"
1435
1436 \end_inset
1437
1438 ), however, that will be more cumbersome because you need to specify the
1439  keys:
1440 \end_layout
1441
1442 \begin_layout LyX-Code
1443 read_tab --data_in=<file> --keys=CHR,CHR_BEG,CHR_END ...
1444 \end_layout
1445
1446 \begin_layout Subsection
1447 How to read PSL input?
1448 \end_layout
1449
1450 \begin_layout Standard
1451 The PSL format is the output from BLAT and contains 21 mandatory fields
1452  that can be read with 
1453 \series bold
1454 read_psl
1455 \series default
1456 :
1457 \end_layout
1458
1459 \begin_layout LyX-Code
1460 read_psl --data_in=<file>
1461 \end_layout
1462
1463 \begin_layout Section
1464 Writing output
1465 \end_layout
1466
1467 \begin_layout Standard
1468 All result output can be written explicitly to file using the 
1469 \begin_inset ERT
1470 status collapsed
1471
1472 \begin_layout Standard
1473
1474 -
1475 \backslash
1476 /-
1477 \end_layout
1478
1479 \end_inset
1480
1481 result_out switch which all result generating biotools have.
1482  It is also possible to write the result to file implicetly by directing
1483  'stdout' to file using '>', however, that requires the 
1484 \begin_inset ERT
1485 status collapsed
1486
1487 \begin_layout Standard
1488
1489 -
1490 \backslash
1491 /-
1492 \end_layout
1493
1494 \end_inset
1495
1496 no_stream swich to prevent a mixture of data stream and results in the file.
1497  The explicit (and safe) way:
1498 \end_layout
1499
1500 \begin_layout LyX-Code
1501 ...
1502  | <biotool> --result_out=<file>
1503 \end_layout
1504
1505 \begin_layout Standard
1506 The implicit way:
1507 \end_layout
1508
1509 \begin_layout LyX-Code
1510 ...
1511  | <biotool> --no_stream > <file>
1512 \end_layout
1513
1514 \begin_layout Subsection
1515 How to write biotools output?
1516 \end_layout
1517
1518 \begin_layout Standard
1519 See 
1520 \begin_inset LatexCommand eqref
1521 reference "sub:How-to-write-stream"
1522
1523 \end_inset
1524
1525 .
1526 \end_layout
1527
1528 \begin_layout Subsection
1529 How to write FASTA output?
1530 \begin_inset LatexCommand label
1531 name "sub:How-to-write-fasta"
1532
1533 \end_inset
1534
1535
1536 \end_layout
1537
1538 \begin_layout Standard
1539 FASTA output can be written with 
1540 \series bold
1541 write_fasta
1542 \series default
1543 .
1544 \end_layout
1545
1546 \begin_layout LyX-Code
1547 ...
1548  | write_fasta --result_out=<file>
1549 \end_layout
1550
1551 \begin_layout Standard
1552 It is also possible to wrap the sequences to a given width using the 
1553 \begin_inset ERT
1554 status collapsed
1555
1556 \begin_layout Standard
1557
1558 -
1559 \backslash
1560 /-
1561 \end_layout
1562
1563 \end_inset
1564
1565 wrap switch allthough wrapping of sequence is generally an evil thing:
1566 \end_layout
1567
1568 \begin_layout LyX-Code
1569 ...
1570  | write_fasta --no_stream --wrap=80
1571 \end_layout
1572
1573 \begin_layout Subsection
1574 How to write alignment output?
1575 \begin_inset LatexCommand label
1576 name "sub:How-to-write-alignment"
1577
1578 \end_inset
1579
1580
1581 \end_layout
1582
1583 \begin_layout Standard
1584 Pretty alignments with ruler
1585 \begin_inset Foot
1586 status collapsed
1587
1588 \begin_layout Standard
1589 '.' for every 10 residues, ':' for every 50, and '|' for every 100
1590 \end_layout
1591
1592 \end_inset
1593
1594  and consensus sequence
1595 \begin_inset Note Note
1596 status collapsed
1597
1598 \begin_layout Standard
1599 which reminds me to make that an option.
1600 \end_layout
1601
1602 \end_inset
1603
1604  can be created with 
1605 \series bold
1606 write_align
1607 \series default
1608 , what also have the optional 
1609 \begin_inset ERT
1610 status collapsed
1611
1612 \begin_layout Standard
1613
1614 -
1615 \backslash
1616 /-
1617 \end_layout
1618
1619 \end_inset
1620
1621 wrap switch to break the alignment into blocks of a given width: 
1622 \end_layout
1623
1624 \begin_layout LyX-Code
1625 ...
1626  | write_align --result_out=<file> --wrap=80
1627 \end_layout
1628
1629 \begin_layout Standard
1630 If the number of sequnces in the alignment is 2 then a pairwise alignment
1631  will be output otherwise a multiple alignment.
1632  And if the sequence type, determined automagically, is protein, then residues
1633  and symbols (+,\InsetSpace ~
1634 :,\InsetSpace ~
1635 .) will be used to show consensus according to the Blosum62
1636  matrix.
1637 \end_layout
1638
1639 \begin_layout Subsection
1640 How to write tabular output?
1641 \begin_inset LatexCommand label
1642 name "sub:How-to-write-tab"
1643
1644 \end_inset
1645
1646
1647 \end_layout
1648
1649 \begin_layout Standard
1650 Outputting the data stream as a table can be done with 
1651 \series bold
1652 write_tab
1653 \series default
1654 , which will write generate one row per record with the values as columns.
1655  If you supply the optional 
1656 \begin_inset ERT
1657 status collapsed
1658
1659 \begin_layout Standard
1660
1661 -
1662 \backslash
1663 /-
1664 \end_layout
1665
1666 \end_inset
1667
1668 comment switch, when the first row in the table will be a 'comment' line
1669  prefixed with a '#':
1670 \end_layout
1671
1672 \begin_layout LyX-Code
1673 ...
1674  | write_tab --result_out=<file> --comment
1675 \end_layout
1676
1677 \begin_layout Standard
1678 You can also change the delimiter from the default (tab) to 
1679 \emph on
1680 e.g.
1681
1682 \emph default
1683  ',':
1684 \end_layout
1685
1686 \begin_layout LyX-Code
1687 ...
1688  | write_tab --result_out=<file> --delimit=','
1689 \end_layout
1690
1691 \begin_layout Standard
1692 If you want the values output in a specific order you have to supply a comma
1693  separated list using the 
1694 \begin_inset ERT
1695 status collapsed
1696
1697 \begin_layout Standard
1698
1699 -
1700 \backslash
1701 /-
1702 \end_layout
1703
1704 \end_inset
1705
1706 keys switch that will print only those keys in that order:
1707 \end_layout
1708
1709 \begin_layout LyX-Code
1710 ...
1711  | write_tab --result_out=<file> --keys=SEQ_NAME,COUNT
1712 \end_layout
1713
1714 \begin_layout Standard
1715 Alternatively, if you have some keys that you don't want in the tabular
1716  output, use the 
1717 \begin_inset ERT
1718 status collapsed
1719
1720 \begin_layout Standard
1721
1722 -
1723 \backslash
1724 /-
1725 \end_layout
1726
1727 \end_inset
1728
1729 no_keys switch.
1730  So to print all keys except SEQ and SEQ_TYPE do:
1731 \end_layout
1732
1733 \begin_layout LyX-Code
1734 ...
1735  | write_tab --result_out=<file> --no_keys=SEQ,SEQ_TYPE
1736 \end_layout
1737
1738 \begin_layout Standard
1739 Finally, if you have a stream containing a mix of different records types,
1740  
1741 \emph on
1742 e.g.
1743
1744 \emph default
1745  records with sequences and records with matches, then you can use 
1746 \series bold
1747 write_tab
1748 \series default
1749  to output all the records in tabluar format, however, the 
1750 \begin_inset ERT
1751 status collapsed
1752
1753 \begin_layout Standard
1754
1755 -
1756 \backslash
1757 /-
1758 \end_layout
1759
1760 \end_inset
1761
1762 comment, 
1763 \begin_inset ERT
1764 status collapsed
1765
1766 \begin_layout Standard
1767
1768 -
1769 \backslash
1770 /-
1771 \end_layout
1772
1773 \end_inset
1774
1775 keys, and 
1776 \begin_inset ERT
1777 status collapsed
1778
1779 \begin_layout Standard
1780
1781 -
1782 \backslash
1783 /-
1784 \end_layout
1785
1786 \end_inset
1787
1788 no_keys switches will only respond to records of the first type encountered.
1789  The reason is that outputting mixed records is probably not what you want
1790  anyway, and you should remove all the unwanted records from the stream
1791  before outputting the table: 
1792 \series bold
1793 grab
1794 \series default
1795  is your friend (see\InsetSpace ~
1796
1797 \begin_inset LatexCommand ref
1798 reference "sub:How-to-grab"
1799
1800 \end_inset
1801
1802 ).
1803 \end_layout
1804
1805 \begin_layout Subsection
1806 How to write a BED output?
1807 \begin_inset LatexCommand label
1808 name "sub:How-to-write-BED"
1809
1810 \end_inset
1811
1812
1813 \end_layout
1814
1815 \begin_layout Standard
1816 Data in BED format can be output if the records contain the mandatory keys
1817  CHR, CHR_BEG, and CHR_END using 
1818 \series bold
1819 write_bed
1820 \series default
1821 .
1822  If the optional keys are also present, they will be output as well:
1823 \end_layout
1824
1825 \begin_layout LyX-Code
1826 write_bed --result_out=<file>
1827 \end_layout
1828
1829 \begin_layout Subsection
1830 How to write PSL output?
1831 \begin_inset LatexCommand label
1832 name "sub:How-to-write-PSL"
1833
1834 \end_inset
1835
1836
1837 \end_layout
1838
1839 \begin_layout Standard
1840 Data in PSL format can be output using 
1841 \series bold
1842 write_psl:
1843 \end_layout
1844
1845 \begin_layout LyX-Code
1846 write_psl --result_out=<file>
1847 \end_layout
1848
1849 \begin_layout Section
1850 Manipulating Records
1851 \end_layout
1852
1853 \begin_layout Subsection
1854 How to select a few records?
1855 \begin_inset LatexCommand label
1856 name "sub:How-to-select-a-few-records"
1857
1858 \end_inset
1859
1860
1861 \end_layout
1862
1863 \begin_layout Standard
1864 To quickly get an overview of your data you can limit the data stream to
1865  show a few records.
1866  This also very useful to test the pipeline with a few records if you are
1867  setting up a complex analysis using several biotools.
1868  That way you can inspect that all goes well before analyzing and waiting
1869  for the full data set.
1870  All of the read_<type> biotools have the 
1871 \begin_inset ERT
1872 status collapsed
1873
1874 \begin_layout Standard
1875
1876 -
1877 \backslash
1878 /-
1879 \end_layout
1880
1881 \end_inset
1882
1883 num switch which will take a number as argument and only that number of
1884  records will be read.
1885  So to read in the first 10 FASTA entries from a file:
1886 \end_layout
1887
1888 \begin_layout LyX-Code
1889 read_fasta --data_in=test.fna --num=10
1890 \end_layout
1891
1892 \begin_layout Standard
1893 Another way of doing this is to use 
1894 \series bold
1895 head_records
1896 \series default
1897  will limit the stream to show the first 10 records (default):
1898 \end_layout
1899
1900 \begin_layout LyX-Code
1901 ...
1902  | head_records
1903 \end_layout
1904
1905 \begin_layout Standard
1906 Using 
1907 \series bold
1908 head_records
1909 \series default
1910  directly after one of the read_<type> biotools will be a lot slower than
1911  using the 
1912 \begin_inset ERT
1913 status collapsed
1914
1915 \begin_layout Standard
1916
1917 -
1918 \backslash
1919 /-
1920 \end_layout
1921
1922 \end_inset
1923
1924 num switch with the read_<type> biotools, however, 
1925 \series bold
1926 head_records
1927 \series default
1928  can also be used to limit the output from all the other biotools.
1929  It is also possible to give 
1930 \series bold
1931 head_records
1932 \series default
1933  a number of records to show using the 
1934 \begin_inset ERT
1935 status collapsed
1936
1937 \begin_layout Standard
1938
1939 -
1940 \backslash
1941 /-
1942 \end_layout
1943
1944 \end_inset
1945
1946 num switch.
1947  So to display the first 100 records do:
1948 \end_layout
1949
1950 \begin_layout LyX-Code
1951 ...
1952  | head_records --num=100
1953 \end_layout
1954
1955 \begin_layout Subsection
1956 How to select random records?
1957 \begin_inset LatexCommand label
1958 name "sub:How-to-select-random-records"
1959
1960 \end_inset
1961
1962
1963 \end_layout
1964
1965 \begin_layout Standard
1966 If you want to inspect a number of random records from the stream this can
1967  be done with the 
1968 \series bold
1969 random_records
1970 \series default
1971  biotool.
1972  So if you have 1 mio records in the stream and you want to select 1000
1973  random records do:
1974 \end_layout
1975
1976 \begin_layout LyX-Code
1977 ...
1978  | random_records --num=1000
1979 \end_layout
1980
1981 \begin_layout Subsection
1982 How to count all records in the data stream?
1983 \end_layout
1984
1985 \begin_layout Standard
1986 To count all the records in the data stream use 
1987 \series bold
1988 count_records
1989 \series default
1990 , which adds one record (which is not included in the count) to the data
1991  stream.
1992  So to count the number of sequences in a FASTA file you can do this:
1993 \end_layout
1994
1995 \begin_layout LyX-Code
1996 cat test.fna | read_fasta | count_records --no_stream
1997 \end_layout
1998
1999 \begin_layout Standard
2000 Which will write the last record containing the count to 'stdout':
2001 \end_layout
2002
2003 \begin_layout LyX-Code
2004
2005 \size scriptsize
2006 count_records: 630
2007 \end_layout
2008
2009 \begin_layout LyX-Code
2010
2011 \size scriptsize
2012 ---
2013 \end_layout
2014
2015 \begin_layout Standard
2016 It is also possible to write the count to file using the 
2017 \begin_inset ERT
2018 status collapsed
2019
2020 \begin_layout Standard
2021
2022 -
2023 \backslash
2024 /-
2025 \end_layout
2026
2027 \end_inset
2028
2029 result_out switch.
2030 \end_layout
2031
2032 \begin_layout Subsection
2033 How to get the length of record values?
2034 \begin_inset LatexCommand label
2035 name "sub:How-to-get-value_length"
2036
2037 \end_inset
2038
2039
2040 \end_layout
2041
2042 \begin_layout Standard
2043 Use the 
2044 \series bold
2045 length_vals
2046 \series default
2047  biotool to get the length of each value for a comma separated list of keys:
2048 \end_layout
2049
2050 \begin_layout LyX-Code
2051 ...
2052  | length_vals --keys=HIT,PATTERN
2053 \end_layout
2054
2055 \begin_layout Subsection
2056 How to grab specific records?
2057 \begin_inset LatexCommand label
2058 name "sub:How-to-grab"
2059
2060 \end_inset
2061
2062
2063 \end_layout
2064
2065 \begin_layout Standard
2066 The biotool 
2067 \series bold
2068 grab
2069 \series default
2070  is related to the Unix grep and locates records based on matching keys
2071  and/or values using either a pattern, a Perl regex, or a numerical evaluation.
2072  To easily 
2073 \series bold
2074 grab
2075 \series default
2076  all records in the stream that has any mentioning of the pattern 'human'
2077  just pipe the data stream through 
2078 \series bold
2079 grab
2080 \series default
2081  like this:
2082 \end_layout
2083
2084 \begin_layout LyX-Code
2085 ...
2086  | grab --pattern=human
2087 \end_layout
2088
2089 \begin_layout Standard
2090 This will search for the pattern 'human' in all keys and all values.
2091  The 
2092 \begin_inset ERT
2093 status collapsed
2094
2095 \begin_layout Standard
2096
2097 -
2098 \backslash
2099 /-
2100 \end_layout
2101
2102 \end_inset
2103
2104 pattern switch takes a comma separated list of patterns, so in order to
2105  match multiple patterns do:
2106 \end_layout
2107
2108 \begin_layout LyX-Code
2109 ...
2110  | grab --pattern=human,mouse
2111 \end_layout
2112
2113 \begin_layout Standard
2114 It is also possible to use the 
2115 \begin_inset ERT
2116 status collapsed
2117
2118 \begin_layout Standard
2119
2120 -
2121 \backslash
2122 /-
2123 \end_layout
2124
2125 \end_inset
2126
2127 pattern_in switch instead of 
2128 \begin_inset ERT
2129 status collapsed
2130
2131 \begin_layout Standard
2132
2133 -
2134 \backslash
2135 /-
2136 \end_layout
2137
2138 \end_inset
2139
2140 pattern.
2141  
2142 \begin_inset ERT
2143 status collapsed
2144
2145 \begin_layout Standard
2146
2147 -
2148 \backslash
2149 /-
2150 \end_layout
2151
2152 \end_inset
2153
2154 pattern_in is used to read a file with one pattern per line:
2155 \end_layout
2156
2157 \begin_layout LyX-Code
2158 ...
2159  | grab --pattern_in=patterns.txt
2160 \end_layout
2161
2162 \begin_layout Standard
2163 If you want the opposite result --- to find all records that does not match
2164  the patterns, add the 
2165 \begin_inset ERT
2166 status collapsed
2167
2168 \begin_layout Standard
2169
2170 -
2171 \backslash
2172 /-
2173 \end_layout
2174
2175 \end_inset
2176
2177 invert switch, which not only works with the 
2178 \begin_inset ERT
2179 status collapsed
2180
2181 \begin_layout Standard
2182
2183 -
2184 \backslash
2185 /-
2186 \end_layout
2187
2188 \end_inset
2189
2190 pattern switch, but also with 
2191 \begin_inset ERT
2192 status collapsed
2193
2194 \begin_layout Standard
2195
2196 -
2197 \backslash
2198 /-
2199 \end_layout
2200
2201 \end_inset
2202
2203 regex and 
2204 \begin_inset ERT
2205 status collapsed
2206
2207 \begin_layout Standard
2208
2209 -
2210 \backslash
2211 /-
2212 \end_layout
2213
2214 \end_inset
2215
2216 eval:
2217 \end_layout
2218
2219 \begin_layout LyX-Code
2220 ...
2221  | grab --pattern=human --invert
2222 \end_layout
2223
2224 \begin_layout Standard
2225 If you want to search the record keys only, 
2226 \emph on
2227 e.g.
2228
2229 \emph default
2230  to find all records containing the key SEQ you can add the 
2231 \begin_inset ERT
2232 status collapsed
2233
2234 \begin_layout Standard
2235
2236 -
2237 \backslash
2238 /-
2239 \end_layout
2240
2241 \end_inset
2242
2243 keys_only switch.
2244  This will prevent matching of SEQ in any record value, and in fact SEQ
2245  is a not uncommon peptide sequence you could get an unwanted record.
2246  Also, this will give an increase in speed since only the keys are searched:
2247 \end_layout
2248
2249 \begin_layout LyX-Code
2250 ...
2251  | grab --pattern=SEQ --keys_only
2252 \end_layout
2253
2254 \begin_layout Standard
2255 However, if you are interested in finding the peptide sequence SEQ and not
2256  the SEQ key, just add the 
2257 \begin_inset ERT
2258 status collapsed
2259
2260 \begin_layout Standard
2261
2262 -
2263 \backslash
2264 /-
2265 \end_layout
2266
2267 \end_inset
2268
2269 vals_only switch instead:
2270 \end_layout
2271
2272 \begin_layout LyX-Code
2273 ...
2274  | grab --pattern=SEQ --vals_only
2275 \end_layout
2276
2277 \begin_layout Standard
2278 Also, if you want to grab for certain key/value pairs you can supply a comma
2279  separated list of keys whos values will then be searched using the 
2280 \begin_inset ERT
2281 status collapsed
2282
2283 \begin_layout Standard
2284
2285 -
2286 \backslash
2287 /-
2288 \end_layout
2289
2290 \end_inset
2291
2292 keys switch.
2293  This is handy if your records contain large genomic sequences and you dont
2294  want to search the entire sequence for 
2295 \emph on
2296 e.g.
2297
2298 \emph default
2299  the organism name --- it is much faster to tell 
2300 \series bold
2301 grab
2302 \series default
2303  which keys to search the value for:
2304 \end_layout
2305
2306 \begin_layout LyX-Code
2307 ...
2308  | grab --pattern=human --keys=SEQ_NAME
2309 \end_layout
2310
2311 \begin_layout LyX-Code
2312
2313 \end_layout
2314
2315 \begin_layout Standard
2316 It is also possible to invoke flexible matching using regex (regular expressions
2317 ) instead of simple pattern matching.
2318  In 
2319 \series bold
2320 grab
2321 \series default
2322  the regex engine is Perl based and allows use of different type of wild
2323  cards, alternatives, 
2324 \emph on
2325 etc
2326 \emph default
2327
2328 \begin_inset Foot
2329 status open
2330
2331 \begin_layout Standard
2332 \begin_inset LatexCommand url
2333 target "http://perldoc.perl.org/perlreref.html"
2334
2335 \end_inset
2336
2337
2338 \end_layout
2339
2340 \end_inset
2341
2342 .
2343  If you want to 
2344 \series bold
2345 grab
2346 \series default
2347  records withs the sequence ATCG or GCTA you can do this:
2348 \end_layout
2349
2350 \begin_layout LyX-Code
2351 ...
2352  | grab --regex='ATCG|GCTA'
2353 \end_layout
2354
2355 \begin_layout Standard
2356 Or if you want to find sequences beginning with ATCG:
2357 \end_layout
2358
2359 \begin_layout LyX-Code
2360 ...
2361  | grab --regex='^ATCG'
2362 \end_layout
2363
2364 \begin_layout Standard
2365 You can also use 
2366 \series bold
2367 grab
2368 \series default
2369  to locate records that fulfill a numerical property using the 
2370 \begin_inset ERT
2371 status collapsed
2372
2373 \begin_layout Standard
2374
2375 -
2376 \backslash
2377 /-
2378 \end_layout
2379
2380 \end_inset
2381
2382 eval switch witch takes an expression in three parts.
2383  The first part is the key that holds the value we want to evaluate, the
2384  second part holds one the six operators:
2385 \end_layout
2386
2387 \begin_layout Enumerate
2388 Greater than: >
2389 \end_layout
2390
2391 \begin_layout Enumerate
2392 Greater than or equal to: >=
2393 \end_layout
2394
2395 \begin_layout Enumerate
2396 Less than: <
2397 \end_layout
2398
2399 \begin_layout Enumerate
2400 Less than or equal to: <=
2401 \end_layout
2402
2403 \begin_layout Enumerate
2404 Equal to: =
2405 \end_layout
2406
2407 \begin_layout Enumerate
2408 Not equal to: !=
2409 \end_layout
2410
2411 \begin_layout Enumerate
2412 String wise equal to: eq
2413 \end_layout
2414
2415 \begin_layout Enumerate
2416 String wise not equal to: ne
2417 \end_layout
2418
2419 \begin_layout Standard
2420 And finally comes the number used in the evaluation.
2421  So to 
2422 \series bold
2423 grab
2424 \series default
2425  all records with a sequence length greater than 30:
2426 \end_layout
2427
2428 \begin_layout LyX-Code
2429 ...
2430  length_seq | grab --eval='SEQ_LEN > 30'
2431 \end_layout
2432
2433 \begin_layout Standard
2434 If you want to locate all records containing the pattern 'human' and where
2435  the sequence length is greater that 30, you do this by running the stream
2436  through 
2437 \series bold
2438 grab
2439 \series default
2440  twice:
2441 \end_layout
2442
2443 \begin_layout LyX-Code
2444 ...
2445  | grab --pattern='human' | length_seq | grab --eval='SEQ_LEN > 30'
2446 \end_layout
2447
2448 \begin_layout Standard
2449 Finally, it is possible to do fast matching of expressions from a file using
2450  the 
2451 \begin_inset ERT
2452 status collapsed
2453
2454 \begin_layout Standard
2455
2456 -
2457 \backslash
2458 /-
2459 \end_layout
2460
2461 \end_inset
2462
2463 exact switch.
2464  Each of these expressions has to be matched exactly over the entrie length,
2465  which if useful if you have a file with accession numbers, that you want
2466  to locate in the stream:
2467 \end_layout
2468
2469 \begin_layout LyX-Code
2470 ...
2471  | grab --exact acc_no.txt | ...
2472 \end_layout
2473
2474 \begin_layout Standard
2475 Using 
2476 \begin_inset ERT
2477 status collapsed
2478
2479 \begin_layout Standard
2480
2481 -
2482 \backslash
2483 /-
2484 \end_layout
2485
2486 \end_inset
2487
2488 exact is much faster than using 
2489 \begin_inset ERT
2490 status collapsed
2491
2492 \begin_layout Standard
2493
2494 -
2495 \backslash
2496 /-
2497 \end_layout
2498
2499 \end_inset
2500
2501 pattern_in, because with 
2502 \begin_inset ERT
2503 status collapsed
2504
2505 \begin_layout Standard
2506
2507 -
2508 \backslash
2509 /-
2510 \end_layout
2511
2512 \end_inset
2513
2514 exact the expression has to be complete matches, where 
2515 \begin_inset ERT
2516 status collapsed
2517
2518 \begin_layout Standard
2519
2520 -
2521 \backslash
2522 /-
2523 \end_layout
2524
2525 \end_inset
2526
2527 pattern_in looks for subpatterns.
2528 \end_layout
2529
2530 \begin_layout Standard
2531 NB! To get the best speed performance, use the most restrictive 
2532 \series bold
2533 grab
2534 \series default
2535  first.
2536 \end_layout
2537
2538 \begin_layout Subsection
2539 How to remove keys from records?
2540 \end_layout
2541
2542 \begin_layout Standard
2543 To remove one or more specific keys from all records in the data stream
2544  use 
2545 \series bold
2546 remove_keys
2547 \series default
2548  like this:
2549 \end_layout
2550
2551 \begin_layout LyX-Code
2552 ...
2553  | remove_keys --keys=SEQ,SEQ_NAME
2554 \end_layout
2555
2556 \begin_layout Standard
2557 In the above example SEQ and SEQ_NAME will be removed from all records if
2558  they exists in these.
2559  If all keys are removed from a record, then the record will be removed.
2560 \end_layout
2561
2562 \begin_layout Subsection
2563 How to rename keys in records?
2564 \end_layout
2565
2566 \begin_layout Standard
2567 Sometimes you want to rename a record key, 
2568 \emph on
2569 e.g.
2570
2571 \emph default
2572  if you have read in a two column table with sequence name and sequence
2573  in each column (see 
2574 \begin_inset LatexCommand ref
2575 reference "sub:How-to-read-table"
2576
2577 \end_inset
2578
2579 ) without specifying the key names, then the sequence name will be called
2580  V0 and the sequence V1 as default in the 
2581 \series bold
2582 read_tab
2583 \series default
2584  biotool.
2585  To rename the V0 and V1 keys we need to run the stream through 
2586 \series bold
2587 rename_keys
2588 \series default
2589  twice (one for each key to rename):
2590 \end_layout
2591
2592 \begin_layout LyX-Code
2593 ...
2594  | rename_keys --keys=V0,SEQ_NAME | rename_keys --keys=V1,SEQ
2595 \end_layout
2596
2597 \begin_layout Standard
2598 The first instance of 
2599 \series bold
2600 rename_keys
2601 \series default
2602  replaces all the V0 keys with SEQ_NAME, and the second instance of 
2603 \series bold
2604 rename_keys
2605 \series default
2606  replaces all the V1 keys with SEQ.
2607  
2608 \emph on
2609 Et viola
2610 \emph default
2611  the data can now be used in the biotools that requires these keys.
2612 \end_layout
2613
2614 \begin_layout Section
2615 Manipulating Sequences
2616 \end_layout
2617
2618 \begin_layout Subsection
2619 How to get sequence lengths?
2620 \end_layout
2621
2622 \begin_layout Standard
2623 The length for sequences in records can be determined with 
2624 \series bold
2625 length_seq
2626 \series default
2627 , which adds the key SEQ_LEN to each record with the sequence length as
2628  the value.
2629  It also generates an extra record that is emitted last with the key TOTAL_SEQ_L
2630 EN showing the total length of all the sequences.
2631 \end_layout
2632
2633 \begin_layout LyX-Code
2634 read_fasta --data_in=<file> | length_seq
2635 \end_layout
2636
2637 \begin_layout Standard
2638 It is also possible to determine the sequence length using the generic tool
2639  
2640 \series bold
2641 length_vals
2642 \series default
2643  
2644 \begin_inset LatexCommand eqref
2645 reference "sub:How-to-get-value_length"
2646
2647 \end_inset
2648
2649 , which determines the length of the values for a given list of keys:
2650 \end_layout
2651
2652 \begin_layout LyX-Code
2653 read_fasta --data_in=<file> | length_vals --keys=SEQ
2654 \end_layout
2655
2656 \begin_layout Standard
2657 To obtain the total length of all sequences use 
2658 \series bold
2659 sum_vals
2660 \series default
2661  like this:
2662 \end_layout
2663
2664 \begin_layout LyX-Code
2665 read_fasta --data_in=<file> | length_vals --keys=SEQ
2666 \end_layout
2667
2668 \begin_layout LyX-Code
2669 | sum_vals --keys=SEQ_LEN
2670 \end_layout
2671
2672 \begin_layout Standard
2673 The biotool 
2674 \series bold
2675 analyze_seq
2676 \series default
2677  will also determine the length of each sequence (see\InsetSpace ~
2678
2679 \begin_inset LatexCommand ref
2680 reference "sub:How-to-analyze"
2681
2682 \end_inset
2683
2684 ).
2685 \end_layout
2686
2687 \begin_layout Subsection
2688 How to analyze sequence composition?
2689 \begin_inset LatexCommand label
2690 name "sub:How-to-analyze"
2691
2692 \end_inset
2693
2694
2695 \end_layout
2696
2697 \begin_layout Standard
2698 If you want to find out the sequence type, composition, length, as well
2699  as GC content, indel content and proportions of soft and hard masked sequence,
2700  then use 
2701 \series bold
2702 analyze_seq
2703 \series default
2704 .
2705  This handy biotool will determine all these things per sequence from which
2706  it is easy to get an overview using the 
2707 \series bold
2708 write_tab
2709 \series default
2710  biotool to output a table (see\InsetSpace ~
2711
2712 \begin_inset LatexCommand ref
2713 reference "sub:How-to-write-tab"
2714
2715 \end_inset
2716
2717 ).
2718  So in order to determine the sequence composition of a FASTA file with
2719  just one entry containing the sequence 'ATCG' we just read the data with
2720  
2721 \series bold
2722 read_fasta
2723 \series default
2724  and run the output through 
2725 \series bold
2726 analyze_seq
2727 \series default
2728  which will add the analysis to the record like this:
2729 \end_layout
2730
2731 \begin_layout LyX-Code
2732 read_fasta --data_in=test.fna | analyze_seq ...
2733 \end_layout
2734
2735 \begin_layout LyX-Code
2736
2737 \end_layout
2738
2739 \begin_layout LyX-Code
2740
2741 \size scriptsize
2742 RES:D: 0
2743 \end_layout
2744
2745 \begin_layout LyX-Code
2746
2747 \size scriptsize
2748 MIX_INDEX: 0.55
2749 \end_layout
2750
2751 \begin_layout LyX-Code
2752
2753 \size scriptsize
2754 RES:W: 0
2755 \end_layout
2756
2757 \begin_layout LyX-Code
2758
2759 \size scriptsize
2760 RES:G: 16
2761 \end_layout
2762
2763 \begin_layout LyX-Code
2764
2765 \size scriptsize
2766 SOFT_MASK%: 63.75
2767 \end_layout
2768
2769 \begin_layout LyX-Code
2770
2771 \size scriptsize
2772 RES:B: 0
2773 \end_layout
2774
2775 \begin_layout LyX-Code
2776
2777 \size scriptsize
2778 RES:V: 0
2779 \end_layout
2780
2781 \begin_layout LyX-Code
2782
2783 \size scriptsize
2784 HARD_MASK%: 0.00
2785 \end_layout
2786
2787 \begin_layout LyX-Code
2788
2789 \size scriptsize
2790 RES:H: 0 
2791 \end_layout
2792
2793 \begin_layout LyX-Code
2794
2795 \size scriptsize
2796 RES:S: 0 
2797 \end_layout
2798
2799 \begin_layout LyX-Code
2800
2801 \size scriptsize
2802 RES:N: 0
2803 \end_layout
2804
2805 \begin_layout LyX-Code
2806
2807 \size scriptsize
2808 RES:.: 0 
2809 \end_layout
2810
2811 \begin_layout LyX-Code
2812
2813 \size scriptsize
2814 GC%: 35.00 
2815 \end_layout
2816
2817 \begin_layout LyX-Code
2818
2819 \size scriptsize
2820 RES:A: 8 
2821 \end_layout
2822
2823 \begin_layout LyX-Code
2824
2825 \size scriptsize
2826 RES:Y: 0 
2827 \end_layout
2828
2829 \begin_layout LyX-Code
2830
2831 \size scriptsize
2832 RES:M: 0 
2833 \end_layout
2834
2835 \begin_layout LyX-Code
2836
2837 \size scriptsize
2838 RES:T: 44 
2839 \end_layout
2840
2841 \begin_layout LyX-Code
2842
2843 \size scriptsize
2844 SEQ_TYPE: DNA 
2845 \end_layout
2846
2847 \begin_layout LyX-Code
2848
2849 \size scriptsize
2850 RES:K: 0 
2851 \end_layout
2852
2853 \begin_layout LyX-Code
2854
2855 \size scriptsize
2856 RES:~: 0 
2857 \end_layout
2858
2859 \begin_layout LyX-Code
2860
2861 \size scriptsize
2862 SEQ: TTTCAGTTTGGGACGGAGTAAGGCCTTCCtttttttttttttttttttttttttttttgagaccgagtcttgctc
2863 tgtcg 
2864 \end_layout
2865
2866 \begin_layout LyX-Code
2867
2868 \size scriptsize
2869 SEQ_LEN: 
2870 \end_layout
2871
2872 \begin_layout LyX-Code
2873
2874 \size scriptsize
2875 80 RES:R: 0 
2876 \end_layout
2877
2878 \begin_layout LyX-Code
2879
2880 \size scriptsize
2881 RES:C: 12 
2882 \end_layout
2883
2884 \begin_layout LyX-Code
2885
2886 \size scriptsize
2887 RES:-: 0 
2888 \end_layout
2889
2890 \begin_layout LyX-Code
2891
2892 \size scriptsize
2893 RES:U: 0
2894 \end_layout
2895
2896 \begin_layout LyX-Code
2897
2898 \size scriptsize
2899 ---
2900 \end_layout
2901
2902 \begin_layout LyX-Code
2903
2904 \end_layout
2905
2906 \begin_layout Standard
2907 Now to make a table of how may As, Ts, Cs, and Gs you can add the following:
2908 \end_layout
2909
2910 \begin_layout LyX-Code
2911 ...
2912  | analyze_seq | write_tab --keys=RES:A,RES:T,RES:C,RES:G
2913 \end_layout
2914
2915 \begin_layout Standard
2916 Or if you want to see the proportions of hard and soft masked sequence:
2917 \end_layout
2918
2919 \begin_layout LyX-Code
2920 ...
2921  | analyse_seq | write_tab --keys=HARD_MASK%,SOFT_MASK%
2922 \end_layout
2923
2924 \begin_layout Standard
2925 If you have a stack of sequences in one file and you want to determine the
2926  mean GC content you can do it using the 
2927 \series bold
2928 mean_vals
2929 \series default
2930  biotool:
2931 \end_layout
2932
2933 \begin_layout LyX-Code
2934 read_fasta --data_in=test.fna | analyze_seq | mean_vals --keys=GC%
2935 \end_layout
2936
2937 \begin_layout Standard
2938 Or if you want the total count of Ns you can use 
2939 \series bold
2940 sum_vals
2941 \series default
2942  like this:
2943 \end_layout
2944
2945 \begin_layout LyX-Code
2946 read_fasta --data_in=test.fna | analyze_seq | sum_vals --keys=RES:N
2947 \end_layout
2948
2949 \begin_layout Standard
2950 The MIX_INDEX key is calculated as the count of the most common residue
2951  over the sequence length, and can be used as a cut-off for removing sequence
2952  tags consisting of mostly one nucleotide:
2953 \end_layout
2954
2955 \begin_layout LyX-Code
2956 read_fasta --data_in=test.fna | analyze_seq | grab --eval='MIX_INDEX<0.85'
2957 \end_layout
2958
2959 \begin_layout Subsection
2960 How to extract subsequences?
2961 \begin_inset LatexCommand label
2962 name "sub:How-to-extract"
2963
2964 \end_inset
2965
2966
2967 \end_layout
2968
2969 \begin_layout Standard
2970 In order to extract a subsequence from a longer sequence use the biotool
2971  extract_seq, which will replace the sequence in the record with the subsequence
2972  (this behaviour should probably be modified to be dependant of a 
2973 \begin_inset ERT
2974 status collapsed
2975
2976 \begin_layout Standard
2977
2978 -
2979 \backslash
2980 /-
2981 \end_layout
2982
2983 \end_inset
2984
2985 replace or a 
2986 \begin_inset ERT
2987 status collapsed
2988
2989 \begin_layout Standard
2990
2991 -
2992 \backslash
2993 /-
2994 \end_layout
2995
2996 \end_inset
2997
2998 no_replace switch
2999 \begin_inset Note Note
3000 status collapsed
3001
3002 \begin_layout Standard
3003 also in split_seq
3004 \end_layout
3005
3006 \end_inset
3007
3008 ).
3009  So to extract the first 20 residues from all sequences do (first residue
3010  is designated 1): 
3011 \end_layout
3012
3013 \begin_layout LyX-Code
3014 ...
3015  | extract_seq --beg=1 --len=20
3016 \end_layout
3017
3018 \begin_layout Standard
3019 You can also specify a begin and end coordinate set:
3020 \end_layout
3021
3022 \begin_layout LyX-Code
3023 ...
3024  | extract_seq --beg=20 --end=40
3025 \end_layout
3026
3027 \begin_layout Standard
3028 If you want the subsequences from position 20 to the sequence end do:
3029 \end_layout
3030
3031 \begin_layout LyX-Code
3032 ...
3033  | extract_seq --beg=20
3034 \end_layout
3035
3036 \begin_layout Standard
3037 If you want to extract subsequences a given distance from the sequence end
3038  you can do this by reversing the sequence with the biotool 
3039 \series bold
3040 reverse_seq
3041 \series default
3042  
3043 \begin_inset LatexCommand eqref
3044 reference "sub:How-to-reverse-seq"
3045
3046 \end_inset
3047
3048 , followed by 
3049 \series bold
3050 extract_seq
3051 \series default
3052  to get the subsequence, and then 
3053 \series bold
3054 reverse_seq
3055 \series default
3056  again to get the subsequence back in the original orientation:
3057 \end_layout
3058
3059 \begin_layout LyX-Code
3060 read_fasta --data_in=test.fna | reverse_seq
3061 \end_layout
3062
3063 \begin_layout LyX-Code
3064 | extract_seq --beg=10 --len=10 | reverse_seq
3065 \end_layout
3066
3067 \begin_layout Subsection
3068 How to get genomic sequence?
3069 \begin_inset LatexCommand label
3070 name "sub:How-to-get-genomic-sequence"
3071
3072 \end_inset
3073
3074
3075 \end_layout
3076
3077 \begin_layout Standard
3078 The biotool 
3079 \series bold
3080 get_genomic_seq
3081 \series default
3082  can extract subsequences for a given genome specified with the 
3083 \begin_inset ERT
3084 status collapsed
3085
3086 \begin_layout Standard
3087
3088 -
3089 \backslash
3090 /-
3091 \end_layout
3092
3093 \end_inset
3094
3095 genome switch explicitly using the 
3096 \begin_inset ERT
3097 status collapsed
3098
3099 \begin_layout Standard
3100
3101 -
3102 \backslash
3103 /-
3104 \end_layout
3105
3106 \end_inset
3107
3108 beg and 
3109 \begin_inset ERT
3110 status collapsed
3111
3112 \begin_layout Standard
3113
3114 -
3115 \backslash
3116 /-
3117 \end_layout
3118
3119 \end_inset
3120
3121 end/
3122 \begin_inset ERT
3123 status collapsed
3124
3125 \begin_layout Standard
3126
3127 -
3128 \backslash
3129 /-
3130 \end_layout
3131
3132 \end_inset
3133
3134 len switches:
3135 \end_layout
3136
3137 \begin_layout LyX-Code
3138 get_genome_seq --genome=<genome> --beg=1 --len=100
3139 \end_layout
3140
3141 \begin_layout Standard
3142 Alternatively, 
3143 \series bold
3144 get_genome_seq
3145 \series default
3146  can be used to append the corresponding sequence to BED, PSL, and BLAST
3147  records:
3148 \end_layout
3149
3150 \begin_layout LyX-Code
3151 read_bed --data_in=<BED file> | get_genome_seq --genome=<genome>
3152 \end_layout
3153
3154 \begin_layout Standard
3155 It is also possible to include flaking sequence using the 
3156 \begin_inset ERT
3157 status collapsed
3158
3159 \begin_layout Standard
3160
3161 -
3162 \backslash
3163 /-
3164 \end_layout
3165
3166 \end_inset
3167
3168 flank switch.
3169  So to include 50 nucleotides upstream and 50 nucleotides downstream for
3170  each BED entry do:
3171 \end_layout
3172
3173 \begin_layout LyX-Code
3174 read_bed --data_in=<BED file> | get_genome_seq --genome=<genome> --flank=50
3175 \end_layout
3176
3177 \begin_layout Subsection
3178 How to upper-case sequences?
3179 \end_layout
3180
3181 \begin_layout Standard
3182 Sequences can be shifted from lower case to upper case using 
3183 \series bold
3184 uppercase_seq
3185 \series default
3186 :
3187 \end_layout
3188
3189 \begin_layout LyX-Code
3190 ...
3191  | uppercase_seq
3192 \end_layout
3193
3194 \begin_layout Subsection
3195 How to reverse sequences?
3196 \begin_inset LatexCommand label
3197 name "sub:How-to-reverse-seq"
3198
3199 \end_inset
3200
3201
3202 \end_layout
3203
3204 \begin_layout Standard
3205 The order of residues in a sequence can be reversed using reverse_seq:
3206 \end_layout
3207
3208 \begin_layout LyX-Code
3209 ...
3210  | reverse_seq
3211 \end_layout
3212
3213 \begin_layout Standard
3214 Note that in order to reverse/complement a sequence you also need the 
3215 \series bold
3216 complement_seq
3217 \series default
3218  biotool (see\InsetSpace ~
3219
3220 \begin_inset LatexCommand ref
3221 reference "sub:How-to-complement"
3222
3223 \end_inset
3224
3225 ).
3226 \end_layout
3227
3228 \begin_layout Subsection
3229 How to complement sequences?
3230 \begin_inset LatexCommand label
3231 name "sub:How-to-complement"
3232
3233 \end_inset
3234
3235
3236 \end_layout
3237
3238 \begin_layout Standard
3239 DNA and RNA sequences can be complemented with 
3240 \series bold
3241 complement_seq
3242 \series default
3243 , which automagically determines the sequence type:
3244 \end_layout
3245
3246 \begin_layout LyX-Code
3247 ...
3248  | complement_seq
3249 \end_layout
3250
3251 \begin_layout Standard
3252 Note that in order to reverse/complement a sequence you also need the 
3253 \series bold
3254 reverse_seq
3255 \series default
3256  biotool (see\InsetSpace ~
3257
3258 \begin_inset LatexCommand ref
3259 reference "sub:How-to-reverse-seq"
3260
3261 \end_inset
3262
3263 ).
3264 \end_layout
3265
3266 \begin_layout Subsection
3267 How to remove indels from sequnces?
3268 \end_layout
3269
3270 \begin_layout Standard
3271 Indels can be removed from sequences with the 
3272 \series bold
3273 remove_indels
3274 \series default
3275  biotool.
3276  This is useful if you have aligned some sequences (see\InsetSpace ~
3277
3278 \begin_inset LatexCommand ref
3279 reference "sub:How-to-align"
3280
3281 \end_inset
3282
3283 ) and extracted (see\InsetSpace ~
3284
3285 \begin_inset LatexCommand ref
3286 reference "sub:How-to-extract"
3287
3288 \end_inset
3289
3290 ) a block of subsequences from the alignment and you want to use these sequence
3291  in a search where you need to remove the indels first.
3292  '-', '~', and '.' are considered indels:
3293 \end_layout
3294
3295 \begin_layout LyX-Code
3296 ...
3297  | remove_indels
3298 \end_layout
3299
3300 \begin_layout Subsection
3301 How to shuffle sequences?
3302 \end_layout
3303
3304 \begin_layout Standard
3305 All residues in sequences in the stream can be shuffled to random positions
3306  using the 
3307 \series bold
3308 shuffle_seq
3309 \series default
3310  biotool:
3311 \end_layout
3312
3313 \begin_layout LyX-Code
3314 ...
3315  | shuffle_seq
3316 \end_layout
3317
3318 \begin_layout Subsection
3319 How to split sequences into overlapping subsequences?
3320 \end_layout
3321
3322 \begin_layout Standard
3323 Sequences can be slit into overlapping subsequences with the 
3324 \series bold
3325 split_seq
3326 \series default
3327  biotool.
3328 \end_layout
3329
3330 \begin_layout LyX-Code
3331 ...
3332  | split_seq --word_size=20 --uniq
3333 \end_layout
3334
3335 \begin_layout Subsection
3336 How to determine the oligo frequency?
3337 \end_layout
3338
3339 \begin_layout Standard
3340 In order to determine if any oligo usage is over represented in one or more
3341  sequences you can determine the frequency of oligos of a given size with
3342  
3343 \series bold
3344 oligo_freq
3345 \series default
3346 :
3347 \end_layout
3348
3349 \begin_layout LyX-Code
3350 ...
3351  | oligo_freq --word_size=4
3352 \end_layout
3353
3354 \begin_layout Standard
3355 And if you have more than one sequence and want to accumulate the frequences
3356  you need the 
3357 \begin_inset ERT
3358 status collapsed
3359
3360 \begin_layout Standard
3361
3362 -
3363 \backslash
3364 /-
3365 \end_layout
3366
3367 \end_inset
3368
3369 all switch:
3370 \end_layout
3371
3372 \begin_layout LyX-Code
3373 ...
3374  | oligo_freq --word_size=4 --all
3375 \end_layout
3376
3377 \begin_layout Standard
3378 To get a meaningful result you need to write the resulting frequencies as
3379  a table with 
3380 \series bold
3381 write_tab
3382 \series default
3383  (see\InsetSpace ~
3384
3385 \begin_inset LatexCommand ref
3386 reference "sub:How-to-write-tab"
3387
3388 \end_inset
3389
3390 ), but first it is important to 
3391 \series bold
3392 grab
3393 \series default
3394  (see\InsetSpace ~
3395
3396 \begin_inset LatexCommand ref
3397 reference "sub:How-to-grab"
3398
3399 \end_inset
3400
3401 ) the records with the frequencies to avoid full length sequences in the
3402  table:
3403 \end_layout
3404
3405 \begin_layout LyX-Code
3406 ...
3407  | oligo_freq --word_size=4 --all | grab --pattern=OLIGO --keys_only
3408 \end_layout
3409
3410 \begin_layout LyX-Code
3411 | write_tab --no_stream
3412 \end_layout
3413
3414 \begin_layout Standard
3415 And the resulting frequency table can be sorted with Unix sort (man sort).
3416 \end_layout
3417
3418 \begin_layout Subsection
3419 How to search for sequences in genomes?
3420 \end_layout
3421
3422 \begin_layout Standard
3423 See the following biotool:
3424 \end_layout
3425
3426 \begin_layout Itemize
3427
3428 \series bold
3429 patscan_seq
3430 \series default
3431  
3432 \begin_inset LatexCommand eqref
3433 reference "sub:How-to-use-patscan"
3434
3435 \end_inset
3436
3437
3438 \end_layout
3439
3440 \begin_layout Itemize
3441
3442 \series bold
3443 blat_seq
3444 \series default
3445  
3446 \begin_inset LatexCommand eqref
3447 reference "sub:How-to-use-BLAT"
3448
3449 \end_inset
3450
3451
3452 \end_layout
3453
3454 \begin_layout Itemize
3455
3456 \series bold
3457 blast_seq
3458 \series default
3459  
3460 \begin_inset LatexCommand eqref
3461 reference "sub:How-to-use-BLAST"
3462
3463 \end_inset
3464
3465
3466 \end_layout
3467
3468 \begin_layout Itemize
3469
3470 \series bold
3471 vmatch_seq
3472 \series default
3473  
3474 \begin_inset LatexCommand eqref
3475 reference "sub:How-to-use-Vmatch"
3476
3477 \end_inset
3478
3479
3480 \end_layout
3481
3482 \begin_layout Subsection
3483 How to search sequences for a pattern?
3484 \begin_inset LatexCommand label
3485 name "sub:How-to-use-patscan"
3486
3487 \end_inset
3488
3489
3490 \end_layout
3491
3492 \begin_layout Standard
3493 It is possible to search sequences in the data stream for patterns using
3494  the 
3495 \series bold
3496 patscan_seq
3497 \series default
3498  biotool which utilizes the powerful scan_for_matches engine.
3499  Consult the documentation for scan_for_matches in order to learn how to
3500  define patterns (the documentation is included in Appendix\InsetSpace ~
3501
3502 \begin_inset LatexCommand ref
3503 reference "sec:scan_for_matches-README"
3504
3505 \end_inset
3506
3507 ).
3508 \end_layout
3509
3510 \begin_layout Standard
3511 To search all sequences for a simple pattern consisting of the sequence
3512  ATCGATCG allowing for 3 mismatches, 2 insertions and 1 deletion:
3513 \end_layout
3514
3515 \begin_layout LyX-Code
3516 read_fasta --data_in=<file> | patscan_seq --pattern='ATCGATCG[3,2,1]'
3517 \end_layout
3518
3519 \begin_layout Standard
3520 The 
3521 \begin_inset ERT
3522 status collapsed
3523
3524 \begin_layout Standard
3525
3526 -
3527 \backslash
3528 /-
3529 \end_layout
3530
3531 \end_inset
3532
3533 pattern switch takes a comma seperated list of patterns, so if you want
3534  to search for more that one pattern do:
3535 \end_layout
3536
3537 \begin_layout LyX-Code
3538 ...
3539  | patscan_seq --pattern='ATCGATCG[3,2,1],GCTAGCTA[3,2,1]'
3540 \end_layout
3541
3542 \begin_layout Standard
3543 It is also possible to have a list of different patterns to search for in
3544  a file with one pattern per line.
3545  In order to get 
3546 \series bold
3547 patscan_seq
3548 \series default
3549  to read these patterns use the 
3550 \begin_inset ERT
3551 status collapsed
3552
3553 \begin_layout Standard
3554
3555 -
3556 \backslash
3557 /-
3558 \end_layout
3559
3560 \end_inset
3561
3562 pattern_in switch:
3563 \end_layout
3564
3565 \begin_layout LyX-Code
3566 ...
3567  | patscan_seq --pattern_in=<file>
3568 \end_layout
3569
3570 \begin_layout Standard
3571 To also scan the complementary strand in nucleotide sequences (
3572 \series bold
3573 patscan_seq
3574 \series default
3575  automagically determines the sequence type) you need to add the 
3576 \begin_inset ERT
3577 status collapsed
3578
3579 \begin_layout Standard
3580
3581 -
3582 \backslash
3583 /-
3584 \end_layout
3585
3586 \end_inset
3587
3588 comp switch:
3589 \end_layout
3590
3591 \begin_layout LyX-Code
3592 ...
3593  | patscan_seq --pattern=<pattern> --comp
3594 \end_layout
3595
3596 \begin_layout Standard
3597 It is also possible to use 
3598 \series bold
3599 patscan_seq
3600 \series default
3601  to output those records that does not contain a certain pattern by using
3602  the 
3603 \begin_inset ERT
3604 status collapsed
3605
3606 \begin_layout Standard
3607
3608 -
3609 \backslash
3610 /-
3611 \end_layout
3612
3613 \end_inset
3614
3615 invert switch:
3616 \end_layout
3617
3618 \begin_layout LyX-Code
3619 ...
3620  | patscan_seq --pattern=<pattern> --invert
3621 \end_layout
3622
3623 \begin_layout Standard
3624 Finally, 
3625 \series bold
3626 patscan_seq
3627 \series default
3628  can also scan for patterns in a given genome sequence, instead of sequences
3629  in the stream, using the 
3630 \begin_inset ERT
3631 status open
3632
3633 \begin_layout Standard
3634
3635 -
3636 \backslash
3637 /-
3638 \end_layout
3639
3640 \end_inset
3641
3642 genome switch:
3643 \end_layout
3644
3645 \begin_layout LyX-Code
3646 patscan --pattern=<pattern> --genome=<genome>
3647 \end_layout
3648
3649 \begin_layout Subsection
3650 How to use BLAT for sequence search?
3651 \begin_inset LatexCommand label
3652 name "sub:How-to-use-BLAT"
3653
3654 \end_inset
3655
3656
3657 \end_layout
3658
3659 \begin_layout Standard
3660 Sequences in the data stream can be matched against supported genomes using
3661  
3662 \series bold
3663 blat_seq
3664 \series default
3665  which is a biotool using BLAT as the name might suggest.
3666  Currently only Mouse and Human genomes are available and it is not possible
3667  to use OOC files since there is still a need for a local repository for
3668  genome files.
3669  Otherwise it is just:
3670 \end_layout
3671
3672 \begin_layout LyX-Code
3673 read_fasta --data_in=<file> | blat_seq --genome=<genome>
3674 \end_layout
3675
3676 \begin_layout Standard
3677 The search results can then be written to file with 
3678 \series bold
3679 write_psl
3680 \series default
3681  (see\InsetSpace ~
3682
3683 \begin_inset LatexCommand ref
3684 reference "sub:How-to-write-PSL"
3685
3686 \end_inset
3687
3688 ) or 
3689 \series bold
3690 write_bed
3691 \series default
3692  (see\InsetSpace ~
3693
3694 \begin_inset LatexCommand ref
3695 reference "sub:How-to-write-BED"
3696
3697 \end_inset
3698
3699 ) allthough with 
3700 \series bold
3701 write_bed
3702 \series default
3703  some information will be lost).
3704  It is also possible to plot chromosome distribution of the search results
3705  using 
3706 \series bold
3707 plot_chrdist
3708 \series default
3709  (see\InsetSpace ~
3710
3711 \begin_inset LatexCommand ref
3712 reference "sub:How-to-plot-chrdist"
3713
3714 \end_inset
3715
3716 ) or the distribution of the match lengths using 
3717 \series bold
3718 plot_lendist
3719 \series default
3720  (see\InsetSpace ~
3721
3722 \begin_inset LatexCommand ref
3723 reference "sub:How-to-plot-lendist"
3724
3725 \end_inset
3726
3727 ) or a karyogram with the hits using 
3728 \series bold
3729 plot_karyogram
3730 \series default
3731  (see\InsetSpace ~
3732
3733 \begin_inset LatexCommand ref
3734 reference "sub:How-to-plot-karyogram"
3735
3736 \end_inset
3737
3738 ).
3739 \end_layout
3740
3741 \begin_layout Subsection
3742 How to use BLAST for sequence search?
3743 \begin_inset LatexCommand label
3744 name "sub:How-to-use-BLAST"
3745
3746 \end_inset
3747
3748
3749 \end_layout
3750
3751 \begin_layout Standard
3752 Two biotools exist for blasting sequences: 
3753 \series bold
3754 create_blast_db
3755 \series default
3756  is used to create the BLAST database required for BLAST which is queried
3757  using the biotool 
3758 \series bold
3759 blast_seq
3760 \series default
3761 .
3762  So in order to create a BLAST database from sequences in the data stream
3763  you simple run:
3764 \end_layout
3765
3766 \begin_layout LyX-Code
3767 ...
3768  | create_blast_db --database=my_database --no_stream
3769 \end_layout
3770
3771 \begin_layout Standard
3772 The type of sequence to use for the database is automagically determined
3773  by 
3774 \series bold
3775 create_blast_db
3776 \series default
3777 , but don't have a mixture of peptide and nucleic acids sequences in the
3778  stream.
3779  The 
3780 \begin_inset ERT
3781 status collapsed
3782
3783 \begin_layout Standard
3784
3785 -
3786 \backslash
3787 /-
3788 \end_layout
3789
3790 \end_inset
3791
3792 database switch takes a path as argument, but will default to 'blastdb_<time_sta
3793 mp> if not set.
3794 \end_layout
3795
3796 \begin_layout Standard
3797 The resulting database can now be queried with sequences in another data
3798  stream using 
3799 \series bold
3800 blast_seq
3801 \series default
3802 :
3803 \end_layout
3804
3805 \begin_layout LyX-Code
3806 ...
3807  | blast_seq --database=my_database
3808 \end_layout
3809
3810 \begin_layout Standard
3811 Again, the sequence type is determined automagically and the appropriate
3812  BLAST program is guessed (see below table), however, the program name can
3813  be overruled with the 
3814 \begin_inset ERT
3815 status collapsed
3816
3817 \begin_layout Standard
3818
3819 -
3820 \backslash
3821 /-
3822 \end_layout
3823
3824 \end_inset
3825
3826 program switch.
3827 \end_layout
3828
3829 \begin_layout Standard
3830 \noindent
3831 \align center
3832 \begin_inset Tabular
3833 <lyxtabular version="3" rows="5" columns="3">
3834 <features>
3835 <column alignment="center" valignment="top" width="0">
3836 <column alignment="center" valignment="top" width="0">
3837 <column alignment="center" valignment="top" width="0">
3838 <row bottomline="true">
3839 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3840 \begin_inset Text
3841
3842 \begin_layout Standard
3843 Subject sequence
3844 \end_layout
3845
3846 \end_inset
3847 </cell>
3848 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3849 \begin_inset Text
3850
3851 \begin_layout Standard
3852 Query sequence
3853 \end_layout
3854
3855 \end_inset
3856 </cell>
3857 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3858 \begin_inset Text
3859
3860 \begin_layout Standard
3861 Program guess
3862 \end_layout
3863
3864 \end_inset
3865 </cell>
3866 </row>
3867 <row>
3868 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3869 \begin_inset Text
3870
3871 \begin_layout Standard
3872 Nucleotide
3873 \end_layout
3874
3875 \end_inset
3876 </cell>
3877 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3878 \begin_inset Text
3879
3880 \begin_layout Standard
3881 Nucleotide
3882 \end_layout
3883
3884 \end_inset
3885 </cell>
3886 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3887 \begin_inset Text
3888
3889 \begin_layout Standard
3890 blastn
3891 \end_layout
3892
3893 \end_inset
3894 </cell>
3895 </row>
3896 <row>
3897 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3898 \begin_inset Text
3899
3900 \begin_layout Standard
3901 Protein
3902 \end_layout
3903
3904 \end_inset
3905 </cell>
3906 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3907 \begin_inset Text
3908
3909 \begin_layout Standard
3910 Protein
3911 \end_layout
3912
3913 \end_inset
3914 </cell>
3915 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3916 \begin_inset Text
3917
3918 \begin_layout Standard
3919 blastp
3920 \end_layout
3921
3922 \end_inset
3923 </cell>
3924 </row>
3925 <row>
3926 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3927 \begin_inset Text
3928
3929 \begin_layout Standard
3930 Protein
3931 \end_layout
3932
3933 \end_inset
3934 </cell>
3935 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3936 \begin_inset Text
3937
3938 \begin_layout Standard
3939 Nucleotide
3940 \end_layout
3941
3942 \end_inset
3943 </cell>
3944 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3945 \begin_inset Text
3946
3947 \begin_layout Standard
3948 blastx
3949 \end_layout
3950
3951 \end_inset
3952 </cell>
3953 </row>
3954 <row>
3955 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3956 \begin_inset Text
3957
3958 \begin_layout Standard
3959 Nucleotide
3960 \end_layout
3961
3962 \end_inset
3963 </cell>
3964 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3965 \begin_inset Text
3966
3967 \begin_layout Standard
3968 Protein
3969 \end_layout
3970
3971 \end_inset
3972 </cell>
3973 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3974 \begin_inset Text
3975
3976 \begin_layout Standard
3977 tblastn
3978 \end_layout
3979
3980 \end_inset
3981 </cell>
3982 </row>
3983 </lyxtabular>
3984
3985 \end_inset
3986
3987
3988 \end_layout
3989
3990 \begin_layout Standard
3991 Finally, it is also possible to use 
3992 \series bold
3993 blast_seq
3994 \series default
3995  for blasting sequences agains a preformatted genome using the 
3996 \begin_inset ERT
3997 status collapsed
3998
3999 \begin_layout Standard
4000
4001 -
4002 \backslash
4003 /-
4004 \end_layout
4005
4006 \end_inset
4007
4008 genome switch instead of the 
4009 \begin_inset ERT
4010 status collapsed
4011
4012 \begin_layout Standard
4013
4014 -
4015 \backslash
4016 /-
4017 \end_layout
4018
4019 \end_inset
4020
4021 database switch:
4022 \end_layout
4023
4024 \begin_layout LyX-Code
4025 ...
4026  | blast_seq --genome=<genome>
4027 \end_layout
4028
4029 \begin_layout Subsection
4030 How to use Vmatch for sequence search?
4031 \begin_inset LatexCommand label
4032 name "sub:How-to-use-Vmatch"
4033
4034 \end_inset
4035
4036
4037 \end_layout
4038
4039 \begin_layout Standard
4040 The powerful suffix array software package Vmatch
4041 \begin_inset Foot
4042 status collapsed
4043
4044 \begin_layout Standard
4045 \begin_inset LatexCommand url
4046 target "http://www.vmatch.de/"
4047
4048 \end_inset
4049
4050
4051 \end_layout
4052
4053 \end_inset
4054
4055  can be used for exact mapping of sequences against indexed genomes using
4056  the biotool 
4057 \series bold
4058 vmatch_seq
4059 \series default
4060 , which will e.g.
4061  map 700000 ESTs to the human genome locating all 160 mio hits in less than
4062  an hour.
4063  Only nucleotide sequences and sequences longer than 11 nucleotides will
4064  be mapped.
4065  It is recommended that sequences consisting of mostly one nucleotide type
4066  are removed.
4067  This can be done with the 
4068 \series bold
4069 analyze_seq
4070 \series default
4071  biotool 
4072 \begin_inset LatexCommand eqref
4073 reference "sub:How-to-analyze"
4074
4075 \end_inset
4076
4077 .
4078 \end_layout
4079
4080 \begin_layout LyX-Code
4081 ...
4082  | vmatch_seq --genome=<genome>
4083 \end_layout
4084
4085 \begin_layout Standard
4086 It is also possible to allow for mismatches using the 
4087 \begin_inset ERT
4088 status collapsed
4089
4090 \begin_layout Standard
4091
4092 -
4093 \backslash
4094 /-
4095 \end_layout
4096
4097 \end_inset
4098
4099 hamming_dist switch.
4100  So to allow for 2 mismatches:
4101 \end_layout
4102
4103 \begin_layout LyX-Code
4104 ...
4105  | vmatch_seq --genome=<genome> --hamming_dist=2
4106 \end_layout
4107
4108 \begin_layout Standard
4109 Or to allow for 10% mismathing nucleotides:
4110 \end_layout
4111
4112 \begin_layout LyX-Code
4113 ...
4114  | vmatch_seq --genome=<genome> --hamming_dist=10p
4115 \end_layout
4116
4117 \begin_layout Standard
4118 To allow both indels and mismatches use the 
4119 \begin_inset ERT
4120 status collapsed
4121
4122 \begin_layout Standard
4123
4124 -
4125 \backslash
4126 /-
4127 \end_layout
4128
4129 \end_inset
4130
4131 edit_dist switch.
4132  So to allow for one mismatch or one indel:
4133 \end_layout
4134
4135 \begin_layout LyX-Code
4136 ...
4137  | vmatch_seq --genome=<genome> --hamming_dist=1
4138 \end_layout
4139
4140 \begin_layout Standard
4141 Or to allow for 5% indels or mismatches:
4142 \end_layout
4143
4144 \begin_layout LyX-Code
4145 ...
4146  | vmatch_seq --genome=<genome> --hamming_dist=5p
4147 \end_layout
4148
4149 \begin_layout Standard
4150 Note that using 
4151 \begin_inset ERT
4152 status collapsed
4153
4154 \begin_layout Standard
4155
4156 -
4157 \backslash
4158 /-
4159 \end_layout
4160
4161 \end_inset
4162
4163 hamming_dist or
4164 \begin_inset ERT
4165 status collapsed
4166
4167 \begin_layout Standard
4168
4169 -
4170 \backslash
4171 /-
4172 \end_layout
4173
4174 \end_inset
4175
4176 edit_dist greatly slows down vmatch considerably --- use with care.
4177 \end_layout
4178
4179 \begin_layout Standard
4180 The resulting SCORE key can be replaced to hold the number of genome matches
4181  of a given sequence (multi-mappers) is the 
4182 \begin_inset ERT
4183 status collapsed
4184
4185 \begin_layout Standard
4186
4187 -
4188 \backslash
4189 /-
4190 \end_layout
4191
4192 \end_inset
4193
4194 count switch is given.
4195 \end_layout
4196
4197 \begin_layout Subsection
4198 How to find all matches between sequences?
4199 \begin_inset LatexCommand label
4200 name "sub:How-to-find-matches"
4201
4202 \end_inset
4203
4204
4205 \end_layout
4206
4207 \begin_layout Standard
4208 All matches between two sequences can be determined with the biotool 
4209 \series bold
4210 match_seq
4211 \series default
4212 .
4213  The match finding engine underneath the hood of 
4214 \series bold
4215 match_seq
4216 \series default
4217  is the super fast suffix tree program MUMmer
4218 \begin_inset Foot
4219 status collapsed
4220
4221 \begin_layout Standard
4222 \begin_inset LatexCommand url
4223 target "http://mummer.sourceforge.net/"
4224
4225 \end_inset
4226
4227
4228 \end_layout
4229
4230 \end_inset
4231
4232 , which will locate all forward and reverse matches between huge sequences
4233  in a matter of minutes (if the repeat count is not too high and if the
4234  word size used is appropriate).
4235  Matching two 
4236 \emph on
4237 Helicobacter pylori
4238 \emph default
4239  genomes (1.7Mbp) takes around 10 seconds:
4240 \end_layout
4241
4242 \begin_layout LyX-Code
4243 ...
4244  | match_seq --word_size=20 --direction=both
4245 \end_layout
4246
4247 \begin_layout Standard
4248 The output from 
4249 \series bold
4250 match_seq
4251 \series default
4252  can be used to generate a dot plot with 
4253 \series bold
4254 plot_matches
4255 \series default
4256  (see\InsetSpace ~
4257
4258 \begin_inset LatexCommand ref
4259 reference "sub:How-to-generate-dotplot"
4260
4261 \end_inset
4262
4263 ).
4264 \end_layout
4265
4266 \begin_layout Subsection
4267 How to align sequences?
4268 \begin_inset LatexCommand label
4269 name "sub:How-to-align"
4270
4271 \end_inset
4272
4273
4274 \end_layout
4275
4276 \begin_layout Standard
4277 Sequences in the stream can be aligned with the 
4278 \series bold
4279 align_seq
4280 \series default
4281  biotool that uses Muscle
4282 \begin_inset Foot
4283 status open
4284
4285 \begin_layout Standard
4286 \begin_inset LatexCommand url
4287 target "http://www.drive5.com/muscle/muscle.html"
4288
4289 \end_inset
4290
4291
4292 \end_layout
4293
4294 \end_inset
4295
4296  as aligment engine.
4297  Currently you cannot change any of the Muscle alignment parameters and
4298  
4299 \series bold
4300 align_seq
4301 \series default
4302  will create an alignment based on the defaults (which are really good!):
4303 \end_layout
4304
4305 \begin_layout LyX-Code
4306 ...
4307  | align_seq
4308 \end_layout
4309
4310 \begin_layout Standard
4311 The aligned output can be written to file in FASTA format using 
4312 \series bold
4313 write_fasta
4314 \series default
4315  (see\InsetSpace ~
4316
4317 \begin_inset LatexCommand ref
4318 reference "sub:How-to-write-fasta"
4319
4320 \end_inset
4321
4322 ) or in pretty text using 
4323 \series bold
4324 write_align
4325 \series default
4326  (see\InsetSpace ~
4327
4328 \begin_inset LatexCommand ref
4329 reference "sub:How-to-write-alignment"
4330
4331 \end_inset
4332
4333 ).
4334 \end_layout
4335
4336 \begin_layout Subsection
4337 How to create a weight matrix?
4338 \end_layout
4339
4340 \begin_layout Standard
4341 If you want a weight matrix to show the sequence composition of a stack
4342  of sequences you can use the biotool create_weight_matrix:
4343 \end_layout
4344
4345 \begin_layout LyX-Code
4346 ...
4347  | create_weight_matrix
4348 \end_layout
4349
4350 \begin_layout Standard
4351 The result can be output in percent using the 
4352 \begin_inset ERT
4353 status open
4354
4355 \begin_layout Standard
4356
4357 -
4358 \backslash
4359 /-
4360 \end_layout
4361
4362 \end_inset
4363
4364 percent switch:
4365 \end_layout
4366
4367 \begin_layout LyX-Code
4368 ...
4369  | create_weight_matrix --percent
4370 \end_layout
4371
4372 \begin_layout Standard
4373 The weight matrix can be written as tabular output with 
4374 \series bold
4375 write_tab
4376 \series default
4377  (see\InsetSpace ~
4378
4379 \begin_inset LatexCommand ref
4380 reference "sub:How-to-write-tab"
4381
4382 \end_inset
4383
4384 ) after removeing the records containing SEQ with 
4385 \series bold
4386 grab
4387 \series default
4388  (see\InsetSpace ~
4389
4390 \begin_inset LatexCommand ref
4391 reference "sub:How-to-grab"
4392
4393 \end_inset
4394
4395 ):
4396 \end_layout
4397
4398 \begin_layout LyX-Code
4399 ...
4400  | create_weight_matrix | grab --invert --keys=SEQ --keys_only
4401 \end_layout
4402
4403 \begin_layout LyX-Code
4404 | write_tab --no_stream
4405 \end_layout
4406
4407 \begin_layout Standard
4408 The V0 column will hold the residue, while the rest of the columns will
4409  hold the frequencies for each sequence position.
4410 \end_layout
4411
4412 \begin_layout Section
4413 Plotting
4414 \end_layout
4415
4416 \begin_layout Standard
4417 There exists several biotools for plotting.
4418  Some of these are based on GNUplot
4419 \begin_inset Foot
4420 status open
4421
4422 \begin_layout Standard
4423 \begin_inset LatexCommand url
4424 target "http://www.gnuplot.info/"
4425
4426 \end_inset
4427
4428
4429 \end_layout
4430
4431 \end_inset
4432
4433 , which is an extremely powerful platform to generate all sorts of plots
4434  and even though GNUplot has quite a steep learning curve, the biotools
4435  utilizing GNUplot are simple to use.
4436  GNUplot is able to output a lot of different formats (called terminals
4437  in GNUplot), but the biotools focusses on three formats only:
4438 \end_layout
4439
4440 \begin_layout Enumerate
4441 The 'dumb' terminal is default to the GNUplot based biotools and will output
4442  a plot in crude ASCII text (Fig.\InsetSpace ~
4443
4444 \begin_inset LatexCommand ref
4445 reference "fig:Dumb-terminal"
4446
4447 \end_inset
4448
4449 ).
4450  This is quite nice for a quick and dirty plot to get an overview of your
4451  data .
4452 \end_layout
4453
4454 \begin_layout Enumerate
4455 The 'post' or 'postscript' terminal output postscript code which is publication
4456  grade graphics that can be viewed with applications such as Ghostview,
4457  Photoshop, and Preview.
4458 \end_layout
4459
4460 \begin_layout Enumerate
4461 The 'svg' terminal output's scalable vector graphics (SVG) which is a vector
4462  based format.
4463  SVG is great because you can edit the resulting plot using Photoshop or
4464  Inkscape
4465 \begin_inset Foot
4466 status collapsed
4467
4468 \begin_layout Standard
4469 Inkscape is a really handy drawing program that is free and open source.
4470  Availble at 
4471 \begin_inset LatexCommand htmlurl
4472 target "http://www.inkscape.org"
4473
4474 \end_inset
4475
4476
4477 \end_layout
4478
4479 \end_inset
4480
4481  if you want to add additional labels, captions, arrows, and so on and then
4482  save the result in different formats, such as postscript without loosing
4483  resolution.
4484 \end_layout
4485
4486 \begin_layout Standard
4487 The biotools for plotting that are not based on GNUplot only output SVG
4488  (that may change in the future).
4489 \end_layout
4490
4491 \begin_layout Standard
4492 \begin_inset Float figure
4493 wide false
4494 sideways false
4495 status open
4496
4497 \begin_layout Standard
4498 \noindent
4499 \align center
4500 \begin_inset Graphics
4501         filename lendist_ascii.png
4502         lyxscale 70
4503         width 12cm
4504
4505 \end_inset
4506
4507
4508 \end_layout
4509
4510 \begin_layout Standard
4511 \begin_inset Caption
4512
4513 \begin_layout Standard
4514 \begin_inset LatexCommand label
4515 name "fig:Dumb-terminal"
4516
4517 \end_inset
4518
4519 Dumb terminal
4520 \end_layout
4521
4522 \end_inset
4523
4524
4525 \end_layout
4526
4527 \begin_layout Quote
4528 The output of a length distribution plot in the default 'dumb terminal'
4529  to the terminal window.
4530  
4531 \end_layout
4532
4533 \end_inset
4534
4535
4536 \end_layout
4537
4538 \begin_layout Subsection
4539 How to plot a histogram?
4540 \begin_inset LatexCommand label
4541 name "How-to-plot-histogram"
4542
4543 \end_inset
4544
4545
4546 \end_layout
4547
4548 \begin_layout Standard
4549 A generic histogram for a given value can be plotted with the biotool 
4550 \series bold
4551 plot_histogram
4552 \series default
4553  (Fig.\InsetSpace ~
4554
4555 \begin_inset LatexCommand ref
4556 reference "fig:Histogram"
4557
4558 \end_inset
4559
4560 ):
4561 \end_layout
4562
4563 \begin_layout LyX-Code
4564 ...
4565  | plot_histogram --key=TISSUE --no_stream
4566 \end_layout
4567
4568 \begin_layout Standard
4569 (Figure missing)
4570 \end_layout
4571
4572 \begin_layout Standard
4573 \noindent
4574 \align left
4575 \begin_inset Float figure
4576 wide false
4577 sideways false
4578 status open
4579
4580 \begin_layout Standard
4581 \noindent
4582 \align center
4583 \begin_inset Graphics
4584         filename histogram.png
4585         lyxscale 70
4586         width 12cm
4587
4588 \end_inset
4589
4590
4591 \end_layout
4592
4593 \begin_layout Standard
4594 \begin_inset Caption
4595
4596 \begin_layout Standard
4597 \begin_inset LatexCommand label
4598 name "fig:Histogram"
4599
4600 \end_inset
4601
4602 Histogram
4603 \end_layout
4604
4605 \end_inset
4606
4607
4608 \end_layout
4609
4610 \end_inset
4611
4612
4613 \end_layout
4614
4615 \begin_layout Subsection
4616 How to plot a length distribution?
4617 \begin_inset LatexCommand label
4618 name "sub:How-to-plot-lendist"
4619
4620 \end_inset
4621
4622
4623 \end_layout
4624
4625 \begin_layout Standard
4626 Plotting of length distributions, weather sequence lengths, patterns lengths,
4627  hit lengths, 
4628 \emph on
4629 etc.
4630
4631 \emph default
4632  is a really handy thing and can be done with the the biotool 
4633 \series bold
4634 plot_lendist
4635 \series default
4636 .
4637  If you have a file with FASTA entries and want to plot the length distribution
4638  you do it like this:
4639 \end_layout
4640
4641 \begin_layout LyX-Code
4642 read_fasta --data_in=<file> | length_seq
4643 \end_layout
4644
4645 \begin_layout LyX-Code
4646 | plot_lendist --key=SEQ_LEN --no_stream
4647 \end_layout
4648
4649 \begin_layout Standard
4650 The result will be written to the default dumb terminal and will look like
4651  Fig.\InsetSpace ~
4652
4653 \begin_inset LatexCommand ref
4654 reference "fig:Dumb-terminal"
4655
4656 \end_inset
4657
4658 .
4659 \end_layout
4660
4661 \begin_layout Standard
4662 If you instead want the result in postscript format you can do:
4663 \end_layout
4664
4665 \begin_layout LyX-Code
4666 ...
4667  | plot_lendist --key=SEQ_LEN --terminal=post --result_out=file.ps
4668 \end_layout
4669
4670 \begin_layout Standard
4671 That will generate the plot and save it to file, but not interrupt the data
4672  stream which can then be used in further analysis.
4673  You can also save the plot implicetly using '>', however, it is then important
4674  to terminate the stream with the 
4675 \begin_inset ERT
4676 status collapsed
4677
4678 \begin_layout Standard
4679
4680 -
4681 \backslash
4682 /-
4683 \end_layout
4684
4685 \end_inset
4686
4687 no_stream switch:
4688 \end_layout
4689
4690 \begin_layout LyX-Code
4691 ...
4692  | plot_lendist --key=SEQ_LEN --terminal=post --no_stream > file.ps
4693 \end_layout
4694
4695 \begin_layout Standard
4696 The resulting plot can be seen in Fig.\InsetSpace ~
4697
4698 \begin_inset LatexCommand ref
4699 reference "fig:Length-distribution"
4700
4701 \end_inset
4702
4703 .
4704 \end_layout
4705
4706 \begin_layout Standard
4707 \begin_inset Float figure
4708 wide false
4709 sideways false
4710 status open
4711
4712 \begin_layout Standard
4713
4714 \end_layout
4715
4716 \begin_layout Standard
4717 \noindent
4718 \align center
4719 \begin_inset Graphics
4720         filename lendist.ps
4721         lyxscale 50
4722         width 12cm
4723
4724 \end_inset
4725
4726
4727 \end_layout
4728
4729 \begin_layout Standard
4730 \begin_inset Caption
4731
4732 \begin_layout Standard
4733 \begin_inset LatexCommand label
4734 name "fig:Length-distribution"
4735
4736 \end_inset
4737
4738 Length distribution
4739 \end_layout
4740
4741 \end_inset
4742
4743
4744 \end_layout
4745
4746 \begin_layout Quote
4747 Length distribution of 630 piRNA like RNAs.
4748 \end_layout
4749
4750 \end_inset
4751
4752
4753 \end_layout
4754
4755 \begin_layout Subsection
4756 How to plot a chromosome distribution?
4757 \begin_inset LatexCommand label
4758 name "sub:How-to-plot-chrdist"
4759
4760 \end_inset
4761
4762
4763 \end_layout
4764
4765 \begin_layout Standard
4766 If you have the result of a sequence search against a multi chromosome genome,
4767  it is very practical to be able to plot the distribution of search hits
4768  on the different chromosomes.
4769  This can be done with 
4770 \series bold
4771 plot_chrdist
4772 \series default
4773 :
4774 \end_layout
4775
4776 \begin_layout LyX-Code
4777 read_fasta --data_in=<file> | blat_genome | plot_chrdist --no_stream
4778 \end_layout
4779
4780 \begin_layout Standard
4781 The above example will result in a crude plot using the 'dumb' terminal,
4782  and if you want to mess around with the results from the BLAT search you
4783  probably want to save the result to file first (see\InsetSpace ~
4784
4785 \begin_inset LatexCommand ref
4786 reference "sub:How-to-write-PSL"
4787
4788 \end_inset
4789
4790 ).
4791  To plot the chromosome distribution from the saved search result you can
4792  do:
4793 \end_layout
4794
4795 \begin_layout LyX-Code
4796 read_bed --data_in=file.bed | plot_chrdist --terminal=post --result_out=plot.ps
4797 \end_layout
4798
4799 \begin_layout Standard
4800 That will result in the output show in Fig.\InsetSpace ~
4801
4802 \begin_inset LatexCommand ref
4803 reference "fig:Chromosome-distribution"
4804
4805 \end_inset
4806
4807 .
4808 \end_layout
4809
4810 \begin_layout Standard
4811 \begin_inset Float figure
4812 wide false
4813 sideways false
4814 status open
4815
4816 \begin_layout Standard
4817
4818 \end_layout
4819
4820 \begin_layout Standard
4821 \noindent
4822 \align center
4823 \begin_inset Graphics
4824         filename chrdist.ps
4825         lyxscale 50
4826         width 12cm
4827         rotateAngle 90
4828
4829 \end_inset
4830
4831
4832 \end_layout
4833
4834 \begin_layout Standard
4835 \begin_inset Caption
4836
4837 \begin_layout Standard
4838 \begin_inset LatexCommand label
4839 name "fig:Chromosome-distribution"
4840
4841 \end_inset
4842
4843 Chromosome distribution
4844 \end_layout
4845
4846 \end_inset
4847
4848
4849 \end_layout
4850
4851 \end_inset
4852
4853
4854 \end_layout
4855
4856 \begin_layout Subsection
4857 How to generate a dotplot?
4858 \begin_inset LatexCommand label
4859 name "sub:How-to-generate-dotplot"
4860
4861 \end_inset
4862
4863
4864 \end_layout
4865
4866 \begin_layout Standard
4867 A dotplot is a powerful way to get an overview of the size and location
4868  of sequence insertions, deletions, and duplications between two sequences.
4869  Generating a dotplot with biotools is a two step process where you initially
4870  find all matches between two sequences using the tool 
4871 \series bold
4872 match_seq
4873 \series default
4874  (see\InsetSpace ~
4875
4876 \begin_inset LatexCommand ref
4877 reference "sub:How-to-find-matches"
4878
4879 \end_inset
4880
4881 ) and plot the resulting matches with 
4882 \series bold
4883 plot_matches
4884 \series default
4885 .
4886  Matching and plotting two 
4887 \emph on
4888 Helicobacter pylori
4889 \emph default
4890  genomes (1.7Mbp) takes around 10 seconds:
4891 \end_layout
4892
4893 \begin_layout LyX-Code
4894 ...
4895  | match_seq | plot_matches --terminal=post --result_out=plot.ps
4896 \end_layout
4897
4898 \begin_layout Standard
4899 The resulting dotplot is in Fig.\InsetSpace ~
4900
4901 \begin_inset LatexCommand ref
4902 reference "fig:Dotplot"
4903
4904 \end_inset
4905
4906 .
4907 \end_layout
4908
4909 \begin_layout Standard
4910 \begin_inset Float figure
4911 wide false
4912 sideways false
4913 status open
4914
4915 \begin_layout Standard
4916 \noindent
4917 \align center
4918 \begin_inset Graphics
4919         filename dotplot.ps
4920         lyxscale 50
4921         width 12cm
4922
4923 \end_inset
4924
4925
4926 \end_layout
4927
4928 \begin_layout Standard
4929 \begin_inset Caption
4930
4931 \begin_layout Standard
4932 \begin_inset LatexCommand label
4933 name "fig:Dotplot"
4934
4935 \end_inset
4936
4937 Dotplot
4938 \end_layout
4939
4940 \end_inset
4941
4942
4943 \end_layout
4944
4945 \begin_layout Quote
4946 Forward matches are displayed in green while reverse matches are displayed
4947  in red.
4948 \end_layout
4949
4950 \end_inset
4951
4952
4953 \end_layout
4954
4955 \begin_layout Subsection
4956 How to plot a sequence logo?
4957 \end_layout
4958
4959 \begin_layout Standard
4960 Sequence logos can be generate with 
4961 \series bold
4962 plot_seqlogo
4963 \series default
4964 .
4965  The sequnce type is determined automagically and an entropy scale of 2
4966  bits and 4 bits is used for nucleotide and peptide sequences, respectively
4967 \begin_inset Foot
4968 status collapsed
4969
4970 \begin_layout Standard
4971 \begin_inset LatexCommand htmlurl
4972 target "http://www.ccrnp.ncifcrf.gov/~toms/paper/hawaii/latex/node5.html"
4973
4974 \end_inset
4975
4976
4977 \end_layout
4978
4979 \end_inset
4980
4981 .
4982 \end_layout
4983
4984 \begin_layout LyX-Code
4985 ...
4986  | plot_seqlogo --no_stream --result_out=seqlogo.svg
4987 \end_layout
4988
4989 \begin_layout Standard
4990 An example of a sequence logo can be seen in Fig.\InsetSpace ~
4991
4992 \begin_inset LatexCommand ref
4993 reference "fig:Sequence-logo"
4994
4995 \end_inset
4996
4997 .
4998 \end_layout
4999
5000 \begin_layout Standard
5001 \begin_inset Float figure
5002 wide false
5003 sideways false
5004 status open
5005
5006 \begin_layout Standard
5007 \noindent
5008 \align center
5009 \begin_inset Graphics
5010         filename seqlogo.png
5011         lyxscale 50
5012         width 12cm
5013
5014 \end_inset
5015
5016
5017 \end_layout
5018
5019 \begin_layout Standard
5020 \begin_inset Caption
5021
5022 \begin_layout Standard
5023 \begin_inset LatexCommand label
5024 name "fig:Sequence-logo"
5025
5026 \end_inset
5027
5028 Sequence logo
5029 \end_layout
5030
5031 \end_inset
5032
5033
5034 \end_layout
5035
5036 \end_inset
5037
5038
5039 \end_layout
5040
5041 \begin_layout Subsection
5042 How to plot a karyogram?
5043 \begin_inset LatexCommand label
5044 name "sub:How-to-plot-karyogram"
5045
5046 \end_inset
5047
5048
5049 \end_layout
5050
5051 \begin_layout Standard
5052 To plot search hits on genomes use 
5053 \series bold
5054 plot_karyogram
5055 \series default
5056 , which will output a nice karyogram in SVG graphics:
5057 \end_layout
5058
5059 \begin_layout LyX-Code
5060 ...
5061  | plot_karyogram --result_out=karyogram.svg
5062 \end_layout
5063
5064 \begin_layout Standard
5065 The banding data is taken from the UCSC genome browser database and currently
5066  only Human and Mouse is supported.
5067  Fig.\InsetSpace ~
5068
5069 \begin_inset LatexCommand ref
5070 reference "fig:Karyogram"
5071
5072 \end_inset
5073
5074  shows the distribution of piRNA like RNAs matched to the Human genome.
5075 \end_layout
5076
5077 \begin_layout Standard
5078 \begin_inset Float figure
5079 wide false
5080 sideways false
5081 status open
5082
5083 \begin_layout Standard
5084 \noindent
5085 \align center
5086 \begin_inset Graphics
5087         filename karyogram.png
5088         lyxscale 35
5089         width 12cm
5090
5091 \end_inset
5092
5093
5094 \end_layout
5095
5096 \begin_layout Standard
5097 \begin_inset Caption
5098
5099 \begin_layout Standard
5100 \begin_inset LatexCommand label
5101 name "fig:Karyogram"
5102
5103 \end_inset
5104
5105 Karyogram
5106 \end_layout
5107
5108 \end_inset
5109
5110
5111 \end_layout
5112
5113 \begin_layout Quote
5114 Hits from a search of piRNA like RNAs in the Human genome is displayed as
5115  short horizontal bars.
5116 \end_layout
5117
5118 \end_inset
5119
5120
5121 \end_layout
5122
5123 \begin_layout Section
5124 Uploading Results
5125 \end_layout
5126
5127 \begin_layout Subsection
5128 How do I display my results in the UCSC Genome Browser?
5129 \end_layout
5130
5131 \begin_layout Standard
5132 Results from the list of biotools below can be uploaded directly to a local
5133  mirror of the UCSC Genome Browser using the biotool 
5134 \series bold
5135 upload_to_ucsc
5136 \series default
5137 :
5138 \end_layout
5139
5140 \begin_layout Itemize
5141 patscan_seq 
5142 \begin_inset LatexCommand eqref
5143 reference "sub:How-to-use-patscan"
5144
5145 \end_inset
5146
5147
5148 \end_layout
5149
5150 \begin_layout Itemize
5151 blat_seq 
5152 \begin_inset LatexCommand eqref
5153 reference "sub:How-to-use-BLAT"
5154
5155 \end_inset
5156
5157
5158 \end_layout
5159
5160 \begin_layout Itemize
5161 blast_seq 
5162 \begin_inset LatexCommand eqref
5163 reference "sub:How-to-use-BLAST"
5164
5165 \end_inset
5166
5167
5168 \end_layout
5169
5170 \begin_layout Itemize
5171 vmatch_seq 
5172 \begin_inset LatexCommand eqref
5173 reference "sub:How-to-use-Vmatch"
5174
5175 \end_inset
5176
5177
5178 \end_layout
5179
5180 \begin_layout Standard
5181 The syntax for uploading data the most simple way requires two mandatory
5182  switches: 
5183 \begin_inset ERT
5184 status collapsed
5185
5186 \begin_layout Standard
5187
5188 -
5189 \backslash
5190 /-
5191 \end_layout
5192
5193 \end_inset
5194
5195 database, which is the UCSC database name (such as hg18, mm9, etc.) and
5196 \begin_inset ERT
5197 status collapsed
5198
5199 \begin_layout Standard
5200
5201 -
5202 \backslash
5203 /-
5204 \end_layout
5205
5206 \end_inset
5207
5208 table which should be the users initials followed by an underscore and a
5209  short description of the data:
5210 \end_layout
5211
5212 \begin_layout LyX-Code
5213 ...
5214  | upload_to_ucsc --database=hg18 --table=mah_snoRNAs
5215 \end_layout
5216
5217 \begin_layout Standard
5218 The 
5219 \series bold
5220 upload_to_ucsc
5221 \series default
5222  biotool modifies the users ~/ucsc/my_tracks.ra file automagically (a backup
5223  is created with the name ~/ucsc/my_tracks.ra~) with default values that
5224  can be overridden using the following switches:
5225 \end_layout
5226
5227 \begin_layout Itemize
5228 \begin_inset ERT
5229 status collapsed
5230
5231 \begin_layout Standard
5232
5233 -
5234 \backslash
5235 /-
5236 \end_layout
5237
5238 \end_inset
5239
5240 short_label - Short label for track - Default=database->table
5241 \end_layout
5242
5243 \begin_layout Itemize
5244 \begin_inset ERT
5245 status collapsed
5246
5247 \begin_layout Standard
5248
5249 -
5250 \backslash
5251 /-
5252 \end_layout
5253
5254 \end_inset
5255
5256 long_label - Long label for track - Default=database->table
5257 \end_layout
5258
5259 \begin_layout Itemize
5260 \begin_inset ERT
5261 status collapsed
5262
5263 \begin_layout Standard
5264
5265 -
5266 \backslash
5267 /-
5268 \end_layout
5269
5270 \end_inset
5271
5272 group - Track group name - Default=<user name as defined in env>
5273 \end_layout
5274
5275 \begin_layout Itemize
5276 \begin_inset ERT
5277 status collapsed
5278
5279 \begin_layout Standard
5280
5281 -
5282 \backslash
5283 /-
5284 \end_layout
5285
5286 \end_inset
5287
5288 priority - Track display priority - Default=1
5289 \end_layout
5290
5291 \begin_layout Itemize
5292 \begin_inset ERT
5293 status collapsed
5294
5295 \begin_layout Standard
5296
5297 -
5298 \backslash
5299 /-
5300 \end_layout
5301
5302 \end_inset
5303
5304 color - Track color - Default=147,73,42
5305 \end_layout
5306
5307 \begin_layout Itemize
5308 \begin_inset ERT
5309 status collapsed
5310
5311 \begin_layout Standard
5312
5313 -
5314 \backslash
5315 /-
5316 \end_layout
5317
5318 \end_inset
5319
5320 chunk_size - Chunks for loading - Default=10000000
5321 \end_layout
5322
5323 \begin_layout Itemize
5324 \begin_inset ERT
5325 status collapsed
5326
5327 \begin_layout Standard
5328
5329 -
5330 \backslash
5331 /-
5332 \end_layout
5333
5334 \end_inset
5335
5336 visibility - Track visibility - Default=pack
5337 \end_layout
5338
5339 \begin_layout Standard
5340 Also, data in BED or PSL format can be uploaded with 
5341 \series bold
5342 upload_to_ucsc
5343 \series default
5344  as long as these reference to genomes and chromosomes existing in the UCSC
5345  Genome Browser:
5346 \end_layout
5347
5348 \begin_layout LyX-Code
5349 read_bed --data_in=<bed file> | upload_to_ucsc ...
5350 \end_layout
5351
5352 \begin_layout LyX-Code
5353
5354 \end_layout
5355
5356 \begin_layout LyX-Code
5357 read_psl --data_in=<psl file> | upload_to_ucsc ...
5358 \end_layout
5359
5360 \begin_layout Section
5361 Power Scripting
5362 \end_layout
5363
5364 \begin_layout Standard
5365 It is possible to do commandline scripting of biotool records using Perl.
5366  Because a biotool record essentially is a hash structure, you can pass
5367  records to 
5368 \series bold
5369 bioscript
5370 \series default
5371  command, which is a wrapper around the Perl executable that allows direct
5372  manipulations of the records using the power of Perl.
5373 \end_layout
5374
5375 \begin_layout Standard
5376 In the below example we replace in all records the value to the CHR key
5377  with a forthrunning number:
5378 \end_layout
5379
5380 \begin_layout LyX-Code
5381 ...
5382  | bioscript 'while($r=get_record(
5383 \backslash
5384 *STDIN)){$r->{CHR}=$i++; put_record($r)}'
5385 \end_layout
5386
5387 \begin_layout Standard
5388 Something more useful would probably be to create custom FASTA headers.
5389  E.g.
5390  if we read in a BED file, lookup the genomic sequence, create a custom
5391  FASTA header with 
5392 \series bold
5393 bioscript
5394 \series default
5395  and output FASTA entries:
5396 \end_layout
5397
5398 \begin_layout LyX-Code
5399 ...
5400  | bioscript 'while($r=get_record(
5401 \backslash
5402 *STDIN)){$r->{SEQ_NAME}= //
5403 \end_layout
5404
5405 \begin_layout LyX-Code
5406 join("_",$r->{CHR},$r->{CHR_BEG},$r->{CHR_END}); put_record($r)}'
5407 \end_layout
5408
5409 \begin_layout Standard
5410 And the output:
5411 \end_layout
5412
5413 \begin_layout LyX-Code
5414 >chr2L_21567527_21567550 
5415 \end_layout
5416
5417 \begin_layout LyX-Code
5418 taccaaacggatgcctcagacatc
5419 \end_layout
5420
5421 \begin_layout LyX-Code
5422 >chr2L_693380_693403 
5423 \end_layout
5424
5425 \begin_layout LyX-Code
5426 taccaaacggatgcctcagacatc 
5427 \end_layout
5428
5429 \begin_layout LyX-Code
5430 >chr2L_13859534_13859557 
5431 \end_layout
5432
5433 \begin_layout LyX-Code
5434 taccaaacggatgcctcagacatc 
5435 \end_layout
5436
5437 \begin_layout LyX-Code
5438 >chr2L_9005090_9005113 
5439 \end_layout
5440
5441 \begin_layout LyX-Code
5442 taccaaacggatgcctcagacatc 
5443 \end_layout
5444
5445 \begin_layout LyX-Code
5446 >chr2L_2106825_2106848 
5447 \end_layout
5448
5449 \begin_layout LyX-Code
5450 taccaaacggatgcctcagacatc 
5451 \end_layout
5452
5453 \begin_layout LyX-Code
5454 >chr2L_14649031_14649054 
5455 \end_layout
5456
5457 \begin_layout LyX-Code
5458 taccaaacggatgcctcagacatc
5459 \end_layout
5460
5461 \begin_layout Section
5462 Trouble shooting
5463 \end_layout
5464
5465 \begin_layout Standard
5466 Shoot the messenger!
5467 \end_layout
5468
5469 \begin_layout Section
5470 \start_of_appendix
5471 Keys
5472 \begin_inset LatexCommand label
5473 name "sec:Keys"
5474
5475 \end_inset
5476
5477
5478 \end_layout
5479
5480 \begin_layout Standard
5481 HIT
5482 \end_layout
5483
5484 \begin_layout Standard
5485 HIT_BEG
5486 \end_layout
5487
5488 \begin_layout Standard
5489 HIT_END
5490 \end_layout
5491
5492 \begin_layout Standard
5493 HIT_LEN
5494 \end_layout
5495
5496 \begin_layout Standard
5497 HIT_NAME
5498 \end_layout
5499
5500 \begin_layout Standard
5501 PATTERN
5502 \end_layout
5503
5504 \begin_layout Section
5505 Switches
5506 \begin_inset LatexCommand label
5507 name "sec:Switches"
5508
5509 \end_inset
5510
5511
5512 \end_layout
5513
5514 \begin_layout Standard
5515 \begin_inset ERT
5516 status collapsed
5517
5518 \begin_layout Standard
5519
5520 -
5521 \backslash
5522 /-
5523 \end_layout
5524
5525 \end_inset
5526
5527 stream_in
5528 \end_layout
5529
5530 \begin_layout Standard
5531 \begin_inset ERT
5532 status collapsed
5533
5534 \begin_layout Standard
5535
5536 -
5537 \backslash
5538 /-
5539 \end_layout
5540
5541 \end_inset
5542
5543 stream_out
5544 \end_layout
5545
5546 \begin_layout Standard
5547 \begin_inset ERT
5548 status collapsed
5549
5550 \begin_layout Standard
5551
5552 -
5553 \backslash
5554 /-
5555 \end_layout
5556
5557 \end_inset
5558
5559 no_stream
5560 \end_layout
5561
5562 \begin_layout Standard
5563 \begin_inset ERT
5564 status collapsed
5565
5566 \begin_layout Standard
5567
5568 -
5569 \backslash
5570 /-
5571 \end_layout
5572
5573 \end_inset
5574
5575 data_in
5576 \end_layout
5577
5578 \begin_layout Standard
5579 \begin_inset ERT
5580 status collapsed
5581
5582 \begin_layout Standard
5583
5584 -
5585 \backslash
5586 /-
5587 \end_layout
5588
5589 \end_inset
5590
5591 result_out
5592 \end_layout
5593
5594 \begin_layout Standard
5595 \begin_inset ERT
5596 status collapsed
5597
5598 \begin_layout Standard
5599
5600 -
5601 \backslash
5602 /-
5603 \end_layout
5604
5605 \end_inset
5606
5607 num
5608 \end_layout
5609
5610 \begin_layout Section
5611 scan_for_matches README
5612 \begin_inset LatexCommand label
5613 name "sec:scan_for_matches-README"
5614
5615 \end_inset
5616
5617
5618 \end_layout
5619
5620 \begin_layout LyX-Code
5621                           scan_for_matches:
5622 \end_layout
5623
5624 \begin_layout LyX-Code
5625     A Program to Scan Nucleotide or Protein Sequences for Matching Patterns
5626 \end_layout
5627
5628 \begin_layout LyX-Code
5629                         Ross Overbeek
5630 \end_layout
5631
5632 \begin_layout LyX-Code
5633                         MCS
5634 \end_layout
5635
5636 \begin_layout LyX-Code
5637                         Argonne National Laboratory
5638 \end_layout
5639
5640 \begin_layout LyX-Code
5641                         Argonne, IL 60439
5642 \end_layout
5643
5644 \begin_layout LyX-Code
5645                         USA
5646 \end_layout
5647
5648 \begin_layout LyX-Code
5649 Scan_for_matches is a utility that we have written to search for
5650 \end_layout
5651
5652 \begin_layout LyX-Code
5653 patterns in DNA and protein sequences.
5654   I wrote most of the code,
5655 \end_layout
5656
5657 \begin_layout LyX-Code
5658 although David Joerg and Morgan Price wrote sections of an
5659 \end_layout
5660
5661 \begin_layout LyX-Code
5662 earlier version.
5663   The whole notion of pattern matching has a rich
5664 \end_layout
5665
5666 \begin_layout LyX-Code
5667 history, and we borrowed liberally from many sources.
5668   However, it is
5669 \end_layout
5670
5671 \begin_layout LyX-Code
5672 worth noting that we were strongly influenced by the elegant tools
5673 \end_layout
5674
5675 \begin_layout LyX-Code
5676 developed and distributed by David Searls.
5677   My intent is to make the
5678 \end_layout
5679
5680 \begin_layout LyX-Code
5681 existing tool available to anyone in the research community that might
5682 \end_layout
5683
5684 \begin_layout LyX-Code
5685 find it useful.
5686   I will continue to try to fix bugs and make suggested
5687 \end_layout
5688
5689 \begin_layout LyX-Code
5690 enhancements, at least until I feel that a superior tool exists.
5691 \end_layout
5692
5693 \begin_layout LyX-Code
5694 Hence, I would appreciate it if all bug reports and suggestions are
5695 \end_layout
5696
5697 \begin_layout LyX-Code
5698 directed to me at Overbeek@mcs.anl.gov.
5699   
5700 \end_layout
5701
5702 \begin_layout LyX-Code
5703 I will try to log all bug fixes and report them to users that send me
5704 \end_layout
5705
5706 \begin_layout LyX-Code
5707 their email addresses.
5708   I do not require that you give me your name
5709 \end_layout
5710
5711 \begin_layout LyX-Code
5712 and address.
5713   However, if you do give it to me, I will try to notify
5714 \end_layout
5715
5716 \begin_layout LyX-Code
5717 you of serious problems as they are discovered.
5718 \end_layout
5719
5720 \begin_layout LyX-Code
5721 Getting Started:
5722 \end_layout
5723
5724 \begin_layout LyX-Code
5725     The distribution should contain at least the following programs:
5726 \end_layout
5727
5728 \begin_layout LyX-Code
5729                 README                  -     This document
5730 \end_layout
5731
5732 \begin_layout LyX-Code
5733                 ggpunit.c               -     One of the two source files
5734 \end_layout
5735
5736 \begin_layout LyX-Code
5737                 scan_for_matches.c      -     The second source file
5738 \end_layout
5739
5740 \begin_layout LyX-Code
5741                 
5742 \end_layout
5743
5744 \begin_layout LyX-Code
5745                 run_tests               -     A perl script to test things
5746 \end_layout
5747
5748 \begin_layout LyX-Code
5749                 show_hits               -     A handy perl script
5750 \end_layout
5751
5752 \begin_layout LyX-Code
5753                 test_dna_input          -     Test sequences for DNA
5754 \end_layout
5755
5756 \begin_layout LyX-Code
5757                 test_dna_patterns       -     Test patterns for DNA scan
5758 \end_layout
5759
5760 \begin_layout LyX-Code
5761                 test_output             -     Desired output from test
5762 \end_layout
5763
5764 \begin_layout LyX-Code
5765                 test_prot_input         -     Test protein sequences
5766 \end_layout
5767
5768 \begin_layout LyX-Code
5769                 test_prot_patterns      -     Test patterns for proteins
5770 \end_layout
5771
5772 \begin_layout LyX-Code
5773                 testit                  -     a perl script used for test
5774 \end_layout
5775
5776 \begin_layout LyX-Code
5777     Only the first three files are required.
5778   The others are useful,
5779 \end_layout
5780
5781 \begin_layout LyX-Code
5782     but only if you have Perl installed on your system.
5783   If you do
5784 \end_layout
5785
5786 \begin_layout LyX-Code
5787     have Perl, I suggest that you type
5788 \end_layout
5789
5790 \begin_layout LyX-Code
5791         
5792 \end_layout
5793
5794 \begin_layout LyX-Code
5795                 which perl
5796 \end_layout
5797
5798 \begin_layout LyX-Code
5799     to find out where it installed.
5800   On my system, I get the following
5801 \end_layout
5802
5803 \begin_layout LyX-Code
5804     response:
5805 \end_layout
5806
5807 \begin_layout LyX-Code
5808         
5809 \end_layout
5810
5811 \begin_layout LyX-Code
5812                 clone% which perl
5813 \end_layout
5814
5815 \begin_layout LyX-Code
5816                 /usr/local/bin/perl
5817 \end_layout
5818
5819 \begin_layout LyX-Code
5820     indicating that Perl is installed in /usr/local/bin.
5821   Anyway, once
5822 \end_layout
5823
5824 \begin_layout LyX-Code
5825     you know where it is installed, edit the first line of files 
5826 \end_layout
5827
5828 \begin_layout LyX-Code
5829         testit
5830 \end_layout
5831
5832 \begin_layout LyX-Code
5833         show_hits
5834 \end_layout
5835
5836 \begin_layout LyX-Code
5837     replacing /usr/local/bin/perl with the appropriate location.
5838   I
5839 \end_layout
5840
5841 \begin_layout LyX-Code
5842     will assume that you can do this, although it is not critical (it
5843 \end_layout
5844
5845 \begin_layout LyX-Code
5846     is needed only to test the installation and to use the "show_hits"
5847 \end_layout
5848
5849 \begin_layout LyX-Code
5850     utility).
5851   Perl is not required to actually install and run
5852 \end_layout
5853
5854 \begin_layout LyX-Code
5855     scan_for_matches.
5856  
5857 \end_layout
5858
5859 \begin_layout LyX-Code
5860     If you do not have Perl, I suggest you get it and install it (it
5861 \end_layout
5862
5863 \begin_layout LyX-Code
5864     is a wonderful utility).
5865   Information about Perl and how to get it
5866 \end_layout
5867
5868 \begin_layout LyX-Code
5869     can be found in the book "Programming Perl" by Larry Wall and
5870 \end_layout
5871
5872 \begin_layout LyX-Code
5873     Randall L.
5874  Schwartz, published by O'Reilly & Associates, Inc.
5875 \end_layout
5876
5877 \begin_layout LyX-Code
5878     To get started, you will need to compile the program.
5879    I do this
5880 \end_layout
5881
5882 \begin_layout LyX-Code
5883     using 
5884 \end_layout
5885
5886 \begin_layout LyX-Code
5887         gcc -O -o scan_for_matches  ggpunit.c scan_for_matches.c
5888 \end_layout
5889
5890 \begin_layout LyX-Code
5891     If you do not use GNU C, use 
5892 \end_layout
5893
5894 \begin_layout LyX-Code
5895         cc -O -DCC -o scan_for_matches  ggpunit.c scan_for_matches.c
5896 \end_layout
5897
5898 \begin_layout LyX-Code
5899     which works on my Sun.
5900   
5901 \end_layout
5902
5903 \begin_layout LyX-Code
5904     Once you have compiled scan_for_matches, you can verify that it
5905 \end_layout
5906
5907 \begin_layout LyX-Code
5908     works with
5909 \end_layout
5910
5911 \begin_layout LyX-Code
5912         clone% run_tests tmp
5913 \end_layout
5914
5915 \begin_layout LyX-Code
5916         clone% diff tmp test_output
5917 \end_layout
5918
5919 \begin_layout LyX-Code
5920     You may get a few strange lines of the sort
5921 \end_layout
5922
5923 \begin_layout LyX-Code
5924         clone% run_tests tmp
5925 \end_layout
5926
5927 \begin_layout LyX-Code
5928         rm: tmp: No such file or directory
5929 \end_layout
5930
5931 \begin_layout LyX-Code
5932         clone% diff tmp test_output
5933 \end_layout
5934
5935 \begin_layout LyX-Code
5936     These should cause no concern.
5937   However, if the "diff" shows that
5938 \end_layout
5939
5940 \begin_layout LyX-Code
5941     tmp and test_output are different, contact me (you have a
5942 \end_layout
5943
5944 \begin_layout LyX-Code
5945     problem).
5946  
5947 \end_layout
5948
5949 \begin_layout LyX-Code
5950     You should now be able to use scan_for_matches by following the
5951 \end_layout
5952
5953 \begin_layout LyX-Code
5954     instructions given below (which is all the normal user should have
5955 \end_layout
5956
5957 \begin_layout LyX-Code
5958     to understand, once things are installed properly).
5959 \end_layout
5960
5961 \begin_layout LyX-Code
5962  ==============================================================
5963 \end_layout
5964
5965 \begin_layout LyX-Code
5966 How to run scan_for_matches:
5967 \end_layout
5968
5969 \begin_layout LyX-Code
5970     To run the program, you type need to create two files
5971 \end_layout
5972
5973 \begin_layout LyX-Code
5974     1.
5975   the first file contains the pattern you wish to scan for; I'll
5976 \end_layout
5977
5978 \begin_layout LyX-Code
5979         call this file pat_file in what follows (but any name is ok)
5980 \end_layout
5981
5982 \begin_layout LyX-Code
5983     2.
5984   the second file contains a set of sequences to scan.
5985   These
5986 \end_layout
5987
5988 \begin_layout LyX-Code
5989         should be in "fasta format".
5990   Just look at the contents of
5991 \end_layout
5992
5993 \begin_layout LyX-Code
5994         test_dna_input to see examples of this format.
5995   Basically,
5996 \end_layout
5997
5998 \begin_layout LyX-Code
5999         each sequence begins with a line of the form
6000 \end_layout
6001
6002 \begin_layout LyX-Code
6003            >sequence_id
6004 \end_layout
6005
6006 \begin_layout LyX-Code
6007         and is followed by one or more lines containing the sequence.
6008 \end_layout
6009
6010 \begin_layout LyX-Code
6011     Once these files have been created, you just use
6012 \end_layout
6013
6014 \begin_layout LyX-Code
6015         scan_for_matches pat_file < input_file
6016 \end_layout
6017
6018 \begin_layout LyX-Code
6019     to scan all of the input sequences for the given pattern.
6020   As an
6021 \end_layout
6022
6023 \begin_layout LyX-Code
6024     example, suppose that pat_file contains a single line of the form
6025 \end_layout
6026
6027 \begin_layout LyX-Code
6028                 p1=4...7 3...8 ~p1
6029 \end_layout
6030
6031 \begin_layout LyX-Code
6032     Then,
6033 \end_layout
6034
6035 \begin_layout LyX-Code
6036                 scan_for_matches pat_file < test_dna_input
6037 \end_layout
6038
6039 \begin_layout LyX-Code
6040     should produce two "hits".
6041   When I run this on my machine, I get
6042 \end_layout
6043
6044 \begin_layout LyX-Code
6045         clone% scan_for_matches pat_file < test_dna_input
6046 \end_layout
6047
6048 \begin_layout LyX-Code
6049         >tst1:[6,27]
6050 \end_layout
6051
6052 \begin_layout LyX-Code
6053         cguaacc ggttaacc gguuacg 
6054 \end_layout
6055
6056 \begin_layout LyX-Code
6057         >tst2:[6,27]
6058 \end_layout
6059
6060 \begin_layout LyX-Code
6061         CGUAACC GGTTAACC GGUUACG 
6062 \end_layout
6063
6064 \begin_layout LyX-Code
6065         clone% 
6066 \end_layout
6067
6068 \begin_layout LyX-Code
6069 Simple Patterns Built by Matching Ranges and Reverse Complements
6070 \end_layout
6071
6072 \begin_layout LyX-Code
6073     Let me first explain this simple pattern:
6074 \end_layout
6075
6076 \begin_layout LyX-Code
6077                 
6078 \end_layout
6079
6080 \begin_layout LyX-Code
6081                 p1=4...7 3...8 ~p1
6082 \end_layout
6083
6084 \begin_layout LyX-Code
6085     The pattern consists of three "pattern units" separated by spaces.
6086 \end_layout
6087
6088 \begin_layout LyX-Code
6089     The first pattern unit is
6090 \end_layout
6091
6092 \begin_layout LyX-Code
6093                 p1=4...7
6094 \end_layout
6095
6096 \begin_layout LyX-Code
6097     which means "match 4 to 7 characters and call them p1".
6098   The
6099 \end_layout
6100
6101 \begin_layout LyX-Code
6102     second pattern unit is
6103 \end_layout
6104
6105 \begin_layout LyX-Code
6106                 3...8
6107 \end_layout
6108
6109 \begin_layout LyX-Code
6110     which means "then match 3 to 8 characters".
6111   The last pattern unit
6112 \end_layout
6113
6114 \begin_layout LyX-Code
6115     is 
6116 \end_layout
6117
6118 \begin_layout LyX-Code
6119                 ~p1
6120 \end_layout
6121
6122 \begin_layout LyX-Code
6123     which means "match the reverse complement of p1".
6124   The first
6125 \end_layout
6126
6127 \begin_layout LyX-Code
6128     reported hit is shown as
6129 \end_layout
6130
6131 \begin_layout LyX-Code
6132         >tst1:[6,27]
6133 \end_layout
6134
6135 \begin_layout LyX-Code
6136         cguaacc ggttaacc gguuacg 
6137 \end_layout
6138
6139 \begin_layout LyX-Code
6140     which states that characters 6 through 27 of sequence tst1 were
6141 \end_layout
6142
6143 \begin_layout LyX-Code
6144     matched.
6145   "cguaac" matched the first pattern unit, "ggttaacc" the
6146 \end_layout
6147
6148 \begin_layout LyX-Code
6149     second, and "gguuacg" the third.
6150   This is an example of a common
6151 \end_layout
6152
6153 \begin_layout LyX-Code
6154     type of pattern used to search for sections of DNA or RNA that
6155 \end_layout
6156
6157 \begin_layout LyX-Code
6158     would fold into a hairpin loop.
6159 \end_layout
6160
6161 \begin_layout LyX-Code
6162 Searching Both Strands
6163 \end_layout
6164
6165 \begin_layout LyX-Code
6166     Now for a short aside: scan_for_matches only searched the
6167 \end_layout
6168
6169 \begin_layout LyX-Code
6170     sequences in the input file; it did not search the opposite
6171 \end_layout
6172
6173 \begin_layout LyX-Code
6174     strand.
6175   With a pattern of the sort we just used, there is not
6176 \end_layout
6177
6178 \begin_layout LyX-Code
6179     need o search the opposite strand.
6180   However, it is normally the
6181 \end_layout
6182
6183 \begin_layout LyX-Code
6184     case that you will wish to search both the sequence and the
6185 \end_layout
6186
6187 \begin_layout LyX-Code
6188     opposite strand (i.e., the reverse complement of the sequence).
6189 \end_layout
6190
6191 \begin_layout LyX-Code
6192     To do that, you would just use the "-c" command line.
6193   For example,
6194 \end_layout
6195
6196 \begin_layout LyX-Code
6197         scan_for_matches -c pat_file < test_dna_input
6198 \end_layout
6199
6200 \begin_layout LyX-Code
6201     Hits on the opposite strand will show a beginning location greater
6202 \end_layout
6203
6204 \begin_layout LyX-Code
6205     than te end location of the match.
6206 \end_layout
6207
6208 \begin_layout LyX-Code
6209 Defining Pairing Rules and Allowing Mismatches, Insertions, and Deletions
6210 \end_layout
6211
6212 \begin_layout LyX-Code
6213     Let us stop now and ask "What additional features would one need to
6214 \end_layout
6215
6216 \begin_layout LyX-Code
6217     really find the kinds of loop structures that characterize tRNAs,
6218 \end_layout
6219
6220 \begin_layout LyX-Code
6221     rRNAs, and so forth?"  I can immediately think of two:
6222 \end_layout
6223
6224 \begin_layout LyX-Code
6225         a) you will need to be able to allow non-standard pairings
6226 \end_layout
6227
6228 \begin_layout LyX-Code
6229            (those other than G-C and A-U), and
6230 \end_layout
6231
6232 \begin_layout LyX-Code
6233         b) you will need to be able to tolerate some number of
6234 \end_layout
6235
6236 \begin_layout LyX-Code
6237            mismatches and bulges.
6238 \end_layout
6239
6240 \begin_layout LyX-Code
6241         
6242 \end_layout
6243
6244 \begin_layout LyX-Code
6245     Let me first show you how to handle non-standard "rules for
6246 \end_layout
6247
6248 \begin_layout LyX-Code
6249     pairing in reverse complements".
6250   Consider the following pattern,
6251 \end_layout
6252
6253 \begin_layout LyX-Code
6254     which I show as two line (you may use as many lines as you like in
6255 \end_layout
6256
6257 \begin_layout LyX-Code
6258     forming a pattern, although you can only break a pattern at points
6259 \end_layout
6260
6261 \begin_layout LyX-Code
6262     where space would be legal):
6263 \end_layout
6264
6265 \begin_layout LyX-Code
6266             r1={au,ua,gc,cg,gu,ug,ga,ag} 
6267 \end_layout
6268
6269 \begin_layout LyX-Code
6270             p1=2...3 0...4 p2=2...5 1...5 r1~p2 0...4 ~p1        
6271 \end_layout
6272
6273 \begin_layout LyX-Code
6274     The first "pattern unit" does not actually match anything; rather,
6275 \end_layout
6276
6277 \begin_layout LyX-Code
6278     it defines a "pairing rule" in which standard pairings are
6279 \end_layout
6280
6281 \begin_layout LyX-Code
6282     allowed, as well as G-A and A-G (in case you wondered, Us and Ts
6283 \end_layout
6284
6285 \begin_layout LyX-Code
6286     and upper and lower case can be used interchangably; for example
6287 \end_layout
6288
6289 \begin_layout LyX-Code
6290     r1={AT,UA,gc,cg} could be used to define the "standard rule" for
6291 \end_layout
6292
6293 \begin_layout LyX-Code
6294     pairings).
6295   The second line consists of six pattern units which
6296 \end_layout
6297
6298 \begin_layout LyX-Code
6299     may be interpreted as follows:
6300 \end_layout
6301
6302 \begin_layout LyX-Code
6303             p1=2...3     match 2 or 3 characters (call it p1)
6304 \end_layout
6305
6306 \begin_layout LyX-Code
6307             0...4        match 0 to 4 characters
6308 \end_layout
6309
6310 \begin_layout LyX-Code
6311             p2=2...5     match 2 to 5 characters (call it p2)
6312 \end_layout
6313
6314 \begin_layout LyX-Code
6315             1...5        match 1 to 5 characters
6316 \end_layout
6317
6318 \begin_layout LyX-Code
6319             r1~p2        match the reverse complement of p2,
6320 \end_layout
6321
6322 \begin_layout LyX-Code
6323                             allowing G-A and A-G pairs
6324 \end_layout
6325
6326 \begin_layout LyX-Code
6327             0...4        match 0 to 4 characters        
6328 \end_layout
6329
6330 \begin_layout LyX-Code
6331             ~p1          match the reverse complement of p1
6332 \end_layout
6333
6334 \begin_layout LyX-Code
6335                             allowing only G-C, C-G, A-T, and T-A pairs
6336 \end_layout
6337
6338 \begin_layout LyX-Code
6339     Thus, r1~p2 means "match the reverse complement of p2 using rule r1".
6340 \end_layout
6341
6342 \begin_layout LyX-Code
6343     Now let us consider the issue of tolerating mismatches and bulges.
6344 \end_layout
6345
6346 \begin_layout LyX-Code
6347     You may add a "qualifier" to the pattern unit that gives the
6348 \end_layout
6349
6350 \begin_layout LyX-Code
6351     tolerable number of "mismatches, deletions, and insertions".
6352 \end_layout
6353
6354 \begin_layout LyX-Code
6355     Thus,
6356 \end_layout
6357
6358 \begin_layout LyX-Code
6359                 p1=10...10 3...8 ~p1[1,2,1]
6360 \end_layout
6361
6362 \begin_layout LyX-Code
6363     means that the third pattern unit must match 10 characters,
6364 \end_layout
6365
6366 \begin_layout LyX-Code
6367     allowing one "mismatch" (a pairing other than G-C, C-G, A-T, or
6368 \end_layout
6369
6370 \begin_layout LyX-Code
6371     T-A), two deletions (a deletion is a character that occurs in p1,
6372 \end_layout
6373
6374 \begin_layout LyX-Code
6375     but has been "deleted" from the string matched by ~p1), and one
6376 \end_layout
6377
6378 \begin_layout LyX-Code
6379     insertion (an "insertion" is a character that occurs in the string
6380 \end_layout
6381
6382 \begin_layout LyX-Code
6383     matched by ~p1, but not for which no corresponding character
6384 \end_layout
6385
6386 \begin_layout LyX-Code
6387     occurs in p1).
6388   In this case, the pattern would match
6389 \end_layout
6390
6391 \begin_layout LyX-Code
6392               ACGTACGTAC GGGGGGGG GCGTTACCT
6393 \end_layout
6394
6395 \begin_layout LyX-Code
6396     which is, you must admit, a fairly weak loop.
6397   It is common to
6398 \end_layout
6399
6400 \begin_layout LyX-Code
6401     allow mismatches, but you will find yourself using insertions and
6402 \end_layout
6403
6404 \begin_layout LyX-Code
6405     deletions much more rarely.
6406   In any event, you should note that
6407 \end_layout
6408
6409 \begin_layout LyX-Code
6410     allowing mismatches, insertions, and deletions does force the
6411 \end_layout
6412
6413 \begin_layout LyX-Code
6414     program to try many additional possible pairings, so it does slow
6415 \end_layout
6416
6417 \begin_layout LyX-Code
6418     things down a bit.
6419 \end_layout
6420
6421 \begin_layout LyX-Code
6422 How Patterns Are Matched
6423 \end_layout
6424
6425 \begin_layout LyX-Code
6426     Now is as good a time as any to discuss the basic flow of control
6427 \end_layout
6428
6429 \begin_layout LyX-Code
6430     when matching patterns.
6431   Recall that a "pattern" is a sequence of
6432 \end_layout
6433
6434 \begin_layout LyX-Code
6435     "pattern units".
6436   Suppose that the pattern units were
6437 \end_layout
6438
6439 \begin_layout LyX-Code
6440         u1 u2 u3 u4 ...
6441  un
6442 \end_layout
6443
6444 \begin_layout LyX-Code
6445     The scan of a sequence S begins by setting the current position
6446 \end_layout
6447
6448 \begin_layout LyX-Code
6449     to 1.
6450   Then, an attempt is made to match u1 starting at the
6451 \end_layout
6452
6453 \begin_layout LyX-Code
6454     current position.
6455   Each attempt to match a pattern unit can
6456 \end_layout
6457
6458 \begin_layout LyX-Code
6459     succeed or fail.
6460   If it succeeds, then an attempt is made to match
6461 \end_layout
6462
6463 \begin_layout LyX-Code
6464     the next unit.
6465   If it fails, then an attempt is made to find an
6466 \end_layout
6467
6468 \begin_layout LyX-Code
6469     alternative match for the immediately preceding pattern unit.
6470   If
6471 \end_layout
6472
6473 \begin_layout LyX-Code
6474     this succeeds, then we proceed forward again to the next unit.
6475   If
6476 \end_layout
6477
6478 \begin_layout LyX-Code
6479     it fails we go back to the preceding unit.
6480   This process is called
6481 \end_layout
6482
6483 \begin_layout LyX-Code
6484     "backtracking".
6485   If there are no previous units, then the current
6486 \end_layout
6487
6488 \begin_layout LyX-Code
6489     position is incremented by one, and everything starts again.
6490   This
6491 \end_layout
6492
6493 \begin_layout LyX-Code
6494     proceeds until either the current position goes past the end of
6495 \end_layout
6496
6497 \begin_layout LyX-Code
6498     the sequence or all of the pattern units succeed.
6499   On success,
6500 \end_layout
6501
6502 \begin_layout LyX-Code
6503     scan_for_matches reports the "hit", the current position is set
6504 \end_layout
6505
6506 \begin_layout LyX-Code
6507     just past the hit, and an attempt is made to find another hit.
6508 \end_layout
6509
6510 \begin_layout LyX-Code
6511     If you wish to limit the scan to simply finding a maximum of, say,
6512 \end_layout
6513
6514 \begin_layout LyX-Code
6515     10 hits, you can use the -n option (-n 10 would set the limit to
6516 \end_layout
6517
6518 \begin_layout LyX-Code
6519     10 reported hits).
6520   For example,
6521 \end_layout
6522
6523 \begin_layout LyX-Code
6524         scan_for_matches -c -n 1 pat_file < test_dna_input
6525 \end_layout
6526
6527 \begin_layout LyX-Code
6528     would search for just the first hit (and would stop searching the
6529 \end_layout
6530
6531 \begin_layout LyX-Code
6532     current sequences or any that follow in the input file).
6533 \end_layout
6534
6535 \begin_layout LyX-Code
6536 Searching for repeats:
6537 \end_layout
6538
6539 \begin_layout LyX-Code
6540     In the last section, I discussed almost all of the details
6541 \end_layout
6542
6543 \begin_layout LyX-Code
6544     required to allow you to look for repeats.
6545   Consider the following
6546 \end_layout
6547
6548 \begin_layout LyX-Code
6549     set of patterns:
6550 \end_layout
6551
6552 \begin_layout LyX-Code
6553         p1=6...6 3...8 p1   (find exact 6 character repeat separated
6554 \end_layout
6555
6556 \begin_layout LyX-Code
6557                              by to 8 characters)
6558 \end_layout
6559
6560 \begin_layout LyX-Code
6561         p1=6...6 3..8 p1[1,0,0]   (allow one mismatch)
6562 \end_layout
6563
6564 \begin_layout LyX-Code
6565         p1=3...3 p1[1,0,0] p1[1,0,0] p1[1,0,0]  
6566 \end_layout
6567
6568 \begin_layout LyX-Code
6569                             (match 12 characters that are the remains
6570 \end_layout
6571
6572 \begin_layout LyX-Code
6573                              of a 3-character sequence occurring 4 times)
6574 \end_layout
6575
6576 \begin_layout LyX-Code
6577                 
6578 \end_layout
6579
6580 \begin_layout LyX-Code
6581         p1=4...8 0...3 p2=6...8 p1 0...3 p2
6582 \end_layout
6583
6584 \begin_layout LyX-Code
6585                             (This would match things like
6586 \end_layout
6587
6588 \begin_layout LyX-Code
6589                                 ATCT G TCTTT ATCT TG TCTTT
6590 \end_layout
6591
6592 \begin_layout LyX-Code
6593                             )
6594 \end_layout
6595
6596 \begin_layout LyX-Code
6597 Searching for particular sequences:
6598 \end_layout
6599
6600 \begin_layout LyX-Code
6601     Occasionally, one wishes to match a specific, known sequence.
6602 \end_layout
6603
6604 \begin_layout LyX-Code
6605     In such a case, you can just give the sequence (along with an
6606 \end_layout
6607
6608 \begin_layout LyX-Code
6609     optional statement of the allowable mismatches, insertions, and
6610 \end_layout
6611
6612 \begin_layout LyX-Code
6613     deletions).
6614   Thus,
6615 \end_layout
6616
6617 \begin_layout LyX-Code
6618         p1=6...8 GAGA ~p1    (match a hairpin with GAGA as the loop)
6619 \end_layout
6620
6621 \begin_layout LyX-Code
6622         RRRRYYYY             (match 4 purines followed by 4 pyrimidines)
6623 \end_layout
6624
6625 \begin_layout LyX-Code
6626         TATAA[1,0,0]         (match TATAA, allowing 1 mismatch)
6627 \end_layout
6628
6629 \begin_layout LyX-Code
6630         
6631 \end_layout
6632
6633 \begin_layout LyX-Code
6634 Matches against a "weight matrix":
6635 \end_layout
6636
6637 \begin_layout LyX-Code
6638     I will conclude my examples of the types of pattern units
6639 \end_layout
6640
6641 \begin_layout LyX-Code
6642     available for matching against nucleotide sequences by discussing a
6643 \end_layout
6644
6645 \begin_layout LyX-Code
6646     crude implemetation of matching using a "weight matrix".
6647   While I
6648 \end_layout
6649
6650 \begin_layout LyX-Code
6651     am less than overwhelmed with the syntax that I chose, I think that
6652 \end_layout
6653
6654 \begin_layout LyX-Code
6655     the reader should be aware that I was thinking of generating
6656 \end_layout
6657
6658 \begin_layout LyX-Code
6659     patterns containing such pattern units automatically from
6660 \end_layout
6661
6662 \begin_layout LyX-Code
6663     alignments (and did not really plan on typing such things in by
6664 \end_layout
6665
6666 \begin_layout LyX-Code
6667     hand very often).
6668   Anyway, suppose that you wanted to match a
6669 \end_layout
6670
6671 \begin_layout LyX-Code
6672     sequence of eight characters.
6673   The "consensus" of these eight
6674 \end_layout
6675
6676 \begin_layout LyX-Code
6677     characters is GRCACCGS, but the actual "frequencies of occurrence"
6678 \end_layout
6679
6680 \begin_layout LyX-Code
6681     are given in the matrix below.
6682   Thus, the first character is an A
6683 \end_layout
6684
6685 \begin_layout LyX-Code
6686     16% the time and a G 84% of the time.
6687   The second is an A 57% of
6688 \end_layout
6689
6690 \begin_layout LyX-Code
6691     the time, a C 10% of the time, a G 29% of the time, and a T 4% of
6692 \end_layout
6693
6694 \begin_layout LyX-Code
6695     the time.
6696   
6697 \end_layout
6698
6699 \begin_layout LyX-Code
6700              C1     C2    C3    C4   C5    C6    C7    C8
6701 \end_layout
6702
6703 \begin_layout LyX-Code
6704     
6705 \end_layout
6706
6707 \begin_layout LyX-Code
6708        A     16     57     0    95    0    18     0     0
6709 \end_layout
6710
6711 \begin_layout LyX-Code
6712        C      0     10    80     0  100    60     0    50
6713 \end_layout
6714
6715 \begin_layout LyX-Code
6716        G     84     29     0     0    0    20   100    50
6717 \end_layout
6718
6719 \begin_layout LyX-Code
6720        T      0      4    20     5    0     2     0     0   
6721 \end_layout
6722
6723 \begin_layout LyX-Code
6724     
6725 \end_layout
6726
6727 \begin_layout LyX-Code
6728     One could use the following pattern unit to search for inexact
6729 \end_layout
6730
6731 \begin_layout LyX-Code
6732     matches related to such a "weight matrix":
6733 \end_layout
6734
6735 \begin_layout LyX-Code
6736         {(16,0,84,0),(57,10,29,4),(0,80,0,20),(95,0,0,5),
6737 \end_layout
6738
6739 \begin_layout LyX-Code
6740          (0,100,0,0),(18,60,20,2),(0,0,100,0),(0,50,50,0)} > 450
6741 \end_layout
6742
6743 \begin_layout LyX-Code
6744     This pattern unit will attempt to match exactly eight characters.
6745 \end_layout
6746
6747 \begin_layout LyX-Code
6748     For each character in the sequence, the entry in the corresponding
6749 \end_layout
6750
6751 \begin_layout LyX-Code
6752     tuple is added to an accumulated sum.
6753   If the sum is greater than
6754 \end_layout
6755
6756 \begin_layout LyX-Code
6757     450, the match succeeds; else it fails.
6758 \end_layout
6759
6760 \begin_layout LyX-Code
6761     Recently, this feature was upgraded to allow ranges.
6762   Thus,
6763 \end_layout
6764
6765 \begin_layout LyX-Code
6766   600 >  {(16,0,84,0),(57,10,29,4),(0,80,0,20),(95,0,0,5),
6767 \end_layout
6768
6769 \begin_layout LyX-Code
6770          (0,100,0,0),(18,60,20,2),(0,0,100,0),(0,50,50,0)} > 450
6771 \end_layout
6772
6773 \begin_layout LyX-Code
6774     will work, as well.
6775 \end_layout
6776
6777 \begin_layout LyX-Code
6778 Allowing Alternatives:
6779 \end_layout
6780
6781 \begin_layout LyX-Code
6782     Very occasionally, you may wish to allow alternative pattern units
6783 \end_layout
6784
6785 \begin_layout LyX-Code
6786     (i.e., "match either A or B").
6787   You can do this using something
6788 \end_layout
6789
6790 \begin_layout LyX-Code
6791     like
6792 \end_layout
6793
6794 \begin_layout LyX-Code
6795                 ( GAGA | GCGCA)
6796 \end_layout
6797
6798 \begin_layout LyX-Code
6799     which says "match either GAGA or GCGCA".
6800   You may take
6801 \end_layout
6802
6803 \begin_layout LyX-Code
6804     alternatives of a list of pattern units, for example
6805 \end_layout
6806
6807 \begin_layout LyX-Code
6808         (p1=3...3 3...8 ~p1 | p1=5...5 4...4 ~p1 GGG)
6809 \end_layout
6810
6811 \begin_layout LyX-Code
6812     would match one of two sequences of pattern units.
6813   There is one
6814 \end_layout
6815
6816 \begin_layout LyX-Code
6817     clumsy aspect of the syntax: to match a list of alternatives, you
6818 \end_layout
6819
6820 \begin_layout LyX-Code
6821     need to fully the request.
6822   Thus,
6823 \end_layout
6824
6825 \begin_layout LyX-Code
6826         (GAGA | (GCGCA | TTCGA))
6827 \end_layout
6828
6829 \begin_layout LyX-Code
6830     would be needed to try the three alternatives.
6831 \end_layout
6832
6833 \begin_layout LyX-Code
6834 One Minor Extension
6835 \end_layout
6836
6837 \begin_layout LyX-Code
6838     Sometimes a pattern will contain a sequence of distinct ranges,
6839 \end_layout
6840
6841 \begin_layout LyX-Code
6842     and you might wish to limit the sum of the lengths of the matched
6843 \end_layout
6844
6845 \begin_layout LyX-Code
6846     subsequences.
6847    For example, suppose that you basically wanted to
6848 \end_layout
6849
6850 \begin_layout LyX-Code
6851     match something like
6852 \end_layout
6853
6854 \begin_layout LyX-Code
6855     ARRYYTT p1=0...5 GCA[1,0,0] p2=1...6 ~p1 4...8 ~p2 p3=4...10 CCT
6856 \end_layout
6857
6858 \begin_layout LyX-Code
6859     but that the sum of the lengths of p1, p2, and p3 must not exceed
6860 \end_layout
6861
6862 \begin_layout LyX-Code
6863     eight characters.
6864   To do this, you could add 
6865 \end_layout
6866
6867 \begin_layout LyX-Code
6868         length(p1+p2+p3) < 9
6869 \end_layout
6870
6871 \begin_layout LyX-Code
6872     as the last pattern unit.
6873   It will just succeed or fail (but does
6874 \end_layout
6875
6876 \begin_layout LyX-Code
6877     not actually match any characters in the sequence).
6878 \end_layout
6879
6880 \begin_layout LyX-Code
6881     
6882 \end_layout
6883
6884 \begin_layout LyX-Code
6885 Matching Protein Sequences
6886 \end_layout
6887
6888 \begin_layout LyX-Code
6889     Suppose that the input file contains protein sequences.
6890   In this
6891 \end_layout
6892
6893 \begin_layout LyX-Code
6894     case, you must invoke scan_for_matches with the "-p" option.
6895   You
6896 \end_layout
6897
6898 \begin_layout LyX-Code
6899     cannot use aspects of the language that relate directly to
6900 \end_layout
6901
6902 \begin_layout LyX-Code
6903     nucleotide sequences (e.g., the -c command line option or pattern
6904 \end_layout
6905
6906 \begin_layout LyX-Code
6907     constructs referring to the reverse complement of a previously
6908 \end_layout
6909
6910 \begin_layout LyX-Code
6911     matched unit).
6912   
6913 \end_layout
6914
6915 \begin_layout LyX-Code
6916     You also have two additional constructs that allow you to match
6917 \end_layout
6918
6919 \begin_layout LyX-Code
6920     either "one of a set of amino acids" or "any amino acid other than
6921 \end_layout
6922
6923 \begin_layout LyX-Code
6924     those a given set".
6925   For example,
6926 \end_layout
6927
6928 \begin_layout LyX-Code
6929         p1=0...4 any(HQD) 1...3 notany(HK) p1
6930 \end_layout
6931
6932 \begin_layout LyX-Code
6933     would successfully match a string like
6934 \end_layout
6935
6936 \begin_layout LyX-Code
6937            YWV D AA C YWV
6938 \end_layout
6939
6940 \begin_layout LyX-Code
6941 Using the show_hits Utility
6942 \end_layout
6943
6944 \begin_layout LyX-Code
6945     When viewing a large set of complex matches, you might find it
6946 \end_layout
6947
6948 \begin_layout LyX-Code
6949     convenient to post-process the scan_for_matches output to get a
6950 \end_layout
6951
6952 \begin_layout LyX-Code
6953     more readable version.
6954   We provide a simple post-processor called
6955 \end_layout
6956
6957 \begin_layout LyX-Code
6958     "show_hits".
6959   To see its effect, just pipe the output of a
6960 \end_layout
6961
6962 \begin_layout LyX-Code
6963     scan_for_matches into show_hits:
6964 \end_layout
6965
6966 \begin_layout LyX-Code
6967      Normal Output:
6968 \end_layout
6969
6970 \begin_layout LyX-Code
6971         clone% scan_for_matches -c pat_file < tmp
6972 \end_layout
6973
6974 \begin_layout LyX-Code
6975         >tst1:[1,28]
6976 \end_layout
6977
6978 \begin_layout LyX-Code
6979         gtacguaacc  ggttaac cgguuacgtac 
6980 \end_layout
6981
6982 \begin_layout LyX-Code
6983         >tst1:[28,1]
6984 \end_layout
6985
6986 \begin_layout LyX-Code
6987         gtacgtaacc  ggttaac cggttacgtac 
6988 \end_layout
6989
6990 \begin_layout LyX-Code
6991         >tst2:[2,31]
6992 \end_layout
6993
6994 \begin_layout LyX-Code
6995         CGTACGUAAC C GGTTAACC GGUUACGTACG 
6996 \end_layout
6997
6998 \begin_layout LyX-Code
6999         >tst2:[31,2]
7000 \end_layout
7001
7002 \begin_layout LyX-Code
7003         CGTACGTAAC C GGTTAACC GGTTACGTACG 
7004 \end_layout
7005
7006 \begin_layout LyX-Code
7007         >tst3:[3,32]
7008 \end_layout
7009
7010 \begin_layout LyX-Code
7011         gtacguaacc g gttaactt cgguuacgtac 
7012 \end_layout
7013
7014 \begin_layout LyX-Code
7015         >tst3:[32,3]
7016 \end_layout
7017
7018 \begin_layout LyX-Code
7019         gtacgtaacc g aagttaac cggttacgtac 
7020 \end_layout
7021
7022 \begin_layout LyX-Code
7023      Piped Through show_hits:
7024 \end_layout
7025
7026 \begin_layout LyX-Code
7027     
7028 \end_layout
7029
7030 \begin_layout LyX-Code
7031         clone% scan_for_matches -c pat_file < tmp | show_hits
7032 \end_layout
7033
7034 \begin_layout LyX-Code
7035         tst1:[1,28]:  gtacguaacc   ggttaac  cgguuacgtac
7036 \end_layout
7037
7038 \begin_layout LyX-Code
7039         tst1:[28,1]:  gtacgtaacc   ggttaac  cggttacgtac
7040 \end_layout
7041
7042 \begin_layout LyX-Code
7043         tst2:[2,31]:  CGTACGUAAC C GGTTAACC GGUUACGTACG
7044 \end_layout
7045
7046 \begin_layout LyX-Code
7047         tst2:[31,2]:  CGTACGTAAC C GGTTAACC GGTTACGTACG
7048 \end_layout
7049
7050 \begin_layout LyX-Code
7051         tst3:[3,32]:  gtacguaacc g gttaactt cgguuacgtac
7052 \end_layout
7053
7054 \begin_layout LyX-Code
7055         tst3:[32,3]:  gtacgtaacc g aagttaac cggttacgtac
7056 \end_layout
7057
7058 \begin_layout LyX-Code
7059         clone% 
7060 \end_layout
7061
7062 \begin_layout LyX-Code
7063     Optionally, you can specify which of the "fields" in the matches
7064 \end_layout
7065
7066 \begin_layout LyX-Code
7067     you wish to sort on, and show_hits will sort them.
7068   The field
7069 \end_layout
7070
7071 \begin_layout LyX-Code
7072     numbers start with 0.
7073   So, you might get something like
7074 \end_layout
7075
7076 \begin_layout LyX-Code
7077         clone% scan_for_matches -c pat_file < tmp | show_hits 2 1
7078 \end_layout
7079
7080 \begin_layout LyX-Code
7081         tst2:[2,31]:  CGTACGUAAC C GGTTAACC GGUUACGTACG
7082 \end_layout
7083
7084 \begin_layout LyX-Code
7085         tst2:[31,2]:  CGTACGTAAC C GGTTAACC GGTTACGTACG
7086 \end_layout
7087
7088 \begin_layout LyX-Code
7089         tst3:[32,3]:  gtacgtaacc g aagttaac cggttacgtac
7090 \end_layout
7091
7092 \begin_layout LyX-Code
7093         tst1:[1,28]:  gtacguaacc   ggttaac  cgguuacgtac
7094 \end_layout
7095
7096 \begin_layout LyX-Code
7097         tst1:[28,1]:  gtacgtaacc   ggttaac  cggttacgtac
7098 \end_layout
7099
7100 \begin_layout LyX-Code
7101         tst3:[3,32]:  gtacguaacc g gttaactt cgguuacgtac
7102 \end_layout
7103
7104 \begin_layout LyX-Code
7105         clone% 
7106 \end_layout
7107
7108 \begin_layout LyX-Code
7109     In this case, the hits have been sorted on fields 2 and 1 (that is,
7110 \end_layout
7111
7112 \begin_layout LyX-Code
7113     the third and second matched subfields).
7114 \end_layout
7115
7116 \begin_layout LyX-Code
7117     show_hits is just one possible little post-processor, and you
7118 \end_layout
7119
7120 \begin_layout LyX-Code
7121     might well wish to write a customized one for yourself.
7122 \end_layout
7123
7124 \begin_layout LyX-Code
7125 Reducing the Cost of a Search
7126 \end_layout
7127
7128 \begin_layout LyX-Code
7129     The scan_for_matches utility uses a fairly simple search, and may
7130 \end_layout
7131
7132 \begin_layout LyX-Code
7133     consume large amounts of CPU time for complex patterns.
7134   Someday,
7135 \end_layout
7136
7137 \begin_layout LyX-Code
7138     I may decide to optimize the code.
7139   However, until then, let me
7140 \end_layout
7141
7142 \begin_layout LyX-Code
7143     mention one useful technique.
7144   
7145 \end_layout
7146
7147 \begin_layout LyX-Code
7148     When you have a complex pattern that includes a number of varying
7149 \end_layout
7150
7151 \begin_layout LyX-Code
7152     ranges, imprecise matches, and so forth, it is useful to
7153 \end_layout
7154
7155 \begin_layout LyX-Code
7156     "pipeline" matches.
7157   That is, form a simpler pattern that can be
7158 \end_layout
7159
7160 \begin_layout LyX-Code
7161     used to scan through a large database extracting sections that
7162 \end_layout
7163
7164 \begin_layout LyX-Code
7165     might be matched by the more complex pattern.
7166   Let me illustrate
7167 \end_layout
7168
7169 \begin_layout LyX-Code
7170     with a short example.
7171   Suppose that you really wished to match the
7172 \end_layout
7173
7174 \begin_layout LyX-Code
7175     pattern 
7176 \end_layout
7177
7178 \begin_layout LyX-Code
7179     p1=3...5 0...8 ~p1[1,1,0] p2=6...7 3...6 AGC 3...5 RYGC ~p2[1,0,0]
7180 \end_layout
7181
7182 \begin_layout LyX-Code
7183     In this case, the pattern units AGC 3...5 RYGC can be used to rapidly
7184 \end_layout
7185
7186 \begin_layout LyX-Code
7187     constrain the overall search.
7188   You can preprocess the overall
7189 \end_layout
7190
7191 \begin_layout LyX-Code
7192     database using the pattern:
7193 \end_layout
7194
7195 \begin_layout LyX-Code
7196           31...31 AGC 3...5 RYGC 7...7
7197 \end_layout
7198
7199 \begin_layout LyX-Code
7200     Put the complex pattern in pat_file1 and the simpler pattern in
7201 \end_layout
7202
7203 \begin_layout LyX-Code
7204     pat_file2.
7205   Then use,
7206 \end_layout
7207
7208 \begin_layout LyX-Code
7209         scan_for_matches -c pat_file2 < nucleotide_database |
7210 \end_layout
7211
7212 \begin_layout LyX-Code
7213         scan_for_matches pat_file1
7214 \end_layout
7215
7216 \begin_layout LyX-Code
7217     The output will show things like
7218 \end_layout
7219
7220 \begin_layout LyX-Code
7221     >seqid:[232,280][2,47]
7222 \end_layout
7223
7224 \begin_layout LyX-Code
7225     matches pieces
7226 \end_layout
7227
7228 \begin_layout LyX-Code
7229     Then, the actual section of the sequence that was matched can be
7230 \end_layout
7231
7232 \begin_layout LyX-Code
7233     easily computed as [233,278] (remember, the positions start from
7234 \end_layout
7235
7236 \begin_layout LyX-Code
7237     1, not 0).
7238 \end_layout
7239
7240 \begin_layout LyX-Code
7241     Let me finally add, you should do a few short experiments to see
7242 \end_layout
7243
7244 \begin_layout LyX-Code
7245     whether or not such pipelining actually improves performance -- it
7246 \end_layout
7247
7248 \begin_layout LyX-Code
7249     is not always obvious where the time is going, and I have
7250 \end_layout
7251
7252 \begin_layout LyX-Code
7253     sometimes found that the added complexity of pipelining actually
7254 \end_layout
7255
7256 \begin_layout LyX-Code
7257     slowed things up.
7258   It gets its best improvements when there are
7259 \end_layout
7260
7261 \begin_layout LyX-Code
7262     exact matches of more than just a few characters that can be
7263 \end_layout
7264
7265 \begin_layout LyX-Code
7266     rapidly used to eliminate large sections of the database.
7267 \end_layout
7268
7269 \begin_layout LyX-Code
7270 =============
7271 \end_layout
7272
7273 \begin_layout LyX-Code
7274 Additions:
7275 \end_layout
7276
7277 \begin_layout LyX-Code
7278 Feb 9, 1995:   the pattern units ^ and $ now work as in normal regular
7279 \end_layout
7280
7281 \begin_layout LyX-Code
7282                expressions.
7283   That is
7284 \end_layout
7285
7286 \begin_layout LyX-Code
7287                         TTF $
7288 \end_layout
7289
7290 \begin_layout LyX-Code
7291                matches only TTF at the end of the string and 
7292 \end_layout
7293
7294 \begin_layout LyX-Code
7295                         ^ TTF 
7296 \end_layout
7297
7298 \begin_layout LyX-Code
7299                matches only an initial TTF
7300 \end_layout
7301
7302 \begin_layout LyX-Code
7303                The pattern unit 
7304 \end_layout
7305
7306 \begin_layout LyX-Code
7307                         <p1
7308 \end_layout
7309
7310 \begin_layout LyX-Code
7311                matches the reverse of the string named p1.
7312   That is,
7313 \end_layout
7314
7315 \begin_layout LyX-Code
7316                if p1 matched GCAT, then <p1 would match TACG.
7317   Thus,
7318 \end_layout
7319
7320 \begin_layout LyX-Code
7321                    p1=6...6 <p1
7322 \end_layout
7323
7324 \begin_layout LyX-Code
7325                matches a real palindrome (not the biologically common
7326 \end_layout
7327
7328 \begin_layout LyX-Code
7329                meaning of "reverse complement")
7330 \end_layout
7331
7332 \begin_layout LyX-Code
7333
7334 \end_layout
7335
7336 \end_body
7337 \end_document