R
Rita
Hi Members
I am making a program and I ran into a bit of difficulty with it. my
program is Bioinformatics related.and i have two files of squences.i
took one seq from first file and second seq from second file.and i did
Blast to both sequence then i want Gap Sequence in result.and my
program is working for 2 sequences but i want to put in loop to whole
program .so it will take for 1 inputf irst seq from first file then 2
input first sequence from second file then blast it and find a gap
sequence then again it will take second sequence from first file and
second seq from second file.........
so the problam is that the gap sequence is always different some
sequence has 1 gap some has 2 gap and some doesn't has gap .so i want
to put this thing is in loop and store all output sequences in a file.i
am trying it but i cannot figur it out please can you give a look to my
programm-
use warnings;
use strict;
use Bio::SeqIO;
use Bio::SearchIO;
# Get the name of the text file from the user that has the
# seqid, source seq :
print "Please type the filename of the seqid and source seq : ";
my $filename = <STDIN>;
# Remove the newline from the filename
chomp $filename;
# either open the file, or exit from the program
open FILE,$filename ||die "Cannot open file \"$filename\"\n\n $!";
<FILE>;
chomp(my $line = <FILE>);
my ($seqid, $source_seq) = (split /\t/, $line)[1,4];
print $seqid,"\t";
print $source_seq,"\n";
#write First sequence in Fasta Format and store in file name tmp:
my $seqio = Bio::SeqIO ->new(-file =>'>tmp',-format =>'fasta');
$source_seq = Bio::Seq-> new(-seq => $source_seq, -disaply_id
=>'test1');
$seqio ->write_seq($source_seq);
my$filename1="$seqid";
open(FILE1,"C:/Ritu/FastaSeqs/$filename1.CONSENS.fasta")||die "Cannot
open file
\"$filename1\"\n\n $!";
<FILE1>;
chomp(my $sts_seq=<FILE1>);
#Blast to both sequences and store output in file name temp.blast:
system("c:/downloads/bin/bl2seq -i tmp -j
C:/Ritu/FastaSeqs/$filename1.CONSENS.fasta
-p blastn -o temp.blast ");
my $in = Bio::SearchIO ->new(-format => 'blast',
-file => 'temp.blast');
while( my $result = $in->next_result ) {
while( my $hit = $result->next_hit ) {
#Print Starting and Ending Point of 1 Hsps-
my $hsp1 =$hit->next_hsp;
my$start1=$hsp1->hit->start;
my $end1=$hsp1->hit->end;
print "start First Hsp ",$start1,"\n";
print "End First Hsp ",$end1,"\n\n";
#Print Starting and Ending Point of 2 Hsps-
my $hsp2 =$hit->next_hsp;
my$start2=$hsp2->query->start;
my $end2=$hsp2->query->end;
print "start Second Hsp ",$start2,"\n";
print "End Second Hsp ",$end2,"\n\n";
#Get Gap Sequence :
print "Gap Sequence- ",$sts_seq->subseq($end1+1,$start2-1);
}
}
#Close the file
close FILE;
close FILE1;
thanks
I am making a program and I ran into a bit of difficulty with it. my
program is Bioinformatics related.and i have two files of squences.i
took one seq from first file and second seq from second file.and i did
Blast to both sequence then i want Gap Sequence in result.and my
program is working for 2 sequences but i want to put in loop to whole
program .so it will take for 1 inputf irst seq from first file then 2
input first sequence from second file then blast it and find a gap
sequence then again it will take second sequence from first file and
second seq from second file.........
so the problam is that the gap sequence is always different some
sequence has 1 gap some has 2 gap and some doesn't has gap .so i want
to put this thing is in loop and store all output sequences in a file.i
am trying it but i cannot figur it out please can you give a look to my
programm-
use warnings;
use strict;
use Bio::SeqIO;
use Bio::SearchIO;
# Get the name of the text file from the user that has the
# seqid, source seq :
print "Please type the filename of the seqid and source seq : ";
my $filename = <STDIN>;
# Remove the newline from the filename
chomp $filename;
# either open the file, or exit from the program
open FILE,$filename ||die "Cannot open file \"$filename\"\n\n $!";
<FILE>;
chomp(my $line = <FILE>);
my ($seqid, $source_seq) = (split /\t/, $line)[1,4];
print $seqid,"\t";
print $source_seq,"\n";
#write First sequence in Fasta Format and store in file name tmp:
my $seqio = Bio::SeqIO ->new(-file =>'>tmp',-format =>'fasta');
$source_seq = Bio::Seq-> new(-seq => $source_seq, -disaply_id
=>'test1');
$seqio ->write_seq($source_seq);
my$filename1="$seqid";
open(FILE1,"C:/Ritu/FastaSeqs/$filename1.CONSENS.fasta")||die "Cannot
open file
\"$filename1\"\n\n $!";
<FILE1>;
chomp(my $sts_seq=<FILE1>);
#Blast to both sequences and store output in file name temp.blast:
system("c:/downloads/bin/bl2seq -i tmp -j
C:/Ritu/FastaSeqs/$filename1.CONSENS.fasta
-p blastn -o temp.blast ");
my $in = Bio::SearchIO ->new(-format => 'blast',
-file => 'temp.blast');
while( my $result = $in->next_result ) {
while( my $hit = $result->next_hit ) {
#Print Starting and Ending Point of 1 Hsps-
my $hsp1 =$hit->next_hsp;
my$start1=$hsp1->hit->start;
my $end1=$hsp1->hit->end;
print "start First Hsp ",$start1,"\n";
print "End First Hsp ",$end1,"\n\n";
#Print Starting and Ending Point of 2 Hsps-
my $hsp2 =$hit->next_hsp;
my$start2=$hsp2->query->start;
my $end2=$hsp2->query->end;
print "start Second Hsp ",$start2,"\n";
print "End Second Hsp ",$end2,"\n\n";
#Get Gap Sequence :
print "Gap Sequence- ",$sts_seq->subseq($end1+1,$start2-1);
}
}
#Close the file
close FILE;
close FILE1;
thanks