Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bioman1
    Member
    • May 2012
    • 80

    #1

    Text file editing_perl-GFF

    I would like to get the help of computer experts, in editing my GFF file

    Code:
    ##dsfsd2
    ##sdf-sdf sasg 5.6.3
    gi34_ex Gen  CDS     161     317     .       +       .       Name=Xm ZAK;created by=User
    gi56_ex Gen  CDS     2194    2280    .       +       .       Name=Xm ZAK;created by=User
    gi37_ex Gen  CDS     2848    2951    .       +       .       Name=Xm ZAK;created by=User
    gi37_ex Gen  CDS     4554    4619    .       +       .       Name=Xm ZAK;created by=User
    gi37_ex Gen  CDS     4729    4756    .       +       .       Name=Xm ZAK;created by=User
    gi37_ex Gen  extracted region        1       11677   .       +       .       Name=Extracted region from gi|371443185|gb|JH556675.1|;Extracted interval="1960862 -> 1972538"
    Note that following from third row, the input has 12 ($1 to $12) columns, tab separated. The last line of the file has 16 ($1 to $16) columns, tab separated. ## lines should be ignored.

    I want to take $14 of the last line (interval="1960862) only the number (1960862) add to $4 column (161,2194,2848..4729) i.e (161+1960862=1961023,2194+1960862=1963056..) and to $5 column (317,2280,2951..4756) i.e (317+1960862=1961179,2280+1960862=1963142), ignore the last line.

    The output should look like this:

    Code:
    ##dsfsd2
    ##sdf-sdf sasg 5.6.3
    gi34_ex Gen  CDS     1961023     1961179     .       +       .       Name=Xm ZAK;created by=User
    gi56_ex Gen  CDS     1963056    1963142    .       +       .       Name=Xm ZAK;created by=User
    gi37_ex Gen  CDS     1963710    1963813    .       +       .       Name=Xm ZAK;created by=User
    gi37_ex Gen  CDS     1965416    1965481    .       +       .       Name=Xm ZAK;created by=User
    gi37_ex Gen  CDS     1965591    1965618    .       +       .       Name=Xm ZAK;created by=User
    gi37_ex Gen  extracted region        1       11677   .       +       .       Name=Extracted region from gi|371443185|gb|JH556675.1|;Extracted interval="1960862 -> 1972538"

    I have used perl script as below.But it has some errors, it outputs the same result

    Code:
    #!/usr/bin/perl
    use warnings;
    use strict;
    
    open my $IN, '<', '1.in' or die $!;
    
    my $line;
    $line = $_ while <$IN>;                 # Remember the last line.
    my $last = $.;                          # Remember the number of the last line.
    
    my $interval = (split /\t/, $line)[13]; # Extract the 14th column.
    $interval =~ s/[^0-9]+//;               # Keep only the number.
    
    seek $IN, 0, 0;                         # Rewind to the beginning of the input.
    $. = 0;                                 # Restart the line counter.
    my $start = 1;                          # Flag to skip first lines.
    while (<$IN>) {
        my @columns = split /\t/;
        /^##/ or undef $start;              # Unset start if the header is over.
        if (not ($start or $. == $last)) {  # Not header or last line?
            $_ += $interval for @columns[3, 4];
        }
        print join "\t", @columns;
    }
    Any help in perl is appreciated.

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
53 views
0 reactions
Last Post SEQadmin2  
Started by SEQadmin2, 10-22-2026, 10:48 AM
0 responses
40 views
0 reactions
Last Post SEQadmin2  
Started by SEQadmin2, 10-15-2026, 10:52 AM
0 responses
46 views
0 reactions
Last Post SEQadmin2  
Started by SEQadmin2, 10-14-2026, 05:39 AM
0 responses
46 views
0 reactions
Last Post SEQadmin2  
Working...