Thread: Join the data.

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    3
    Rep Power
    0

    Join the data.


    Hi Dev Shed Forum,

    I am new to the programming.
    I have written this script.

    This is the input file example
    #>ABC|seq|seq.1 clone ABC10, partial sequence.
    #AGAGTTTGATCCTGGCTCAGGATGAACGCTGGCGGCGTGCCTAACACATGCAAGTCGAGC
    #GAAGCGCATAAGTTAGAATCTTCGGAGGAAGACATATGTGACTGAGCGGCGGACGGGTGA
    #GTAACGCGTGGGTAACCTGCCTTACACAGGGGGATAACAGTTAGAAATGACTGCTAATAC
    #CGCATAAGACCACAGTACTGCATGGTACAGTGGTAAAAACTGAGGTGGTGTAAGATGGAC


    #!/usr/bin/perl

    open(IN,'Input.fasta');
    open (OUT,'>Mod.Input.fasta');

    @in=<IN>;
    chomp(@in);
    close(IN);


    foreach $line(@in)
    {
    if($line=~/>\w+\|(\w+)\|.*/)
    {
    $line=~/>\w+\|(\w+)\|.*/;
    $header=$1;
    print OUT "$1\n";
    }#end of if

    }#end of foreach loop

    now i have got the middle ID(i.e. seq) which I wanted but I want to join the sequences of same ID. Please tell me the logic how one can do this.

    so i want output like
    >seq
    ATGGCGC so on

    Thanks in advance,
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2012
    Posts
    831
    Rep Power
    496
    If I understand correctly what you are doing, your whole foreach loop could be:

    Perl Code:
    foreach my $line(@in) {
         print OUT "$1\n" if $line=~/>\w+\|(\w+)\|/;
    } #end of foreach


    Now, for your question:

    I want to join the sequences of same ID
    I am not a biologist and don't understand what this means. Pls explain what you mean by joining the sequences.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    3
    Rep Power
    0
    Dear Laurent_R,

    Thanks for the reply but in $1 i have just the ID and not the sequences so printing $1 will not be helpful because I want sequence also for the same Id.

    So my question is how to get the sequences belongs to same ID.

    Thanks
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    3
    Rep Power
    0
    Oh yeah I got it. I have to put else

IMN logo majestic logo threadwatch logo seochat tools logo