Seqanswers Leaderboard Ad

Collapse

Announcement

Collapse
No announcement yet.
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Script Help

    Hello everyone,

    I've been racking my brain trying to create a script to make a certain file, but I have had no success in my attempts.

    I have a file like this:
    Code:
    ACGCCGGCCA
    GTGAATTGTA
    ATACGACTCA
    CTATAGGGCG
    AATTGGGCCC
    TCTAGATG
    All I want to do is to create a file like the following:
    Code:
    1	ACGCCGGCCA
    11	GTGAATTGTA
    21	ATACGACTCA
    31	CTATAGGGCG
    41	AATTGGGCCC
    51	TCTAGATGCA
    61	TGCTCGAGCG
    71	GCCGCCAGTG
    It should be something relatively easy I'm just really missing. I've been trying it using awk, but have had little luck.

    I believe it is basically just this code:
    Code:
    awk '{print NR?????? "\t" $0}'
    I'm just not sure what the ??????????? should be. Any help with this would be great. Thanks in advance.

  • #2
    If it's ok with perl, here's a simple perl one liner:

    Code:
    perl -e ' $pos=1; while(<>) { $line=$_; print "$pos\t$line"; $pos+=10; } ' inputfile.txt > outputfile.txt
    replace inputfile.txt with your file containing your reads, and outputfile.txt with a desired output file name.

    I'm assuming you want the position of the base at the start of every line. You can replace the '10' in the code if you desire another increment. The delimiter here is a tab (\t).

    Comment


    • #3
      I was going to say something very similar to Kennels's answer. If you are going to be doing this kind of thing frequently, Perl is awesome!

      Comment


      • #4
        Here is the awk:

        Code:
        awk -v N=1 '{print N "\t" $0} {N += 10}'

        Comment


        • #5
          Use MS Excel to open the file, insert a column in the front of the data.
          Put 1 in the A1 cell. In cell B1, put the formula =A1+10. Then fill down the column.
          Then save the file as a text file, tab delimited.

          Comment

          Latest Articles

          Collapse

          • seqadmin
            Advancing Precision Medicine for Rare Diseases in Children
            by seqadmin




            Many organizations study rare diseases, but few have a mission as impactful as Rady Children’s Institute for Genomic Medicine (RCIGM). “We are all about changing outcomes for children,” explained Dr. Stephen Kingsmore, President and CEO of the group. The institute’s initial goal was to provide rapid diagnoses for critically ill children and shorten their diagnostic odyssey, a term used to describe the long and arduous process it takes patients to obtain an accurate...
            12-16-2024, 07:57 AM
          • seqadmin
            Recent Advances in Sequencing Technologies
            by seqadmin



            Innovations in next-generation sequencing technologies and techniques are driving more precise and comprehensive exploration of complex biological systems. Current advancements include improved accessibility for long-read sequencing and significant progress in single-cell and 3D genomics. This article explores some of the most impactful developments in the field over the past year.

            Long-Read Sequencing
            Long-read sequencing has seen remarkable advancements,...
            12-02-2024, 01:49 PM

          ad_right_rmr

          Collapse

          News

          Collapse

          Topics Statistics Last Post
          Started by seqadmin, 12-17-2024, 10:28 AM
          0 responses
          33 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 12-13-2024, 08:24 AM
          0 responses
          48 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 12-12-2024, 07:41 AM
          0 responses
          34 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 12-11-2024, 07:45 AM
          0 responses
          46 views
          0 likes
          Last Post seqadmin  
          Working...
          X