| 1 |
#! /usr/bin/perl |
| 2 |
|
| 3 |
# github issue X - search/scan pipeline truncated (FORCE) passes allow hits |
| 4 |
# that do not include first/final nucleotide in sequence |
| 5 |
# |
| 6 |
# EPN, Thu Feb 23 12:00:29 2023 |
| 7 |
# |
| 8 |
|
| 9 |
$usage = "perl iss33-trunc-pipeline.pl <cmsearch> <path to iss33.cm> <path to iss33.fa>\n"; |
| 10 |
if ($#ARGV != 2) { die "Wrong argument number.\n$usage"; } |
| 11 |
|
| 12 |
$cmsearch = shift; |
| 13 |
$cmfile = shift; |
| 14 |
$seqfile = shift; |
| 15 |
$ok = 1; |
| 16 |
|
| 17 |
if ($ok) { |
| 18 |
$output = `$cmsearch --fmt 3 --cpu 0 -T 40 --toponly --rfam --tblout iss33.tbl $cmfile $seqfile > /dev/null`; |
| 19 |
if ($? != 0) { $ok = 0; } |
| 20 |
|
| 21 |
# we need to parse the tblout file to determine if the truncated hits are valid |
| 22 |
# PRGG01000010.1 L=1975 |
| 23 |
# with bug: 3' truncated hit from 498..1955 |
| 24 |
# without bug: 3' truncated hit from 498..1975 |
| 25 |
# QYUU01000014.1 L=1370 |
| 26 |
# with bug: 5' truncated hit from 2..1170 |
| 27 |
# without bug: 5' truncated hit from 1..1170 |
| 28 |
# BMWJ01000078.1 L=804 |
| 29 |
# with bug: 5'&3' truncated hit from 616..804 |
| 30 |
# without bug: 3' truncated hit from 475..804 |
| 31 |
if(open(IN, "iss33.tbl")) { |
| 32 |
$ok = 1; # set to 0 below if we see any incorrectly truncated hits |
| 33 |
while($line = <IN>) { |
| 34 |
chomp $line; |
| 35 |
if($line !~ m/^\#/) { |
| 36 |
##target name accession query name accession mdl mdl from mdl to seq from seq to strand trunc pass gc bias score E-value inc mdl len seq len description of target |
| 37 |
##-------------------------------- --------- -------------------- --------- --- -------- -------- -------- -------- ------ ----- ---- ---- ----- ------ --------- --- ------- ------- --------------------- |
| 38 |
#gi|1687014738|gb|PRGG01000010.1| - LSU_rRNA_bacteria RF02541 cm 1 1750 498 1955 + 3' 3 0.47 25.3 519.6 2.9e-174 ! 2925 1975 Acinetobacter baumannii strain AB-HZ-S15 sp_sm_15_ctg010_1975, whole genome shotgun sequence |
| 39 |
@el_A = split(/\s+/, $line); |
| 40 |
($seq_from, $seq_to, $strand, $trunc, $seq_len) = ($el_A[7], $el_A[8], $el_A[9], $el_A[10], $el_A[18]); |
| 41 |
if($strand ne "+") { |
| 42 |
$ok = 0; # all hits should be on the positive strand |
| 43 |
} |
| 44 |
if(($trunc eq "5'") || ($trunc eq "5'&3'")) { |
| 45 |
if($seq_from != 1) { |
| 46 |
$ok = 0; |
| 47 |
} |
| 48 |
} |
| 49 |
if(($trunc eq "3'") || ($trunc eq "5'&3'")) { |
| 50 |
if($seq_to != $seq_len) { |
| 51 |
$ok = 0; |
| 52 |
} |
| 53 |
} |
| 54 |
} |
| 55 |
} |
| 56 |
close(IN); |
| 57 |
} |
| 58 |
else { # open(IN, "iss33.tbl") failed |
| 59 |
$ok = 0; |
| 60 |
} |
| 61 |
} |
| 62 |
|
| 63 |
foreach $tmpfile ("iss33.tbl") { |
| 64 |
unlink $tmpfile if -e $tmpfile; |
| 65 |
} |
| 66 |
|
| 67 |
if ($ok) { print "ok\n"; exit 0; } |
| 68 |
else { print "FAILED\n"; exit 1; } |
| 69 |
|
| 70 |
|