Enlightened Monks, I am writing to you today so that your wisdom may flow through me. I am working with a small problem that is a part of a larger string of programs.
The objective is to write a simple(<10 lines) script that will combine Maternal and Paternal strings into a new string:
1) Open my Table File, and skip the first line in the table as it is unnecessary for the task.
2) Read my file that is shown below two lines at a time(i guess). The Lines are IDed Maternal and Paternal strings of 0s and 1s.
3) Combine the the same ID strings by adding the 0s and 1s creating a new string.
4) Lastly I want to only keep and store the combined> and labeled strings that have 0s and 2s only, no 1s in the string.
THIS IS A SMALL PORTION OF THE FILE I AM WORKING WITH:
INDIV 16051347(G-C) 16051497(A-G) 16052239(A-G) 16052513(G-C) + 16052618(G-A) 16053659(A-C) 16054667(C-G) HG00096.M 0 0 0 1 1 1 1 + 1 0 0 0 0 0 HG00096.P 0 0 1 0 0 0 0 + 1 0 0 0 0 0 HG00097.M 1 1 0 0 0 0 0 + 0 0 0 0 1 0 HG00097.P 0 0 1 0 0 1 0 + 1 1 1 0 0 0 HG00099.M 1 1 0 0 0 0 0 + 0 0 0 0 0 0 HG00099.P 0 0 0 0 1 1 0 + 0 1 1 0 1 0 HG00100.M 0 0 1 1 1 1 1 + 1 1 1 1 1 1 HG00100.P 1 1 0 0 0 1 0 + 0 1 1 0 1 0 HG00101.M 1 1 0 0 0 1 0 + 0 1 1 0 1 0 HG00101.P 0 0 1 1 1 1 1 + 1 1 1 1 1 0 HG00102.M 1 1 0 0 0 0 0 + 0 0 0 0 1 0 HG00102.P 0 0 1 0 0 1 0 + 1 1 1 0 1 0
SO FOR 102 THE NEW STRING WOULD BE ONE I WOULD NOT WANT TO KEEP AS IT HAS 1s
1 1 1 0 0 1 0 1 1 + 1 0 1 0
THIS IS WHAT I CAME UP WITH SO FAR BUT ITS VERY INCOMPLETE SO PLEASE HELP ME BROTHERS
@add = (); open (TA, "Table_C22-17") || die "Can't open file"; while (<TA>) { $c++; if ($c > 1) {$count++; @a = split /\t/,$_; chop ($a[0]); for $x (0..$#a) { if ($count <= 2) { $add[$x] += $a[$x]; push (@tl, $add[$x]); next; } } } } $count = 0; print "@tl\n";
In reply to SEEKING HELP by A1 Transcendence
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |