Seqanswers Leaderboard Ad
Collapse
Announcement
Collapse
No announcement yet.
X
-
try this
Code:paste - - < input.fa | awk ' { print $1"_"NR"\n"$2 } ' > output.fa
Leave a comment:
-
Thanks. I am pretty weak in Perl. Do you have any idea using AWK to do this?
Leave a comment:
-
Heres another way: R
Code:library(seqinr) read.fasta("fastafile.fa")->fa write.fasta(fa,names=paste(getName(fa),1:5,sep="_"),file.out="fa_new_name.fa")
Leave a comment:
-
Here's one way using Perl. Save the text in a file named numbers.pl (or whatever). Usage would be:
perl numbers.pl --in file_to_change.fasta --out revised_file.fasta
Code:#!/usr/bin/perl use strict; use warnings; use Getopt::Long; my $inFile; my $outFile; GetOptions ("in=s" => \$inFile, "out=s" => \$outFile); if (!$inFile or !$outFile) { die "Must supply both infile and outfile as command line arguments.\n"; } open(my $inFH, "<", $inFile) or die "couldn't open infile for reading.\n"; if (-e $outFile) { die "Output file $outFile already exists--aborting so you don't overwrite.\n"; } open(my $outFH, ">", $outFile) or die "couldn't open outfile for writing.\n"; my $counter = 1; while (my $line = <$inFH>) { chomp $line; if ($line =~ /^(>.*)/) { print $outFH $1 . "_$counter\n"; $counter++; } else { print $outFH "$line\n"; } }
Last edited by atcghelix; 09-26-2013, 09:57 PM. Reason: Edited to move $counter++ so that you didn't just get odd-numbered sequences
Leave a comment:
-
problem with adding numerical sequence at the end of line
Hi,
Anyone has any idea how to get this:
>no_name
TATGCATCGATGCACATATGCTAGTGCGCTAGTGTCGAGGCTAGCTACG
>no_name
GACGTACGTAGCATGCATGCATGCGTAGCTGTAGCTAGC
>no_name
GCTAGCTAGGTAGGTCATGTAGTAGGTGCACTGAGCTAGCTAGCTAGCTAGCAGC
>no_name
GCTAGCATGCTAGCTAGCTAGCACTAGCTAGCTAGCTAGCTAATGCATCATC
>no_name
GCTACGTAGCATGCTAGCGGATCATGCATGCATGCTAGCATCGATGCTAGCATGCAT
become this:
>no_name_1
TATGCATCGATGCACATATGCTAGTGCGCTAGTGTCGAGGCTAGCTACG
>no_name_2
GACGTACGTAGCATGCATGCATGCGTAGCTGTAGCTAGC
>no_name_3
GCTAGCTAGGTAGGTCATGTAGTAGGTGCACTGAGCTAGCTAGCTAGCTAGCAGC
>no_name_4
GCTAGCATGCTAGCTAGCTAGCACTAGCTAGCTAGCTAGCTAATGCATCATC
>no_name_5
GCTACGTAGCATGCTAGCGGATCATGCATGCATGCTAGCATCGATGCTAGCATGCATTags: None
Latest Articles
Collapse
-
by seqadmin
The human gut contains trillions of microorganisms that impact digestion, immune functions, and overall health1. Despite major breakthroughs, we’re only beginning to understand the full extent of the microbiome’s influence on health and disease. Advances in next-generation sequencing and spatial biology have opened new windows into this complex environment, yet many questions remain. This article highlights two recent studies exploring how diet influences microbial...-
Channel: Articles
02-24-2025, 06:31 AM -
ad_right_rmr
Collapse
News
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by seqadmin, 03-03-2025, 01:15 PM
|
0 responses
175 views
0 likes
|
Last Post
by seqadmin
03-03-2025, 01:15 PM
|
||
Started by seqadmin, 02-28-2025, 12:58 PM
|
0 responses
267 views
0 likes
|
Last Post
by seqadmin
02-28-2025, 12:58 PM
|
||
Started by seqadmin, 02-24-2025, 02:48 PM
|
0 responses
652 views
0 likes
|
Last Post
by seqadmin
02-24-2025, 02:48 PM
|
||
Started by seqadmin, 02-21-2025, 02:46 PM
|
0 responses
266 views
0 likes
|
Last Post
by seqadmin
02-21-2025, 02:46 PM
|
Leave a comment: