{"action":"created","issue":{"url":"https://api.github.com/repos/torognes/vsearch/issues/166","repository_url":"https://api.github.com/repos/torognes/vsearch","labels_url":"https://api.github.com/repos/torognes/vsearch/issues/166/labels{/name}","comments_url":"https://api.github.com/repos/torognes/vsearch/issues/166/comments","events_url":"https://api.github.com/repos/torognes/vsearch/issues/166/events","html_url":"https://github.com/torognes/vsearch/issues/166","id":135363881,"number":166,"title":"Make OTU tables","user":{"login":"torognes","id":2765754,"avatar_url":"https://avatars.githubusercontent.com/u/2765754?v=3","gravatar_id":"","url":"https://api.github.com/users/torognes","html_url":"https://github.com/torognes","followers_url":"https://api.github.com/users/torognes/followers","following_url":"https://api.github.com/users/torognes/following{/other_user}","gists_url":"https://api.github.com/users/torognes/gists{/gist_id}","starred_url":"https://api.github.com/users/torognes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/torognes/subscriptions","organizations_url":"https://api.github.com/users/torognes/orgs","repos_url":"https://api.github.com/users/torognes/repos","events_url":"https://api.github.com/users/torognes/events{/privacy}","received_events_url":"https://api.github.com/users/torognes/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/torognes/vsearch/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-02-22T09:32:59Z","updated_at":"2016-02-22T10:20:03Z","closed_at":null,"body":"Add options to create OTU tables directly, as described [here](http://drive5.com/usearch/manual/mapreadstootus.html)."},"comment":{"url":"https://api.github.com/repos/torognes/vsearch/issues/comments/187108638","html_url":"https://github.com/torognes/vsearch/issues/166#issuecomment-187108638","issue_url":"https://api.github.com/repos/torognes/vsearch/issues/166","id":187108638,"user":{"login":"davidmartinad200","id":11404840,"avatar_url":"https://avatars.githubusercontent.com/u/11404840?v=3","gravatar_id":"","url":"https://api.github.com/users/davidmartinad200","html_url":"https://github.com/davidmartinad200","followers_url":"https://api.github.com/users/davidmartinad200/followers","following_url":"https://api.github.com/users/davidmartinad200/following{/other_user}","gists_url":"https://api.github.com/users/davidmartinad200/gists{/gist_id}","starred_url":"https://api.github.com/users/davidmartinad200/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidmartinad200/subscriptions","organizations_url":"https://api.github.com/users/davidmartinad200/orgs","repos_url":"https://api.github.com/users/davidmartinad200/repos","events_url":"https://api.github.com/users/davidmartinad200/events{/privacy}","received_events_url":"https://api.github.com/users/davidmartinad200/received_events","type":"User","site_admin":false},"created_at":"2016-02-22T10:20:03Z","updated_at":"2016-02-22T10:20:03Z","body":"Thanks ,\r\nJust in case it can help others on the mean time i wrote a perl script that will take the uc file and convert it to a OTU table. It requires the perl module Text::Table. Change the filename variable accroding to the name of your ucfile.\r\n\r\nMy ucfile looks like this:\r\n```\r\nH       185     322     99.1    +       0       0       I322M   Sample01_1 OTU_17349\r\nH       420     283     99.3    +       0       0       283M    Sample02 OTU_21114\r\nH       394     283     99.3    +       0       0       283M    Sample03_8 OTU_1154\r\nH       260     322     99.4    +       0       0       322M    Sample05_3 OTU_20186\r\nH       164     329     99.4    +       0       0       I329M   Sample06_2 OTU_6303\r\nH       164     329     99.7    +       0       0       I329M   Sample06_4 OTU_6303\r\n```\r\n\r\n```\r\n#! /usr/bin/perl -w\r\n\r\n#Convert UC file to tab file\r\nuse warnings;\r\nuse Data::Dumper;\r\nuse Text::Table;\r\n\r\nmy $filename = 'ucfinal.txt';\r\nopen(my $fh,'<', $filename)\r\n    or die \"Could not open file '$filename' $!\";\r\n\r\nmy %samples = ();\r\nmy %values;\r\nmy $nbOTUs = 0; \r\nwhile (my $row = <$fh>) {\r\n    chomp $row;\r\n    my @F=split(\"\\t\",$row);\r\n    my @sample = split(\"_\",$F[8]);  # e.g Sample01_1\r\n    my $OTU = $F[9];\r\n    $samples{'OTUs'}{$sample[0]}{$OTU}+=1; \r\n}\r\n\r\nmy $struct = $samples{OTUs};\r\nmy @cols = sort keys %{ $struct };\r\nmy @rows = sort keys %{ { map {\r\n    my $x = $_;\r\n    map { $_ => undef }\r\n    keys %{ $struct->{$x} }\r\n                          } @cols } };\r\n\r\nmy $tb = Text::Table->new('', @cols);\r\n\r\nfor my $r (@rows) {\r\n    $tb->add($r, map $struct->{$_}{$r} // '0', @cols);\r\n}\r\n\r\nprint $tb;\r\n```\r\n\r\nhere is how the output will look. Otus as rows and sample as column.\r\n\r\n```\r\n          Sample01 Sample02 Sample05 Sample06 Sample07 Sample08 Sample01 Sample02 Sample05 Sample06 Sample07 Sample08\r\nOTU_10017     2     7     0    1      6     5    6    3    0    0    6    7\r\nOTU_10021    96    92     0    0     58    42    8    9    0    0    6   13\r\nOTU_10026    22    27     0    0     26    16    3    2    0    0    1    4\r\nOTU_10046   124   136     0    2    153   137  296  333    0    0  318  357\r\nOTU_10055     0     4     0    0      0     0    0    0    0    0    0    0\r\n\r\n```"}}