如何提交作业(序列文件)并使用curl在Web服务器中检索结果

问题描述 投票:0回答:1

我有一个斋戒序列

> seq1

UUUAAAAUCUGUGUAGCUGUCGCUCGGCUGCAUGCCUAGUGCACCUACGCAGUAUAAA

想要将其替换为Web服务器http://bioinformatics.hitsz.edu.cn/iMiRNA-SSF/index.jsp

然后从以下位置检索结果(仅结果表):http://bioinformatics.hitsz.edu.cn/iMiRNA-SSF/showresult.jsp到输出文本文件。

我尝试了以下不起作用的代码。

职位发布

curl -X POST -d'seq1 \ nUUUAAAAUCUGUGUAGCUGUCGCUCGGCUGCAUGCCUAGUGCACCUACGCAGUAUAAA'http://bioinformatics.hitsz.edu.cn/iMiRNA-SSF/ -H“内容类型:application / json”

获取结果

curl -X POSThttp://bioinformatics.hitsz.edu.cn/iMiRNA-SSF/showresult.jsp/response-H“ Content-Type:文本/纯文本”;回声

您能帮忙吗?我有1000个序列。我需要从Linux终端自动执行。

附加了无法完全正常运行的perl脚本。有什么建议吗,编辑?

#!/usr/bin/perl

use LWP::Simple;
use LWP::UserAgent;
use HTTP::Request;
use HTTP::Response;

# Script parameters


# Script hidden parameters
$idCon="12345";

# Sequences source file
# IMPORTANT! use standard fasta file format

$inputFile="file.fa";

# Maximum number of sequences per request
$maxNumOfSequences=1;  

# If you want to skip the N first requests
$skipRequests=0;

# Output files prefix
$outputFile="result_ssf";

# Promoter script URL 
$URL = "http://bioinformatics.hitsz.edu.cn/iMiRNA-SSF/";

# Header and bottom line
$header = "sequenceName; primaryStru; secondStru; Pvalue; Classification\n";

#$URL2 = "http://bioinformatics.hitsz.edu.cn/iMiRNA-SSF/showresult.jsp";

##################################################################################

# The browser

printf "Creating the browser...\n";
$browser = LWP::UserAgent->new();
$browser->timeout(30);

printf "Opening input file...\n";
open(SEQUENCES, "<".$inputFile) or die $!;

printf "Opening output file...\n";
open OUTPUTFILE, ">".$outputFile or die $!;
printf OUTPUTFILE $header;

$sequences = "";
$sequenceName="";
$currentSec=0;
$currentRequest=0;

printf "Sending request...\n";
while(<SEQUENCES>) {

        if ($sequenceName eq "") {
            $sequenceName = $_;
        } else {
            $sequences = $sequences.$sequenceName.$_;
            $currentSec = $currentSec+1;
            $sequenceName = "";
        }

        if ($currentSec == $maxNumOfSequences) {
           $currentRequest=$currentRequest+1;

           if ($currentRequest > $skipRequests ) {
            printf " # Request num. ".$currentRequest."\n";

                my $response = $browser->post($URL, 
                [   "Predict" => $sequences,
                    "uploadFile" => ""
                ], 
                "Content_Type" => "form-data"  );

                if ($response->is_error()) {
                    printf "%s\n", $response->status_line;
                    exit 1;
                }

                $response = $browser->post($URL, ["showresult.jsp"]);


                if ($response->is_error()) {
                    printf "%s\n", $response->status_line;
                    exit 1;
                }

                $contents = $response->content();
                #$contents =~ s/(<BR>\n|<BODY>|<\/BODY>|<HEAD>|<\/HEAD>|<HTML>|<\/HTML>|<META(.*)>|<TITLE>(.*)<\/TITLE>)//ig;
                $contents =~ s/(<BR>\n|<BODY>|<\/BODY>|<HEAD>|<\/HEAD>|<HTML>|<\/HTML>|<META(.*)>|<table>(.*)<\/table>)//ig;

                if ($contents =~ m/$header(.*)\n\n-/s) {
                    print OUTPUTFILE $1;
                    print OUTPUTFILE "\n";
                }

            }
            $currentSec = 0;
            $sequences = "";
        }
}



close OUTPUTFILE;
close SEQUENCES;
curl webserver fasta
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.