Is there any othere way to do it;

Discussion in 'Perl Misc' started by Rita, Jan 23, 2006.

  1. Rita

    Rita Guest

    Hi All,
    I am getting some result through loop.I want to store all the result
    which i am getting.
    but i am using temprary file ,so it is using same file every time,and i
    couldnt figure out that how i can store the result in 1 file every
    time. Here is my program.

    use warnings;
    use strict;
    use Bio::SeqIO;
    use Bio::SearchIO;

    my $outputfile = 'result.out';
    open OUTPUT3 '>', $outputfile || die "Can't open \"$outputfile\" $!";

    my $filename = 'file.fasta';

    #either open the file, or exit from the program
    open FILE,$filename ||die "Cannot open file \"$filename\"\n\n $!";
    #Read the all data of the file in variable called $line;
    while(my $line =<FILE>){
    #Remove the white space or new line from the data
    chomp $line;

    (my ( $sequence) = (split /\t/, $line)[4]);
    print "Sequence - $sequence\n\n";
    my $seqio = Bio::SeqIO-> new(-file =>'>temp1',-format=>'fasta');
    $sequence = Bio::Seq-> new(-seq => $sequence, -display_id=>'test1');

    system ("mfold SEQ='temp1'");
    This mfold generate output in file called "temp1.out"
    I tried this line but this is just printing text temp1.out every time
    in 'result.out'.
    print OUTPUT3 'temp1.out';

    Inputs are some sequences -

    Rita, Jan 23, 2006
    1. Advertisements

  2. Rita

    Rita Guest

    > > my $outputfile = 'result.out';
    > > open OUTPUT3 '>', $outputfile || die "Can't open \"$outputfile\" $!";

    > You have two problems on this line. You need a comma after OUTPUT3;
    > without it the line will not compile. Please post real code that
    > compiles. You also have a precedence problem. See 'perldoc perlopentut'
    > and look at the examples under 'Simple Opens'. Either put paenheses
    > around (OUTPUT3 '>', $outputfile) or replace || with or.


    > > my $filename = 'file.fasta';
    > >
    > > #either open the file, or exit from the program

    > Please do not include comments like this when you post a program.
    > Anybody who is able to help you will already know what the following
    > line does. The comment just gets in the way of comprehending your
    > program.

    Sorry for the inconvieniance.

    > > system ("mfold SEQ='temp1'");
    > > This mfold generate output in file called "temp1.out"
    > > I tried this line but this is just printing text temp1.out every time
    > > in 'result.out'.

    > If you are going to put comments inside your program, at least make
    > them valid Perl comments by prefixing them with '#'.

    That is not my programm comment ,that i just explaned to you.

    > > print OUTPUT3 'temp1.out';

    > You are telling Perl to write the string 'temp1.out' to the file each
    > time through the loop, and this is what it does. If you want to append
    > the contents of temp1.out to the file result.out, you can either tell
    > the operating system to do it:
    > system("cat temp1.out >> result.out");
    > or tell Perl to do it (untested):
    > open( my $rpt, 'temp1.out') or die("Can't open temp1.out: $!);
    > while(<$rpt>) {
    > print OUTPUT3;
    > }
    > close($rpt) or die ...;
    > > }
    > >
    > > Inputs are some sequences -

    > It is difficult for someone who doesn't have your data, doesn't have
    > the Bio::SeqIO or Bio::SearchIO modules installed, and doesn't have the
    > mfold program on their system to run your program and tell what is
    > wrong. Please work on decomposing your problems and posting only those
    > parts with which you are having trouble. Eliminate the other parts,
    > replacing them with stubs or simple assignments. Doing so will increase
    > the probability of getting help.
    > Of course, you have been given this advice many times in the past and
    > either misunderstood or ignored it. Perhaps repeating it one more time
    > will help.
    > Good luck!

    Thanks,Next time i will be take care and I really appritiated for
    help,though my way of asking question is not good.Thanks again.
    > Posted Via Premium Usenet Newsgroup Services
    > ----------------------------------------------------------
    > ----------------------------------------------------------
    Rita, Jan 23, 2006
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Carson
    Divyang M
    Aug 21, 2005
  2. ashu
    David Resnick
    Jan 26, 2006
  3. tenxian
    Apr 29, 2008
  4. Eric Danstron

    Are there ANY good forums out there anymore???

    Eric Danstron, Sep 21, 2005, in forum: ASP General
    Sep 22, 2005
  5. Andries

    is there a way ..... any way

    Andries, Apr 26, 2004, in forum: Perl Misc
    Apr 27, 2004