I have a DNA file like below and I am able to write a short program which finds/not an input motif, but I dont understand how I can include in the code to report which position the motif was found. Example I want to find the first or all "GAT" motifs and want the program to report which position (beginning to end) of the dna motif was found. So in this example GAT (in bold should report 10-12) and if found more than once the other positions too. Can someone explain how to report matching position on strings ??
@Bartus11
Here comes again another one of your amazing one-liners ... could you please comment on the code Here are the parts which I think I understand: Correct me if I'm wrong please
$x="GAT" store name of query in $x
s/>.*// substitute > followed by anything on the first line with nothing, meaning ignore first line
s/\n//g remove new lines globally (but doesnt -l option do this automatically??)
The rest of it I didnt understand, please could you explain?
-l "chomps" $_ variable, meaning it removes only last newline. To remove newlines that are inside of the input string, s// has to be used.
This is a bit tricky piece. It is matching sequentially on $_ variable, and when match is found, the body of while loop is executed. So for each match in a string, the code of while's body will be executed. print ((length $1) + 1 + $sumIt will print starting position of the searched pattern. It is achieved by getting the number of characters before that string - length $1 ($1 stores match of the red part in regular expresion). To make it possible to print subsequent positions (after first match), the number of characters from the beginning of the string has to be saved. It is done by $sum. ((length $&) + $sum)This will calculate ending position of pattern to search ($& is a variable containing whole string matched by the regex, so length $& will get number of characters before searched pattern + length of that pattern. $sum+=length $&As I wrote before, $sum is saving the number of characters that regex already passed through.
I am using bash in Fedora 30
From the below lines (ls -l output), how can I print whatever is between the strings 'status_' and '.log'
$ ls -l | grep -i status
-rw-rw-r--. 1 sysadmin sysadmin 378530 Nov 11 21:58 status_vsbm1.log
-rw-rw-r--. 1 sysadmin sysadmin 428776 Nov 11 21:58... (8 Replies)
I am not an expert with linux, but following various posts on this forum, I have been trying to write a script to match pattern of charters occurring together in a file.
My file has approximately 200 million characters (upper and lower case), with about 50 characters per line. I have merged all... (5 Replies)
i have a requirement like this
if the line contains from position 294 to 299 is equal to "prabhu" ,then print entire line .
i want to use awk
awk '{if(substr(294-299) == 'prabhu') print "line" }' filename (1 Reply)
HI All,
am trying to find the position of space in a variable, it is working for other characters other than space
ulab="ulab1|ulab2"
find_pos=`expr index $ulab '|'`
echo $find_pos
above code worked fine but below one says syntax error
ulab="ulab ulab2"
find_pos=`expr index $ulab ' '`... (2 Replies)
Hi,
I need to search for some strings in specific positions in a file.
If the strings: "foo1", "foo2" or "foo3" is on position 266 or position 288 in a file i want the whole line printed.
Any idea how to do it? (5 Replies)
Hello,
I would like to find an efficient way to compare a pair of strings that differ at one position, and return the difference and position.
For example:
String1 123456789
String2 123454789
returning something - position 6, 6/4
Thanks in advance,
Mike (5 Replies)
Hi,
I have this input file called ttbitnres (which is catenated and sorted):-
8 0.4444 213
10 0.5555 342
11 0.5555 321
12 0.5555 231
13 0.4444 400
My code is at :-
#!/bin/bash
echo -e Version "\t" Number of Pass "\t" Number of Fail "\t" Rank Position "\t"Min "\t" Max... (1 Reply)
Hi,
I have a challenging task,in which i have to find the duplicate files by its name and size,then i need to take anyone of the file.Then i need to open the file and find for more than one pattern and count of that pattern.
Note:These are the samples of two files,but i can have more... (2 Replies)
Hi,
I need to insert strings "0000 00" at the each line within the file.
The postion is 37 to 42.
ex.
name1 name2 0000 00
nam name 0000 00
The "0000 00" in two lines should be lined up.
I don't know why it's not lined up when I posted it.
Can anyone help? (14 Replies)