SEQanswers

Go Back   SEQanswers > Bioinformatics > Bioinformatics



Similar Threads
Thread Thread Starter Forum Replies Last Post
gatk python script m_elena_bioinfo Bioinformatics 7 11-20-2011 06:40 AM
just perl script semna Bioinformatics 3 07-02-2011 08:42 AM
perl script bioenvisage Bioinformatics 5 02-01-2010 08:11 AM
perl script bioenvisage Bioinformatics 0 02-01-2010 07:23 AM
Perl script bioenvisage Bioinformatics 4 01-28-2010 12:25 PM

Reply
 
Thread Tools
Old 07-14-2011, 06:05 PM   #1
DrD2009
Member
 
Location: Kansas City

Join Date: Oct 2009
Posts: 88
Default 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.
DrD2009 is offline   Reply With Quote
Old 07-14-2011, 08:56 PM   #2
Kennels
Senior Member
 
Location: Sydney

Join Date: Feb 2011
Posts: 149
Default

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).
Kennels is offline   Reply With Quote
Old 07-15-2011, 07:22 AM   #3
oiiio
Senior Member
 
Location: USA

Join Date: Jan 2011
Posts: 105
Default

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!
oiiio is offline   Reply With Quote
Old 07-15-2011, 08:02 AM   #4
cliffbeall
Senior Member
 
Location: Ohio

Join Date: Jan 2010
Posts: 144
Default

Here is the awk:

Code:
awk -v N=1 '{print N "\t" $0} {N += 10}'
cliffbeall is offline   Reply With Quote
Old 07-15-2011, 08:17 AM   #5
kwatts59
Member
 
Location: nevada

Join Date: Apr 2011
Posts: 46
Default

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.
kwatts59 is offline   Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off




All times are GMT -8. The time now is 11:41 PM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Single Sign On provided by vBSSO