Transpose a list based on specific text in ruby -


i have 1 file 1 long list of different patient samples. each sample starts "slx" below: transpose each sample csv output shown below. know csv library might able don't know how approach have transpose when line starting slx matched.

input:

slx.1767356.fdfsih.fq.gz sequences: 160220 index: 139019 sufficient length: 139018 min index: 0 max index: 83 unique: 48932 # reads processed: 48932 # reads @ least 1 reported alignment: 21172 (43.27%) # reads failed align: 27022 (55.22%) # reads alignments suppressed due -m: 738 (1.51%) reported 21172 alignments 1 output stream(s) slx.94373.ghdua_.fq.gz sequences: 28232 index: 24875 sufficient length: 24875 min index: 3 max index: 41 unique: 14405 # reads processed: 14405 # reads @ least 1 reported alignment: 8307 (57.67%) # reads failed align: 5776 (40.10%) # reads alignments suppressed due -m: 322 (2.24%) reported 8307 alignments 1 output stream(s) slx.73837.blabla_control.fq.gz sequences: 248466 index: 230037 sufficient length: 230036 min index: 0 max index: 98 unique: 64883 # reads processed: 64883 # reads @ least 1 reported alignment: 24307 (37.46%) # reads failed align: 39764 (61.29%) # reads alignments suppressed due -m: 812 (1.25%) reported 24307 alignments 1 output stream(s) 

output

slx.10456.fastseqi_control_oc_ah_094.fq.gz  sequences: 160220   index: 139019  sufficient length: 139018   min index: 0    max index: 83   unique: 48932   # reads processed: 48932    # reads @ least 1 reported alignment: 21172 (43.27%)    # reads failed align: 27022 (55.22%)    # reads alignments suppressed due -m: 738 (1.51%)   reported 21172 alignments 1 output stream(s) mv: /volumes/seagatebackupplusdriv1/sequencingrawfiles/tumouroesophagealoccams/metaoccamstumoursrawfiles/lcmdysplasiaandcancer_lcm_ps14_1105_1f/slx.10456.fastseqi_control_oc_ah_094.fq.gz , /volumes/seagatebackupplusdriv1/sequencingrawfiles/tumouroesophagealoccams/metaoccamstumoursrawfiles/lcmdysplasiaandcancer_lcm_ps14_1105_1f/slx.10456.fastseqi_control_oc_ah_094.fq.gz identical slx.10456.fastseqi_control_oc_ed_008_f1_.fq.gz  sequences: 28232    index: 24875   sufficient length: 24875    min index: 3    max index: 41   unique: 14405   # reads processed: 14405    # reads @ least 1 reported alignment: 8307 (57.67%) # reads failed align: 5776 (40.10%) # reads alignments suppressed due -m: 322 (2.24%)   reported 8307 alignments 1 output stream(s)   slx.10456.fastseqj_oc_ah_086_f1_control.fq.gz   sequences: 248466   index: 230037  sufficient length: 230036   min index: 0    max index: 98   unique: 64883   # reads processed: 64883    # reads @ least 1 reported alignment: 24307 (37.46%)    # reads failed align: 39764 (61.29%)    # reads alignments suppressed due -m: 812 (1.25%)   reported 24307 alignments 1 output stream(s)  

ok, it’s easy post answer.

input.scan(/^slx.*?(?=^slx|\z)/m)      .map { |p| p.split($/).map { |e| %q|"#{e}"| }.join (', ') }      .join($/) 

Comments