Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MoGo
    Junior Member
    • Apr 2015
    • 2

    #1

    awk script to print a set of target sequences to same file

    I have a folder with sample files (81 total .fasta) from a barcoded MiSeq run.

    Each sample file contains consensus sequences for up to 53 targets.

    The .fasta is organized so that name ">" corresponds to locus (AT#G######), followed by the consensus sequence. I need to search all sample files (from 81 total taxa) and create new .fasta files for each locus lists the name of the taxon, followed by the locus consensus sequence for each locus.

    With some help from stackexchange, I have a script that does this beautifully. I've now encountered only one hang-up. The new locus .fasta files are not merged for each taxon, so I get a .fasta for locus ATXGXXXXX for Sample_1 only, a separate .fasta for Sample_2 for the same locus, and so on and so forth for all samples. I can't seem to find a command to merge all Sample sequences for locus ATXGXXXXXX into the same .fasta.

    Here is the script:
    awk '
    FNR==1 { sample = FILENAME ; sub(/\.fasta/, "", sample )}
    /^>/ { target = substr($0,2)".fasta" ; next }
    { print items ">" sample > target ; print > target; close(target) }
    ' C_*.fasta
    Does anyone have any thoughts?
  • MoGo
    Junior Member
    • Apr 2015
    • 2

    #2
    Got it sorted out. It's a nifty little script if anyone needs to batch sort multilocus target consensus files from Geneious Export to a new .fasta for per-locus alignment. Huge thanks to Janis at Stackexchange for that one!

    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
    23 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...