For a while, I did not know the opposite of bioinformatics. I suddenly said that to calculate the foldrate, the file is still in the FASTA format.
Http://ibi.hzau.edu.cn/FDserver/cipred.php
On the website, you can directly submit a single protein sequence to calculate foldrate. In this way, you only need to write the program that submits the form to HTTP, cyclically retrieve the sequence in the. fastx file, and submit it one by one. The Form format can be obtained by viewing the source code of the webpage. PHP and Perl methods are better implemented:
Perl programs are simple:
#! /Usr/bin/perluse strict; Use lwp; my $ word = 'your website has been used Shanghai'; my $ content; my $ browser = lwp :: useragent-> New (); my $ url = 'HTTP: // ibi.hzau.edu.cn/fdserver/cido.php'{browser-> env_proxy (); # environment configuration $ browser-> timeout (200 ); # latency my $ response = $ browser-> post ($ URL, ['textta' => $ word, 'radiobutton' => 'unknown ', 'buttonratepred' => 'predict folding rate']); if ($ response-> is_success) {print $ response-> content ;} else {print "bad luck this time \ n ";}
The obtained format is HTML, Which is saved in $ response-> content. Then use the regular expression:
(The predicted folding rate: )(log\(Kf\) = )(.*)(/sec.)
You can get the folding rate.
PHP uses curl (http://bbs.phpchina.com/thread-237353-1-1.html)
Remove the; Extension = php_curl.dll line from the php. ini file. (Otherwise, an error is returned when curl_init () is called)
<?phpfunction curlFunc($array) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $array['url']); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CRLF, false); if (isset($array['header']) && $array['header']) { curl_setopt($ch, CURLOPT_HEADER, 1); } if (isset($array['httpheader'])) { $headerArr = array(); foreach($array['httpheader'] as $n => $v) { $headerArr[] = $n . ':' . $v; } curl_setopt($ch, CURLOPT_HTTPHEADER, $headerArr); } if (isset($array['referer'])) { curl_setopt($ch, CURLOPT_REFERER, $array['referer']); } if (isset($array['post'])) { curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $array['post']); } if (isset($array['cookie'])) { curl_setopt($ch, CURLOPT_COOKIE, $array['cookie']); } if (isset($array['useragent'])) { curl_setopt($ch, CURLOPT_USERAGENT, $array['useragent']); } else { curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"); } if (isset($array['cookiefile'])) { curl_setopt($ch, CURLOPT_COOKIEFILE, $array['cookiefile']); } if (isset($array['cookiejar'])) { curl_setopt($ch, CURLOPT_COOKIEJAR, $array['cookiejar']); } $r['erro'] = curl_error($ch); $r['errno'] = curl_errno($ch); $r['html'] = curl_exec($ch); $r['http_code'] = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); return $r;}$a=array('url'=>'http://feedback.hao123.com/', 'post'=>'ac=create&catalog_id=2&description=test',);$b=curlFunc($a);echo htmlspecialchars($b['html']);//var_dump($b);
With the curlfunc function, we can submit our data.
The following are two encapsulated functions:
Function stringtorate ($ Str) {// send the form information to $ B $ A = array ('url' => 'HTTP: // ibi.hzau.edu.cn/fdserver/cido.php ', 'post' => 'textarea = '. $ Str. '& radiobutton = unknown & buttonratepred = predict folding rate',); $ B = curlfunc ($ ); // return HTML $ c = htmlspecialchars ($ B ['html']); // display in format // var_dump ($ B ); // search for the matching regular expression from $ B // :( the predicted folding rate:) (log \ (kf \) = )(. *) (/sec .) $ RegEx = '(the predicted folding rate:) (log \ (kf \) = )(. *) (/sec.) '; Ereg ($ RegEx, $ C, $ matches); $ result = $ matches [3]; return $ result;} function fileexec ($ data, $ output) {// $ data is the database path $ output is the path of the output file // open the database $ data_file_name = $ data; $ data_file_pointer = fopen ($ data_file_name, "R "); // open the output file $ output_file_name = $ output; $ output_file_pointer = fopen ($ output_file_name, "W"); $ data_file_line1 = '1'; $ data_file_line2 = '2 '; // read data in two behavior units while ($ data_file_line1! = NULL & $ data_file_line2! = NULL) {$ data_file_line1 = fgets ($ data_file_pointer); $ data_file_line2 = fgets ($ data_file_pointer); $ time = stringtorate ($ data_file_line2 ); $ RegEx = '(Dip-[0-9] * n)'; ereg ($ RegEx, $ data_file_line1, $ matches); $ writer = $ matches [0]. "\ t ". $ time. "\ r \ n"; fwrite ($ output_file_pointer, $ writer);} echo "Congradulations! "; Echo" execute file OK! ";}
==========================================
From: http://blog.csdn.net/zh405123507