Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to replace some digits with letters in each line of a file (according to the letter that exist in column 5th and 6th of that line)?
    text
    copied!<p>I have a file which is space delimited which looks like this:</p> <pre><code>probeset_id submitted_id chr snp_pos alleleA alleleB 562_201 562_202 562_203 562_204 562_205 562_206 562_207 562_208 562_209 562_210 562_211 562_212 562_213 562_214 562_215 562_216 562_217 562_218 562_219 562_220 562_221 562_222 562_223 562_224 562_225 562_226 562_227 562_228 562_229 562_230 562_231 562_232 562_233 562_234 562_235 562_236 562_237 562_238 562_239 562_240 562_241 562_242 562_243 562_244 562_245 562_246 562_247 562_248 562_249 562_250 562_251 562_252 562_253 562_254 562_255 562_256 562_257 562_258 562_259 562_260 562_261 562_262 562_263 562_264 562_265 562_266 562_267 562_268 562_269 562_270 562_271 562_272 562_273 562_274 562_275 562_276 562_277 562_278 562_279 562_280 562_281 562_283 562_284 562_285 562_289 562_291 562_292 562_294 562_295 562_296 562_400 562_401 562_402 562_403 562_404 562_405 AX-75448119 Chr1_41908741 1 41908741 T C 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 1 1 1 1 1 0 1 0 0 0 0 2 2 0 0 0 0 0 1 0 0 0 0 0 AX-75448118 Chr1_41908545 1 41908545 T A 2 2 2 2 2 2 2 2 2 0 0 0 0 0 0 0 0 0 0 0 1 2 2 2 2 2 2 2 2 2 0 0 0 0 0 1 1 0 1 1 0 0 0 0 0 0 1 2 2 2 0 1 1 1 2 -1 1 2 0 0 2 1 1 0 1 0 1 2 1 0 0 1 2 2 1 2 2 0 1 2 2 2 2 2 2 0 1 0 0 0 1 2 2 2 2 0 </code></pre> <p><strong>I want to replace the digits by letters according to column 5th &amp; 6th</strong></p> <ol> <li>Replace <code>0</code> by <code>$5 $5</code> (two repeat of column 5th) e.g if the 5th column is <code>T</code> replace <code>0</code> by <code>T T</code></li> <li>Replace <code>2</code> by <code>$6 $6</code> (two repeat of column 6th) e.g if the 6th column is <code>C</code> replace <code>2</code> by <code>C C</code></li> <li>Replace <code>1</code> by <code>$5 $6</code> e.g if the 5th and 6th columns are <code>T</code> and <code>C</code>, respectively, replace <code>1</code> by <code>T C</code></li> <li>Replace <code>-1</code> by <code>? ?</code> </li> </ol> <p>I have to note that column 5th and 6th can be T, A, C, and G</p> <p>So what I would like to have as output is:</p> <pre><code>AX-75448119 Chr1_41908741 1 41908741 T C T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T C T T T T T T T C T C T C T C T C T C T T T C T T T T T T T T C C C C T T T T T T T T T T T C T T T T T T T T T T AX-75448118 Chr1_41908545 1 41908545 T A A A A A A A A A A A A A A A A A A A T T T T T T T T T T T T T T T T T T T T T T T A A A A A A A A A A A A A A A A A A A T T T T T T T T T T T A T A T T T A T A T T T T T T T T T T T T T A A A A A A A T T T A T A T A A A ? ? T A A A T T T T A A T A T A T T T A T T T A A A T A T T T T T A A A A A T A A A A A T T T A A A A A A A A A A A A A T T T A T T T T T T T A A A A A A A A A T T </code></pre> <p>I don't know if this is possible by awk or not! if not I will give a try in python but I would rather a Linux command like awk (which is much faster than python because I'm using a file which has 1.2 million lines and my computer can swap by python!)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload