{"text_format":"3","workbook":"xls","n_sheets":1,"sheets":["03a.parse.classifier"],"read":"whole","date_system":"1900","formulas":"cached_only"}

{"sheet":"03a.parse.classifier","index":0,"n_rows":44,"n_cols":3,"rows_kept":44,"flags":["formulas_cached_only"]}
["Table 1S. Script used for parsing and collecting metagenomic data "]
[]
["#!/usr/bin/perl"]
["use strict;"]
["#use warnings;"]
["use Data::Dumper;"]
["#use Data::Dump::Streamer;"]
["die \"$0 [input file] [output file]\\n\\n\" if (@ARGV != 2);"]
["my $infile = $ARGV[0];"]
["my $outfile = $ARGV[1];"]
["open (IN, $infile) || die \"non apro $infile\\n\\n\";"]
["my @taxonomy = qw(domain phylum subphylum class subclass order suborder family subfamily genus);"]
["print \"Parsing $infile..\\n\";"]
["my $data;"]
["my $seen;"]
["while (<IN>) {"]
[null,"$_ =~s/\\n|\\r//g;"]
[null,"$_ =~s/\\\"//g;"]
[null,"my @e = split(/\\t/, $_);"]
[null,"my $dataname;"]
[null,"my $localdata;"]
[null,"for (my $c = 6; $c <= scalar(@e); $c+=3) {"]
[null,null,"my $taxon = $e[$c];"]
[null,null,"my $value = $e[$c-1];"]
[null,null,"$localdata->{$taxon} = $value;"]
[null,"}"]
[null,"my $dataname;"]
[null,"foreach my $taxon (@taxonomy) {"]
[null,null,"$dataname .= $localdata->{$taxon}.\"\\t\";"]
[null,"}"]
[null,"$dataname =~s/\\t$//;"]
[null,"$data->{$dataname} ++;"]
[null,"die \"$e[0] seen\\n\\n\" if ($seen->{$e[0]});"]
[null,"$seen->{$e[0]} ++;"]
["#","die;"]
["}"]
["close IN;"]
["#Dump $data;"]
["open(OUT, \">$outfile\") || die \"non scrivo $outfile\\n\\n\";"]
[]
["foreach my $dataname (sort {$data->{$b} <=> $data->{$a}} (keys(%$data))) {"]
[null,"print OUT join(\"\\t\", ($dataname, $data->{$dataname})) .\"\\n\";"]
["}"]
["close OUT;"]