Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • loba17
    Member
    • Sep 2011
    • 19

    #1

    Merging Pairwise Sequence Alignment

    Dear All,

    I am looking for a way to "merge" two large sequence files. The first sequence is the reference sequence and the second is a consensus sequence containing ambiguous nucleotides (Ns). The merged sequence should correspond to the consensus sequence but the missing nucleotides should be used from the reference.

    Example:

    BAM-consensus: CCCTANNNNNNNNCATCTACATGG
    Reference: GTATAGATATCATCATCTACATCC
    Output => CCCTAGATATCATCATCTACATGG


    I tried Emboss (cons, consambig, megamerger) but the problems are ambiguous nucleotides. I wrote a simple unix script and it worked just fine but not with large sequences (100MB). Any ideas that would work for larger files?

    Thanks for considering my question!
  • RickBioinf
    Member
    • Sep 2012
    • 28

    #2
    Maybe try and right a Perl file, I think that would be your best option for this.
    I personally don't know a tool for this.

    Comment

    • gsgs
      Senior Member
      • Oct 2009
      • 139

      #3
      m1:a=fgetc(file1);
      b=fgetc(file2);
      if(a=='N')a=b;
      fputc(a,file3);
      if(feof(file1)==0)goto m1;

      Comment

      • loba17
        Member
        • Sep 2011
        • 19

        #4
        thanks gsgs

        for your helpful reply. unfortunately I am not familiar with fgetc. I am on a Linux RedHat system.

        Comment

        • gsgs
          Senior Member
          • Oct 2009
          • 139

          #5
          it's a pity with all those different systems ...
          do you have a C-compiler ? The simpler the better

          Comment

          • loba17
            Member
            • Sep 2011
            • 19

            #6
            the system was not my choice

            I do have a c compiler an it is :
            gcc version 4.4.6 20120305 (Red Hat 4.4.6-4)

            does this help in anyway?

            Comment

            • gsgs
              Senior Member
              • Oct 2009
              • 139

              #7
              yes, that could work in theory ...

              have you ever successfully compiled a simple C-program ?

              I'll test it (on Windows) and post it here later (or PM or email if you prefer)

              are the 2 files in fasta-format ?

              Comment

              • loba17
                Member
                • Sep 2011
                • 19

                #8
                I guess I would be able to handle compiling a simple C program using:
                gcc infile.c -o outfile

                I have one file with two sequences but I can easily split into two.

                I could also try to compile the lines you send me myself if you could help me with the C formating:

                /* File: merger.c
                Function: Simple program to merge a reference sequence and with another sequence.
                */

                #include <stdio.h>

                void main ()
                {
                m1:a=fgetc(file1);
                b=fgetc(file2);
                if(a=='N')a=b;
                fputc(a,file3);
                if(feof(file1)==0)goto m1;
                }

                ???

                Thanks again for your help!

                Comment

                • gsgs
                  Senior Member
                  • Oct 2009
                  • 139

                  #9
                  /* I'm not sure about Linux, (ascii 10 for end of line rather than
                  ascii 13 and ascii 10 for windows
                  it prints the result, redirect to a file via ">" - piping :
                  loba oldfile.fa ref.fa > newfile.fa

                  fasta-file with one sequence only, same length and lines and aligned to the reference
                  should it also handle multi-sequence-fasta-files ?

                  */


                  #include <stdio.h>
                  int a,b;
                  FILE *file1,*file2;

                  int main(int argc,char*argv[]){
                  if(argc<3){printf("\nusage:loba file1 file2\n\n");
                  printf("replaces N in file1 by what file2 has at that position\n");
                  exit(1);}


                  if((file1=fopen(argv[1],"rb"))==NULL){printf("\ncan't open file %s\n",argv[1]);exit(1);}
                  if((file2=fopen(argv[2],"rb"))==NULL){printf("\ncan't open file %s\n",argv[2]);exit(1);}

                  a=0;while(a!=10){a=fgetc(file1);printf("%c",a);} /* first line printed */
                  a=0;while(a!=10)a=fgetc(file2); /* first line ignored (fasta-format ?)*/

                  m1:;
                  a=fgetc(file1);
                  b=fgetc(file2);
                  if(a=='N')a=b;
                  printf("%c",a);
                  if(feof(file1)==0)goto m1;
                  fclose(file1);fclose(file2);

                  }
                  Last edited by gsgs; 12-17-2012, 05:14 AM.

                  Comment

                  • loba17
                    Member
                    • Sep 2011
                    • 19

                    #10
                    it works - thanks !

                    the compiler finishes with warning but no errors (see below) - I guess that is ok?
                    I tested it and it works now I have to test it with a big file !!

                    Thank you very much for your help !

                    merger.c: In function ‘main’:
                    merger.c:21: warning: incompatible implicit declaration of built-in function ‘exit’
                    merger.c:23: warning: incompatible implicit declaration of built-in function ‘exit’
                    merger.c:24: warning: incompatible implicit declaration of built-in function ‘exit’

                    Comment

                    • gsgs
                      Senior Member
                      • Oct 2009
                      • 139

                      #11
                      if it works, the warnings are no problem
                      maybe it should be exit() instead of exit(1) for your compiler

                      Comment

                      Latest Articles

                      Collapse

                      • SEQadmin2
                        Multiomic Liquid Biopsy: What DNA/RNA Panels Reveal That DNA Alone Can’t
                        by SEQadmin2



                        Tumors contain complex mixtures of cell populations that evolve in response to treatment and host-specific factors. Tissue biopsies provide only static snapshots of a tumor’s state. But what if we could follow that evolution over time using a minimally invasive technique?

                        Liquid biopsies can detect tumor-derived material circulating in the bloodstream, providing a way to study treatment response, detect emerging resistance, and discover new biomarkers. Circulating
                        ...
                        10-14-2026, 09:55 AM
                      • SEQadmin2
                        New Genomics Technologies Take Aim at Long-Standing Limits
                        by SEQadmin2


                        Researchers using sequencing and genomics tools often have to make trade-offs. They can choose between speed or scale, short reads or long-range information, or targeted panels or a view of the whole transcriptome. New technologies that have been released this year are built to address those tough choices.

                        We asked six companies the same four questions to learn about their latest products. The new technologies bring a lot to the table, including rethinking sequencing
                        ...
                        09-28-2026, 10:25 AM

                      ad_right_rmr

                      Collapse

                      News

                      Collapse

                      Topics Statistics Last Post
                      Started by SEQadmin2, 10-22-2026, 11:13 AM
                      0 responses
                      22 views
                      0 reactions
                      Last Post SEQadmin2  
                      Started by SEQadmin2, 10-22-2026, 10:48 AM
                      0 responses
                      19 views
                      0 reactions
                      Last Post SEQadmin2  
                      Started by SEQadmin2, 10-15-2026, 10:52 AM
                      0 responses
                      36 views
                      0 reactions
                      Last Post SEQadmin2  
                      Started by SEQadmin2, 10-14-2026, 05:39 AM
                      0 responses
                      42 views
                      0 reactions
                      Last Post SEQadmin2  
                      Working...