Bonjour,

Je suis en train de mettre en place un outil pour des biologistes qui permet à partir de données qu'on met sur le site internet d'obtenir un résultat via un script perl.
Je souhaiterais que les données misent par les biologistes puissent soit être déposées par un copier/coller dans un textarea soit par un upload.

Pour le textarea il n'y a pas de soucis ça fonctionne, mais pour l'upload ça ne fonctionne pas et je ne comprend pas pourquoi. Voici le code HTML puis une partie du script perl :

flankSNPseq.html
Code :Sélectionner tout -Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
 
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge"> 
    <meta name="description" content="Flanking SNP Sequence"> 
    <link rel="icon" href="favicon.ico">
    <title>Flanking SNP Sequence</title>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/bootstrap-table.css" rel="stylesheet">
    <link href="css/jquery-ui.css" rel="stylesheet">
    <style>
      .odd_row { background: #e9effa; }
      .even_row { }
    </style>
</head> 
<body>    <nav class="navbar  navbar-default">
  <div class="container">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>                        
      </button> 
    </div>
    <div class="collapse navbar-collapse" id="myNavbar">
      <ul class="nav navbar-nav">
        <li class="active"><a href="/index.html">Home</a></li> 
 
        <li class="dropdown">
            <a class="dropdown-toggle" data-toggle="dropdown" href="#">Tools <span class="caret"></span></a>
            <ul class="dropdown-menu" role="menu">
                <li><a href="/ontology.html">Gene Ontology Search</a></li>
                <li><a href="/keyword.html">Keyword Search</a></li>
                <li><a href="/interpro.html">InterPro Search</a></li>
                <li><a href="/location.html">Location</a></li>
                <li><a href="/locus.html">Locus Search</a></li>
				<li><a href="/flankSNPseq.html">Flanking SNP Sequence</a></li>
            </ul>
        </li>
		<li class="dropdown">
            <a class="dropdown-toggle" data-toggle="dropdown" href="#">Blast <span class="caret"></span></a>
            <ul class="dropdown-menu" role="menu">
				<li><a href="/primer_designer.html">Primer Designer</a></li>
				<li><a href="/primer_blaster.html">Primer Blaster</a></li>
				<li><a href="/blast.html">Blast</a></li>
			</ul>
        </li>
        <li><a href="/cgi-bin/gbrowse/elaeis_guineensis">Gbrowse</a></li>
    </div>
  </div>
    </nav><!-- Begin page content -->
<div class="container">
	<p align="justify">This tool was designed to obtain the SNP flanking sequence. <br />
    <div class="loading"></div>
    <div class="run"></div>
   <!-- <div class="tab-content"> -->
        <div id="form">
            <form class="form-horizontal" role="data" id="data" method="post" enctype="multipart/form-data" > 
                <div class="form-group">
					<label class="control-label col-sm-2" for="input">Paste SNP <br /><a  onclick="jQuery('#load_ex').val(example); return false;">Load Example</a></label>
                    <div class="col-sm-10">
					   <!--Textarea-->
						<input type="radio" name="filetype" checked="checked" value="text" id="text1" />										
                        <textarea class="form-control" rows="5" name="query" style="font-family:Courier New;" id="load_ex"></textarea>
					</div>	
					   <!-- -->
					   <!-- Test Upload de fichier vcf -->
					<div class="col-sm-10">
						<input type="radio" name="filetype" value="file" id="file1" /><label for="file1">&nbsp;Or upload your VCF</label>
						<input name="query" type="file" lang="en" size="30" />
					</div>
					   <!-- -->
				</div>				
				<div class="form-group">
					<label class="control-label col-sm-2" >Flanking Sequence Size</label>
					<label class="control-label col-sm-1">Downstream</label>
					<div class="col-xs-2"><input class="form-control" id="ex1" type="text" name="size_min" placeholder="60" /></div> 
					<label class="control-label col-sm-1">Upstream</label>
					<div class="col-xs-2"><input class="form-control" id="ex1" type="text" name="size_max" placeholder="60" /></div>  
				</div>    
                <div class="form-group"> 
                    <div class="col-sm-offset-2 col-sm-10">
                        <input type="hidden" name="type" value="snp"> 
                        <button type="submit" id="submit" class="submit btn btn-primary">Run</button>
                    </div>
                </div>
            </form>
         <!--</div>
    </div>
</div> -->
		</div>
<div class="show_result">
  <div class="container">
    <div class="output" id="output"></div>
    <table id="result" class="table table-no-bordered"
      data-toolbar="#toolbar"
      data-search="true" 
      data-show-toggle="true"
      data-show-columns="true"
      data-show-export="true"  
      data-page-size="10"
      data-pagination="true"
      data-pagination-first-text="First"
      data-pagination-pre-text="Previous"
      data-pagination-next-text="Next"
      data-pagination-last-text="Last" 
      data-page-list="[10, 20, 50, 100, 200]" 
      data-side-pagination="client"> 
    </table>
  </div>
</div> 
	<!--<script type="text/javascript" src="/js/jquery-1.5.1.min.js"></script> 
	<script type="text/javascript" src="/js/jquery-ui-1.8.11.custom.min.js"></script>
	<script type="text/javascript" src="/js/jquery.doubleSelect.js"></script>
	<script type="text/javascript" src="/js/database.js"></script>
	<script type="text/javascript" src="/js/form.js"></script>-->
    <script src="js/jquery.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/jquery.doubleSelect.js"></script>
    <script src="js/database.js"></script>
    <script src="js/bootstrap-table.js"></script>
    <script src="js/bootstrap-table-export.js"></script>
    <script src="js/jquery.validate.min.js"></script>
    <script src="js/tableExport.js"></script>
<script type="text/javascript">
      $(document).ready(function() {
        $('.submit').click(function (event) { 
		  $('#form').fadeOut('slow'); 
		  $('.loading').show(); 
		  $('.run').html("<div><img src='images/loading.gif' /> Please Wait</div> ");
		  $.ajax({
            url: "/cgi-bin/flankingsnp.pl",	
            enctype: 'multipart/form-data', 
			type: "POST", 		
			data:$('#data').serialize(), 
			dataType: 'json',  
            success: function(data) { 
              $('.loading').fadeOut('slow');
              $('.run').fadeOut('slow');
			  var result = "<ul>";
			  result += "<li>"+data.search+"</li>";
			  result += "<li>Number of result : "+data.num_result+"</li>";
              if (data.file_nucl) {
                result += "<li><a href='"+data.file_nucl+"' target='_blank'>Download Flank Sequence</a></li>";
              }
              result += "</ul>";
			  $("#output").html(result); 
              $('#result').bootstrapTable({ 
                  columns: [ {
                    field: 'id',
                    sortable: true,
                    title: 'Query Name'
                  }, {
                    field: 'seq_id',
                    sortable: true,
                    title: 'Flank Sequence'
                  }], 
                  data: data.result
                });
     		},  
      		error: function() {
              alert("Failed to load form");
        	}
		  });
          return false;
        });	
      });	 
</script>    
<script type="text/javascript">
<!--//--><![CDATA[//><!--
 
var example = 'EG01_01\t36486\t.\tC\tT\tPASS\nEG01_01\t364806\t.\tC\tT\tPASS\n';
 
//--><!]]>
</script> 
  </body>
</html>




flankingsnp.pl
Code :Sélectionner tout -Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
 
#!/usr/bin/perl
use CGI;
use SVG;
use CGI::Carp qw/fatalsToBrowser/;
use DBI;   
use JSON;
use FileUpload;  
use Bio:<img src="images/smilies/icon_biggrin.gif" border="0" alt="" title=":D" class="inlineimg" />B::SeqFeature::Store;
use Bio::Tools:<img src="images/smilies/icon_razz.gif" border="0" alt="" title=":P" class="inlineimg" />rimer3;
use Bio:<img src="images/smilies/icon_razz.gif" border="0" alt="" title=":P" class="inlineimg" />rimerDesigner;
use Bio:<img src="images/smilies/icon_razz.gif" border="0" alt="" title=":P" class="inlineimg" />rimarySeq; 
use warnings; 
use Bio::SeqIO;
use File::Basename;
use Bio::Index::Fasta;
use Bio::SearchIO; 
use Tie::IxHash;
use Data:<img src="images/smilies/icon_biggrin.gif" border="0" alt="" title=":D" class="inlineimg" />umper;
 
our $BLAST   = "/opt/ncbi-blast-2.2.31+/bin";
our $BED   = "/opt/bedtools2/bin"; 
our $DEBUG      = 0;
my $thread = 1;
 
use Data:<img src="images/smilies/icon_biggrin.gif" border="0" alt="" title=":D" class="inlineimg" />umper;
my $param = new CGI;
 
my $file      = $param->param("filetype");
my $query     = $param->param("query");
#my $type       = $param->param("type");
 
 
my $type ="snp";
# my $query = "EG01_01	36486	C	T";
my $source      = "opgp";				#
my $get_downstream    = $param->param("size_min") || "60";                   #SNP flanking Sequence
my $get_upstream    = $param->param("size_max") || "60";                     #SNP flanking Sequence
 
 
 
 
print $param->header('application/json'); 
my ($bank_path,$temp_path,$base_temp,$base_url,$length_chr,$base_ggb,$db_name,$host,$user,$password,$types , $tag, $bank_seq,$bank_cds,$bank_prot,$bank_pseudo) = &get_path($source); 
my $db      = Bio:<img src="images/smilies/icon_biggrin.gif" border="0" alt="" title=":D" class="inlineimg" />B::SeqFeature::Store->new( 
            -adaptor => 'DBI::mysql',
            -dsn       => 'dbi:mysql:database='.$db_name.';host=fruges.cirad.fr',
            -user    =>'gnpannot_admin',
            -pass    =>'Pa4dGnp@'
        );

La suite du code permet d'obtenir le résultat souhaité par les biologistes.

Dans le cas d'un upload, ma variable query est vide donc il semblerait que le problème viennent de là mais je n'arrive pas à expliquer la raison pour laquelle query ne contient pas le fichier que je souhaite uploader.

Je me suis posé la question de est ce qu'il faut que je passe par un autre script perl ou php pour faire l'upload puis que je le récupére dans flankingsnp.pl ?

Merci d'avance pour votre aide.