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 $!";
    <FILE>;
    #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');
    $seqio->write_seq($sequence);

    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 -

    Thanks
     
    Rita, Jan 23, 2006
    #1
    1. Advertising

  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.

    Thanks.

    > > 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 Usenet.com Premium Usenet Newsgroup Services
    > ----------------------------------------------------------
    > ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
    > ----------------------------------------------------------
    > http://www.usenet.com
     
    Rita, Jan 23, 2006
    #2
    1. Advertising

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
    Replies:
    9
    Views:
    3,752
    Divyang M
    Aug 21, 2005
  2. ashu
    Replies:
    7
    Views:
    336
    David Resnick
    Jan 26, 2006
  3. tenxian
    Replies:
    3
    Views:
    310
    RedGrittyBrick
    Apr 29, 2008
  4. Eric Danstron

    Are there ANY good forums out there anymore???

    Eric Danstron, Sep 21, 2005, in forum: ASP General
    Replies:
    1
    Views:
    169
    Immediacy
    Sep 22, 2005
  5. Andries

    is there a way ..... any way

    Andries, Apr 26, 2004, in forum: Perl Misc
    Replies:
    27
    Views:
    284
    Robin
    Apr 27, 2004
Loading...

Share This Page