Want Help regarding Text parsing.
1
0
Entering edit mode
6.7 years ago
gsk1185 ▴ 20

I Have a file Like This

chr1    11873,12612,13220,  12227,12721,14409,
chr1    14361,14969,15795,16606,    14829,15038,15947,16765,
chr1    69090,  70008,

Want to convert it into file like this

chr1    11873   12227
chr1    12612   12721
chr1    13220   14409
chr1    14361   14829
chr1    14969   15038
chr1    15795   15947
chr1    16606   16765
chr1    69090   70008

Any Awk or cut command i can use here to get the output?

awk Text • 1.0k views
ADD COMMENT
2
Entering edit mode

I added code markup to your post for increased readability. You can do this by selecting the text and clicking the 101010 button. When you compose or edit a post that button is in your toolbar, see image below:

101010 Button

Also, please select sensible tags. These are meaningless.

Finally: it's hugely appreciated if you show your own effort when asking questions. Don't make us give you a full solution without working on this yourself.

ADD REPLY
0
Entering edit mode

I can't quite work out what the 'rules' you're trying to apply are.. do you just want the string chr1 inserted before each pair of numbers? Though it looks like some numbers need to be dropped and not others.

ADD REPLY
0
Entering edit mode

Sorry, text output looking weird . Not looking like what i want. So i have one file having three coloumns.

1. Chrmosome
2. Start 1 ,Start 2,Start 3 ++
3. END1,END2,END3 ++

want in format like Three coloumns

Chr Start1  END1
Chr Start2  END2
ADD REPLY
2
Entering edit mode
6.7 years ago
 awk '{n=split($2,a,/[,]/);split($3,b,/[,]/);for(i=1;i<=n;i++) if(a[i]!="") printf("%s\t%s\t%s\n",$1,a[i],b[i]);}' input.txt
ADD COMMENT

Login before adding your answer.

Traffic: 2639 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6