Question: Want Help regarding Text parsing.
0
gravatar for gsk1185
3.0 years ago by
gsk118520
gsk118520 wrote:

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 • 555 views
ADD COMMENTlink modified 3.0 years ago by Pierre Lindenbaum134k • written 3.0 years ago by gsk118520
2

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 REPLYlink written 3.0 years ago by WouterDeCoster45k

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 REPLYlink written 3.0 years ago by Joe18k

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 REPLYlink modified 3.0 years ago • written 3.0 years ago by gsk118520
2
gravatar for Pierre Lindenbaum
3.0 years ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum134k wrote:
 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 COMMENTlink written 3.0 years ago by Pierre Lindenbaum134k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1377 users visited in the last hour
_