I will post back tomorrow morning when I get back in. Thank you .
---------- Post updated 10-21-16 at 10:10 AM ---------- Previous update was 10-20-16 at 06:07 PM ----------
In the code below (except for the portion in bold), $2 from file , in a range search using $2 and $3 in file1 . If the search key from file is found in file1 , then the word low is printed in the last field of that line in the updated file . Only the last section of file, Missing in IDP but found in Reference: and only the lines in this section are searched .
The portion in bold was an attempt to add a line that will add Not low if the statement in bold is not true or meet. I guess when the first if statement is true/meet then print low , otherwise print Not low in $(NF + 1) . I am not sure how to correctly add this. Thank you .
file
Code:
Match:
chr15 68521889 C T exonic CLN6 GOOD 50 het 4
chr7 147183143 A G intronic CNTNAP2 GOOD 382 het 22
Missing in Reference but found in IDP:
chr2 51666313 T C intergenic NRXN1,NONE GOOD 108 het 7
chr2 166903445 T C exonic SCN1A GOOD 400 het 28
Missing in IDP but found in Reference:
2 166210776 C T exonic SCN2A c.[2994C>T]+[=] 3095 23.1 24.56
7 148106478 - GT intronic CNTNAP2 c.3716-5_3716-4insGT 4168 28.6 51.01
Match:
chr15 68521889 C T exonic CLN6 GOOD 50 het 4
chr7 147183143 A G intronic CNTNAP2 GOOD 382 het 22
Missing in Reference but found in IDP:
chr2 51666313 T C intergenic NRXN1,NONE GOOD 108 het 7
chr2 166903445 T C exonic SCN1A GOOD 400 het 28
Missing in IDP but found in Reference:
2 166210776 C T exonic SCN2A c.[2994C>T]+[=] 3095 23.1 24.56 Not Low
7 148106478 - GT intronic CNTNAP2 c.3716-5_3716-4insGT 4168 28.6 51.01 Low
Code:
#!/bin/bash
for file in /home/cmccabe/Desktop/concordance/comparison/update/*.txt ; do
file1=${file##*/} # Strip off directory
getprefix=${file1%%_*.txt}
file1=$(printf '%s\n' "/home/cmccabe/Desktop/concordance/low/${file1%%_*.txt}_"*.txt) # look for matching file
if [[ -f "$file1" ]]
then
TmpFile=${0##*/}.$$
awk '
BEGIN { # Set input and output field separators...
OFS = "\t"
}
NR == FNR {
# Grab low and high ends of ranges from the 1st input file...
low[++c] = $2
high[c] = $3
next
}
sect == 3 {
# We are in the 3rd section of the 2nd input file (after the section
# header line)...
# Look for a range of vaues from a line in the 1st file that includes
# the 2nd field in this file...
for(i = 1; i <= c; i++)
if(low[i] <= $2 && $2 <= high[i]) {
# Match found, add field and break out of loop.
$(NF + 1) = "low"
Else
if(low[i] = $2 && $2 = high[i]) {
# No match found, add field and break out of loop.
$(NF+1) = "no low"
fi
break
}
}
/:$/ { # Increment the 2nd input file section number when we find a colon at
# the end of a line...
sect++
}
1 # print the current contents of the 2nd file input line.
' $file1 $file > "$TmpFile" && # End awk script, specifying input files and
# redirect the output to a temp file...
cp "$TmpFile" $file && # If the awk script was successful, copy the
# temp file back to the 2nd input file...
rm "$TmpFile" # and, if that was also successful, remove the
# temp file.
fi
done
I am having trouble figuring this code
I want to grep a text from a file and if it match certain text it break out of the loop or it should continue searching for the text
Here is what I have written but it isn't working
while true
f=`grep 'END OF STATUS REPORT' filename`
do
if ... (9 Replies)
Hello all, I created the below script....and it seemed to be working fine. My problem is i want the script to ignore rest of the things if my condition is not met but do not exit....
#!/bin/ksh
###########################
###########################
# Set name of the listener, this... (2 Replies)
All,
I wrote the following section of code (which logically in PHP would of worked):
tmpPATH=${1}
tmpTAG=${2}
if
then
while read tmpTAG tmpPATH
do
fi
echo $tmpTAG
echo $tmpPATH
if
then
done < ./config.cfg
fi (4 Replies)
Hello All,
I am in the process of learning perl.I have a perl script and based on the arguments passed it would the appropriate subroutine that is defined in the script.
Now, I need to check a value that is defined in the Environment variables and should call the subroutine only if the... (1 Reply)
i have a table like this:
id, senderNumber, blacklist
-----------------------------
1 0835636326 Y
2 0373562343 Y
3 0273646833 Y
and I want to delete automatically if a new inserted row on another table consist anything on senderNumber column above using a BASH Script
I... (9 Replies)
I want to abort script if input variable matched first field in any line of a file.
#!/bin/sh
read INPUTVAR1
awk "{if(\$INPUTVAR1 == $1) x = 1} END {if(x==1) print \"I want to abort script here\"; else print \"OK\"}" /etc/some.conf
I tried "exit" and system("exit") but no luck. (1 Reply)
Hi All,
Seeking for your assistance to print all the specific field when the condition met.
Ex:
file1.txt
1|203|3|31243|5341|6452|623|22|00|01
3|45345|123214|6534|3423|6565|643|343|232|10
if field 1 = 1 and field 3 = 3 and field 5 = 5341 and field 6 = 6452
it will print from $1 to $10.... (2 Replies)
Hi All,
Seeking for your assistance to get the records once the $2 met the condition.
Ex. file 1.txt
123455,10-Aug-2020 07:33:37 AM,2335235,1323534,12343
123232,11-Aug-2015 08:33:37 PM,4234324,1321432,34364
Output:
123455,10-Aug-2020 07:33:37 AM,2335235,1323534,12343
What i did... (5 Replies)
Hi All,
Seeking for your assistance on how to append the specific string when $3 condion met.
ex. file1.txt
ar0050046b16,5,888,0,0,0,0.00,0.00,0.00,0.00,25689.55
ar0050046b16,5,0,0,0,0,0.00,0.00,0.00,0.00,25689.55
ar0050046b16,5,0,0,0,0,0.00,0.00,0.00,0.00,25689.55
expected output:... (5 Replies)
I have a file.txt containing the following:
Query= HWI-ST863:386:C5Y8UACXX:3:2302:16454:89688 1:N:0:ACACGAAT
Length=100
Score E
Sequences producing significant alignments: (Bits) Value
... (2 Replies)