Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • uqfgaiti
    Member
    • Nov 2012
    • 13

    #1

    print first occurence of a line

    Hi all,

    I extracted ORFs from a initial fasta file and now I want to get the longest ORF for each transcript.

    After having extracted the size of the ORFs with faSize and sorted them by size, the code I was used to use is:

    Code:
    perl -ane'print unless $x{$F[0]}++'
    This time I have a problem using the perl command.

    After having extracted the size and sorted the transcripts I have something like this:

    Code:
        Singlet_1000_61 3844
    
        Singlet_2000_73 3508
    
        Singlet_1000_62 3081
    
        Singlet_2000_62 3008
    
        Singlet_3500_48 2973
    
        Singlet_4000_48 2964
    
        Singlet_3500_54 2863
    
    What I want is:
    
        Singlet_1000_61 3844
    
        Singlet_2000_73 3508
    
        Singlet_3500_48 2973
    ...

    The perl command is not working in this case.

    Do you have any suggestions on how I can make it work?

    Or a awk command?

    Thanks for help
  • bruce01
    Senior Member
    • Mar 2011
    • 160

    #2
    Try stackoverflow.com, they love this sort of thing, but put your thick-skin on.

    Comment

    • westerman
      Rick Westerman
      • Jun 2008
      • 1104

      #3
      Or, as a hint, use a hash to keep track of if a transcript has been printed or not. Hashes are a wonderful data structure to know about.

      Comment

      • syfo
        Just a member
        • Nov 2012
        • 103

        #4
        I don't get it. What do the numbers in your input refer to? If the first one is the ID of the transcript and the last one the length I would do

        Code:
        tac list | awk -F "_" '{t[$2]=$0}END{for (i in t)print t[i]}'
        If the ID of each transcript is the first column then it is even simpler

        Code:
        tac list | awk '{t[$1]=$0}END{for (i in t)print t[i]}'
        Pipe sort the output if needed.
        Since you already sorted them by size the script starts by the end (tac) and only remembers the last occurrence of each ID.

        Comment

        Latest Articles

        Collapse

        • SEQadmin2
          16S/ITS Profiling vs. Shotgun Metagenomics: What Changes in Your Workflow?
          by SEQadmin2




          NGS has revolutionized clinical microbiology by offering new ways to identify and surveil pathogens without prior knowledge of the target. One popular approach is 16S rRNA and ITS amplicon sequencing, which targets specific microbial markers. But studies are increasingly incorporating shotgun metagenomics, a technique that sequences all DNA from a sample without targeting specific microbial markers. This approach allows more detailed taxonomic classification, detection...
          Today, 06:46 AM
        • 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

        ad_right_rmr

        Collapse

        News

        Collapse

        Topics Statistics Last Post
        Started by SEQadmin2, 10-28-2026, 09:57 AM
        0 responses
        24 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 10-28-2026, 09:51 AM
        0 responses
        15 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 10-22-2026, 11:13 AM
        0 responses
        68 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 10-22-2026, 10:48 AM
        0 responses
        48 views
        0 reactions
        Last Post SEQadmin2  
        Working...