oushujun / LTR_retriever

LTR_retriever is a highly accurate and sensitive program for identification of LTR retrotransposons; The LTR Assembly Index (LAI) is also included in this package.
https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5813529/
GNU General Public License v3.0
188 stars 40 forks source link

A bug in solo_intact_ratio.pl #110

Closed xie-wei-hh closed 1 year ago

xie-wei-hh commented 2 years ago

There may be a bug for the script solo_intact_ratio.pl. The intact LTR count always less 1 than the real count.

I fixed it like:

!/usr/bin/perl -w

use strict; use 5.010;

compute solo-intact LTR ratio for given lists

Shujun Ou (oushujun@msu.edu)

07-25-2017

update: 04/16/2019

my $usage="\n\tperl solo_intact_ratio.pl solo_list intact_list > solo_intact_ratio\n To make solo and intact lists: perl solo_finder.pl RepeatMasker.out > solo_list perl intact_finder_coarse.pl RepeatMasker.out > intact_list\n\n";

open Solo, "<$ARGV[0]" or die $usage; open Intact, "<$ARGV[1]" or die $usage;

my %intt; #intact my @ids=();

while (){ chomp; s/^\s+//; my $id=(split)[0]; $intt{$id}++; #count intact number push @ids, $id unless ($id~~@ids) } close Intact;

my %solo; #solo while (){ chomp; s/^\s+//; my $id=(split)[0]; $solo{$id}++; #count solo number if($id~~@ids){}else{push @ids, $id} } close Solo;

print "LTR_fam\tSolo_count\tIntact_count\tSolo-Intact-ratio\n"; my $ttlsolo=0; #total solo; my $ttlintt=0; #total intact; foreach my $id (sort {$a cmp $b} @ids){ my $ratio="NA"; if(!exists $solo{$id}){$solo{$id}=0;}; $intt{$id}=0 if (!exists $intt{$id}); my ($solo, $intact)=($solo{$id}, $intt{$id}); $ttlsolo += $solo; $ttlintt += $intact; if ($intact==0){ $ratio="NA"; #no intact LTR found for this family } elsif ($solo==0){ $ratio=0; } else { $ratio=sprintf ("%.2f", $solo/$intact); } print "$id\t$solo\t$intact\t$ratio\n"; } printf "summary\t$ttlsolo\t$ttlintt\t%.2f\n", $ttlsolo/$ttlintt;

oushujun commented 2 years ago

Hello @xie-wei-hh,

Sorry for the long delay. Thank you for helping to improve LTR_retriever! The code you provided is malformatted, can you please attach it as a separate file? You may use .txt instead of .pl to bypass the github requirement.

Best, Shujun

xie-wei-hh commented 2 years ago

Ok, I attached it here.

oushujun commented 2 years ago

Hello @xie-wei-hh,

Did you forget to attach the file? Thanks!

Shujun

xie-wei-hh commented 2 years ago

Hello, @oushujun Sorry, I didn't find the attach approach, so I wrongly attached it with e-mail. I find it now, as below: solo_intact_ratio.imroved.by.xw.txt

oushujun commented 1 year ago

fixed in a85acd1