Skip to content

Commit

Permalink
member/supp file fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Ondov committed Jul 20, 2016
1 parent 4b3f6f7 commit 301bfac
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 21 deletions.
46 changes: 26 additions & 20 deletions KronaTools/lib/KronaTools.pm
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ BEGIN
my $taxonomyDir = $libPath;
$taxonomyDir =~ s/lib$/taxonomy/;
my $ecFile = "$libPath/../data/ec.tsv";
my $useMembers; # set by addMember()

# public subroutines
#
Expand Down Expand Up @@ -222,14 +223,14 @@ our %argumentDescriptions =
(
'blast' =>
'File containing BLAST results in tabular format ("Hit table (text)" when
downloading from NCBI). If running BLAST locally, subject IDs in the local
downloading from NCBI). If running BLAST locally, subject IDs in the local
database must contain accession numbers, either bare or in the fourth field of
the pipe-separated ("gi|12345|xx|ABC123.1|") format.',
'magnitude' =>
'Optional file listing query IDs with magnitudes, separated by tabs. This can
'Optional file listing query IDs with magnitudes, separated by tabs. This can
be used to account for read length or contig depth to obtain a more accurate
representation of abundance. By default, query sequences without specified
magnitudes will be assigned a magnitude of 1. Magnitude files for assemblies in
representation of abundance. By default, query sequences without specified
magnitudes will be assigned a magnitude of 1. Magnitude files for assemblies in
ACE format can be created with ktGetContigMagnitudes.',
'metarep' =>
'Unpacked METAREP data folder.',
Expand Down Expand Up @@ -696,17 +697,18 @@ sub addXML

my $fileMembers = "$file.files/$members[$i]";

open MEMBERS, $fileMembers or die "Could not open $fileMembers";

while ( <MEMBERS> )
if ( open MEMBERS, $fileMembers )
{
if ( /(data\(')?(.+)\\n\\/ )
while ( <MEMBERS> )
{
push @{$node->{'members'}[$dataset + $i]}, $2;
if ( /(data\(')?(.+)\\n\\/ )
{
addMember($node, $dataset + $i, $2);
}
}
}

close MEMBERS;
close MEMBERS;
}
}
}

Expand All @@ -720,7 +722,7 @@ sub addXML

for ( my $i = 0; $i < @members; $i++ )
{
push @{$node->{'members'}[$dataset + $offset]}, $members[$i];
addMember($node, $dataset + $offset, $members[$i]);
}

$offset++;
Expand Down Expand Up @@ -1193,7 +1195,7 @@ sub getTaxIDFromAcc

if ( ! open ACC, "<$options{'taxonomy'}/$fileTaxByAcc" )
{
print "ERROR: Sorted accession to taxID list not found. Was updateAccessions.sh run?\n";
print "ERROR: Sorted accession to taxID list not found. Was updateAccessions.sh run?\n";
exit 1;
}

Expand Down Expand Up @@ -1746,14 +1748,17 @@ sub writeTree
my $totalCount;
my $supp;
#
foreach my $count ( @{$tree->{'count'}} )
if ( $useMembers )
{
$totalCount += $count;

if ( $count > $memberLimitDataset || $totalCount > $memberLimitTotal )
foreach my $count ( @{$tree->{'count'}} )
{
$supp = 1;
last;
$totalCount += $count;

if ( $count > $memberLimitDataset || $totalCount > $memberLimitTotal )
{
$supp = 1;
last;
}
}
}

Expand Down Expand Up @@ -1818,6 +1823,7 @@ sub addMember
# $member =~ s/"/&quot;/g;

push @{$node->{'members'}[$set]}, $member;
$useMembers = 1;
}

sub argumentString
Expand Down Expand Up @@ -1905,7 +1911,7 @@ sub dataHeader
my $assignedText;
my $summaryText;
#
if ( $assignedName && $summaryName )
if ( $assignedName && $summaryName && $useMembers )
{
my $memberTag = $supp ? 'data' : 'list';
my $suppDir = basename($options{'out'}) . $suppDirSuffix;
Expand Down
1 change: 1 addition & 0 deletions KronaTools/scripts/GetTaxIDFromAcc.pl
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ BEGIN
Fasta tag example:
grep ">" sequence
Options:
-p Prepend tax IDs to the original lines (separated by tabs).
Expand Down
2 changes: 1 addition & 1 deletion KronaTools/scripts/GetTaxInfo.pl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ BEGIN
Command line example:
ktGetTaxInfo A00001.1 "gi|2|emb|A00002.1|" 9606
ktGetTaxInfo A00001.1 "gi|2|emb|A00002.1|" 9606
Fasta tag example:
Expand Down

0 comments on commit 301bfac

Please sign in to comment.