user3295716 user3295716 - 2 months ago 16
Perl Question

Incorporation of AWK in perl



I have a BLAST out file in tab limited format. Like this

p=BAC58264.1 CP014046.1 100.00 435 0 0 1 435 804117 8045 862
p=BAC58264.1 CP014046.1 100.00 160 0 0 3 372 444601 4443 32
p=BAC58264.1 BA000031.2 100.00 435 0 0 1 435 805024 371 862


I want to sort that like this based on the 3rd column

p=BAC58264.1 CP014046.1 100.00 435 0 0 1 435 804117 8045 862
p=BAC58264.1 BA000031.2 100.00 435 0 0 1 435 805024 371 862


I usually did this by this awk code "$4>=435">BLASTSORT

How to incorporate this awk code in a Perl program?

Answer

You would be far better off doing this in Perl, rather than starting a whole new process just for some simple text processing

I would need to see the rest of your Perl code to be sure exactly what the code should look like, but if you're reading a file line by line into a variable called, say, $line, then you could do this

my @fields = split ' ', $line;

print $line if $fields[2] >= 435;

If you want to show your existing Perl code then I will refine this

Comments