Debian Codegraph @

examples/phylofoot.pl

raw symbols SCIP
1 #!/usr/bin/env perl -w
2
3 # phylofoot.pl
4 # by Boris Lenhard
5 #
6 # See POD documentation for this script at the end of the file
7 #
8
9 use strict;
10 use Getopt::Long; # for parsing command line arguments
11 use Pod::Usage;
12 use TFBS::DB::FlatFileDir;
13
14 # DEFAULTS - presumes scripts are run from example/ directory
15 # in the TFBS distribution
16
17 # default values for optional parameters
18
19 my $CONSERVATION_PERCENT = 70;
20 my $MATRIX_THRESHOLD_PERCENT = 80;
21 my $SLIDING_WINDOW = 50;
22
23
24 # Get command line options - if you are curious how this
25 # works, check the Getopt::Long module documentation.
26
27 my ($database_dir, $alignment_file, $help);
28 my @matrix_IDs = ();
29 my $conservation = $CONSERVATION_PERCENT;
30 my $threshold = $MATRIX_THRESHOLD_PERCENT;
31 my $window = $SLIDING_WINDOW;
32
33 GetOptions('help' => \$help,
34 'alignment_file=s' => \$alignment_file,
35 'database=s' => \$database_dir,
36 'matrix-id:s' => \@matrix_IDs,
37 'conservation:f' => \$conservation,
38 'threshold-score:f' => \$threshold,
39 'window-size:i' => \$window
40 );
41
42 if($help) {
43 pod2usage(-exitstatus=>0, -verbose=>2);
44 }
45 elsif (!($alignment_file and $database_dir)) {
46 pod2usage(1);
47 }
48
49 # parse both the comma-separated lists and individually specified
50 # matrix IDs:
51
52 @matrix_IDs = split (",", join(',',@matrix_IDs));
53
54
55 # connect to FlatFileDir matrix database
56 # (there is a sample FlatFileDir matrix database directory
57 # examples/SAMPLE_FlatFileDir in the TFBS distribution package)
58 # Change this line if you want to use a different type of database
59 # (e.g. TFBS::DB::JASPAR2)
60
61
62 my $db = TFBS::DB::FlatFileDir->connect($database_dir);
63
64 # slurp the matrices into a TFBS::MatrixSet;
65
66 my $matrixset;
67
68 unless (scalar @matrix_IDs) { # if none are selected, we already have the set:
69
70 $matrixset = $db->get_MatrixSet(-matrixtype=>"PWM"); # retrieves all matrices from the db
71 }
72 else { # otherwise we retrieve inly the requested ones
73
74 $matrixset = $db->get_MatrixSet(-IDs => \@matrix_IDs,
75 -matrixtype=>"PWM");
76 }
77
78
79 # do the phylogenetic footprinting search of the sites
80
81 my $sitepairset = $matrixset->search_aln(-file=>$alignment_file,
82 -cutoff=>"$conservation",
83 -threshold=>"$threshold\%",
84 -windowsize => $window);
85
86 # print it out in GFF format
87
88 print $sitepairset->GFF;
89
90 # ANd that's it. Instead of simply printing GFF, you can e.g.
91 # - iterate through individual detected binding site pairs and extract
92 # the information you need
93 # - attach individual sittes as Bio::SeqFeature subclass objects
94 # to bioperl's Bio::Seq objects
95 # - collect the hit sequences and produce derived pattern matrices
96 # using TFBS::Pa
97 # - you tell me...
98
99
100
101
102
103
104
105
106
107
108 # The rest is usage message if the user requests help
109 # or fails to provide required parameters
110
111
112 __END__
113
114
115 =head1 NAME
116
117 phylofoot.pl - Phylogenetic footprinting example script
118
119 =head1 SYNOPSIS
120
121 ./phylofoot.pl -a <alignment_file> -d <TFBS_matrix_dbase_dir> [other_options]
122
123 =head1 OPTIONS
124
125 =over 8
126
127 =item B<-d or --database> <directory name>
128
129 REQUIRED: Name of the FlatFileDir database directory to
130 use for retrieving matrices.
131 A sample database directory examples/SAMPLE_FlatFileDir
132 is available in TFBS distribution.
133
134 =item B<-a or --alignment-file> <alignment file name>
135
136 REQUIRED: Name of the pairwise alignment file in Clustal
137 format.
138 A sample database directory examples/sample_alignment.aln
139 is available in TFBS distribution.
140
141 =item B<-m or --matrix-id> <list of matrix IDs>
142
143 OPTIONAL: ID of the matrix from the database to scan the
144 alignment with.You can specify multiple matrices using
145 multiple -m switches or a single comma-separated lists of
146 IDs (NO spaces - e.g. -m M00001,M00021,N01921 ). You can
147 use a script called examples/list_matrices.pl in TFBS distribution
148 to list information for all matrices in a matrix database
149 of the FlatFileDir type.
150
151 DEFAULT: If no matrix IDs are specified, all matrices in
152 the database are used for the search;
153
154 =item B<-w or --window-size> <integer value>
155
156 OPTIONAL: The width of sliding window for calculating
157 the conservation profile of the submitted pairwise alignment.
158
159 DEFAULT: If not specified, the default value is 50 (nucleotides).
160
161 =item B<-c or --conservation> <percent value>
162
163 OPTIONAL: Conservation cutoff (in percent) for a region of
164 multiple alignment to include detected conserved sites into output.
165
166 DEFAULT: If not specified, the default value is 70 (%).
167
168 =item B<-t or --threshold-score> <percent value>
169
170 OPTIONAL: Threshold score (in percent) for a matrix match to
171 a subsequence.
172
173 DEFAULT: If not specified, the default value is 80 (%).
174
175 =back
176
177
178
179 =head1 DESCRIPTION
180
181 This is an example script that scans conserved regions of a
182 pairwise DNA sequence alignment with a set of matrices form
183 a flat file databases and produces GFF output. Its source code is
184 meant to be studied by bioinformaticians who wish to learn how to
185 use TFBS modules.
186
187
188 =cut
189