annotate mothur/lib/galaxy/datatypes/metagenomics.py @ 27:49058b1f8d3f

Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
author Jim Johnson <jj@umn.edu>
date Tue, 04 Dec 2012 11:05:19 -0600
parents 5c77423823cb
children 9c0cd3b92295
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
2 metagenomics datatypes
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
3 James E Johnson - University of Minnesota
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
4 for Mothur
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
5 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
6
17
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
7 import logging, os, os.path, sys, time, tempfile, shutil, string, glob, re
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
8 import galaxy.model
17
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
9 from galaxy.datatypes.sniff import *
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
10 from galaxy.datatypes.metadata import MetadataElement
17
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
11 from galaxy.datatypes.data import Text
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
12 from galaxy.datatypes.tabular import Tabular
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
13 from galaxy.datatypes.sequence import Fasta
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
14 from galaxy import util
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
15 from galaxy.datatypes.images import Html
26
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
16 import pkg_resources
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
17 pkg_resources.require("simplejson")
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
18 import simplejson
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
19
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
20 log = logging.getLogger(__name__)
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
21
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
22 ## Mothur Classes
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
23
25
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
24 class Otu( Text ):
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
25 file_ext = 'otu'
25
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
26 MetadataElement( name="columns", default=0, desc="Number of columns", readonly=True, visible=True, no_value=0 )
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
27 MetadataElement( name="labels", default=[], desc="Label Names", readonly=True, visible=True, no_value=[] )
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
28 def __init__(self, **kwd):
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
29 Text.__init__( self, **kwd )
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
30 def set_meta( self, dataset, overwrite = True, **kwd ):
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
31 if dataset.has_data():
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
32 label_names = set()
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
33 ncols = 0
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
34 data_lines = 0
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
35 comment_lines = 0
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
36 try:
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
37 fh = open( dataset.file_name )
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
38 for line in fh:
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
39 fields = line.strip().split('\t')
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
40 if len(fields) >= 2:
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
41 data_lines += 1
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
42 ncols = max(ncols,len(fields))
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
43 label_names.add(fields[0])
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
44 else:
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
45 comment_lines += 1
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
46 # Set the discovered metadata values for the dataset
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
47 dataset.metadata.data_lines = data_lines
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
48 dataset.metadata.columns = ncols
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
49 dataset.metadata.labels = []
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
50 dataset.metadata.labels += label_names
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
51 dataset.metadata.labels.sort()
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
52 finally:
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
53 fh.close()
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
54
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
55 def sniff( self, filename ):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
56 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
57 Determines whether the file is a otu (operational taxonomic unit) format
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
58 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
59 try:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
60 fh = open( filename )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
61 count = 0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
62 while True:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
63 line = fh.readline()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
64 line = line.strip()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
65 if not line:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
66 break #EOF
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
67 if line:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
68 if line[0] != '@':
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
69 linePieces = line.split('\t')
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
70 if len(linePieces) < 2:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
71 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
72 try:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
73 check = int(linePieces[1])
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
74 if check + 2 != len(linePieces):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
75 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
76 except ValueError:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
77 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
78 count += 1
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
79 if count == 5:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
80 return True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
81 fh.close()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
82 if count < 5 and count > 0:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
83 return True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
84 except:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
85 pass
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
86 finally:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
87 fh.close()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
88 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
89
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
90 class OtuList( Otu ):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
91 file_ext = 'list'
25
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
92 def __init__(self, **kwd):
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
93 Otu.__init__( self, **kwd )
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
94 def init_meta( self, dataset, copy_from=None ):
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
95 Otu.init_meta( self, dataset, copy_from=copy_from )
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
96 def set_meta( self, dataset, overwrite = True, **kwd ):
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
97 Otu.set_meta(self,dataset, overwrite = True, **kwd )
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
98 """
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
99 # too many columns to be stored in metadata
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
100 if dataset != None and dataset.metadata.columns > 2:
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
101 for i in range(2,dataset.metadata.columns):
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
102 dataset.metadata.column_types[i] = 'str'
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
103 """
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
104
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
105 class Sabund( Otu ):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
106 file_ext = 'sabund'
25
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
107 def __init__(self, **kwd):
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
108 Otu.__init__( self, **kwd )
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
109 def init_meta( self, dataset, copy_from=None ):
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
110 Otu.init_meta( self, dataset, copy_from=copy_from )
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
111 def sniff( self, filename ):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
112 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
113 Determines whether the file is a otu (operational taxonomic unit) format
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
114 label<TAB>count[<TAB>value(1..n)]
7
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
115
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
116 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
117 try:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
118 fh = open( filename )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
119 count = 0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
120 while True:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
121 line = fh.readline()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
122 line = line.strip()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
123 if not line:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
124 break #EOF
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
125 if line:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
126 if line[0] != '@':
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
127 linePieces = line.split('\t')
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
128 if len(linePieces) < 2:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
129 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
130 try:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
131 check = int(linePieces[1])
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
132 if check + 2 != len(linePieces):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
133 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
134 for i in range( 2, len(linePieces)):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
135 ival = int(linePieces[i])
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
136 except ValueError:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
137 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
138 count += 1
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
139 if count >= 5:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
140 return True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
141 fh.close()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
142 if count < 5 and count > 0:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
143 return True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
144 except:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
145 pass
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
146 finally:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
147 fh.close()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
148 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
149
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
150 class Rabund( Sabund ):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
151 file_ext = 'rabund'
25
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
152 def __init__(self, **kwd):
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
153 Sabund.__init__( self, **kwd )
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
154 def init_meta( self, dataset, copy_from=None ):
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
155 Sabund.init_meta( self, dataset, copy_from=copy_from )
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
156
7
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
157 class GroupAbund( Otu ):
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
158 file_ext = 'grpabund'
25
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
159 MetadataElement( name="groups", default=[], desc="Group Names", readonly=True, visible=True, no_value=[] )
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
160 def __init__(self, **kwd):
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
161 Otu.__init__( self, **kwd )
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
162 # self.column_names[0] = ['label']
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
163 # self.column_names[1] = ['group']
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
164 # self.column_names[2] = ['count']
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
165 """
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
166 def init_meta( self, dataset, copy_from=None ):
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
167 Otu.init_meta( self, dataset, copy_from=copy_from )
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
168 """
7
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
169 def init_meta( self, dataset, copy_from=None ):
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
170 Otu.init_meta( self, dataset, copy_from=copy_from )
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
171 def set_meta( self, dataset, overwrite = True, skip=1, max_data_lines = 100000, **kwd ):
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
172 # See if file starts with header line
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
173 if dataset.has_data():
25
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
174 label_names = set()
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
175 group_names = set()
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
176 data_lines = 0
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
177 comment_lines = 0
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
178 ncols = 0
7
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
179 try:
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
180 fh = open( dataset.file_name )
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
181 line = fh.readline()
25
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
182 fields = line.strip().split('\t')
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
183 ncols = max(ncols,len(fields))
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
184 if fields[0] == 'label' and fields[1] == 'Group':
7
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
185 skip=1
25
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
186 comment_lines += 1
7
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
187 else:
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
188 skip=0
25
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
189 data_lines += 1
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
190 label_names.add(fields[0])
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
191 group_names.add(fields[1])
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
192 for line in fh:
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
193 data_lines += 1
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
194 fields = line.strip().split('\t')
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
195 ncols = max(ncols,len(fields))
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
196 label_names.add(fields[0])
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
197 group_names.add(fields[1])
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
198 # Set the discovered metadata values for the dataset
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
199 dataset.metadata.data_lines = data_lines
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
200 dataset.metadata.columns = ncols
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
201 dataset.metadata.labels = []
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
202 dataset.metadata.labels += label_names
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
203 dataset.metadata.labels.sort()
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
204 dataset.metadata.groups = []
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
205 dataset.metadata.groups += group_names
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
206 dataset.metadata.groups.sort()
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
207 dataset.metadata.skip = skip
7
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
208 finally:
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
209 fh.close()
25
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
210
7
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
211 def sniff( self, filename, vals_are_int=False):
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
212 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
213 Determines whether the file is a otu (operational taxonomic unit) Shared format
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
214 label<TAB>group<TAB>count[<TAB>value(1..n)]
7
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
215 The first line is column headings as of Mothur v 1.20
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
216 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
217 try:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
218 fh = open( filename )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
219 count = 0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
220 while True:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
221 line = fh.readline()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
222 line = line.strip()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
223 if not line:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
224 break #EOF
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
225 if line:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
226 if line[0] != '@':
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
227 linePieces = line.split('\t')
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
228 if len(linePieces) < 3:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
229 return False
7
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
230 if count > 0 or linePieces[0] != 'label':
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
231 try:
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
232 check = int(linePieces[2])
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
233 if check + 3 != len(linePieces):
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
234 return False
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
235 for i in range( 3, len(linePieces)):
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
236 if vals_are_int:
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
237 ival = int(linePieces[i])
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
238 else:
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
239 fval = float(linePieces[i])
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
240 except ValueError:
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
241 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
242 count += 1
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
243 if count >= 5:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
244 return True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
245 fh.close()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
246 if count < 5 and count > 0:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
247 return True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
248 except:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
249 pass
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
250 finally:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
251 fh.close()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
252 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
253
7
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
254 class SharedRabund( GroupAbund ):
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
255 file_ext = 'shared'
25
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
256 def __init__(self, **kwd):
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
257 GroupAbund.__init__( self, **kwd )
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
258 def init_meta( self, dataset, copy_from=None ):
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
259 GroupAbund.init_meta( self, dataset, copy_from=copy_from )
7
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
260 def sniff( self, filename ):
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
261 """
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
262 Determines whether the file is a otu (operational taxonomic unit) Shared format
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
263 label<TAB>group<TAB>count[<TAB>value(1..n)]
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
264 The first line is column headings as of Mothur v 1.20
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
265 """
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
266 # return GroupAbund.sniff(self,filename,True)
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
267 isme = GroupAbund.sniff(self,filename,True)
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
268 return isme
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
269
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
270
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
271 class RelAbund( GroupAbund ):
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
272 file_ext = 'relabund'
25
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
273 def __init__(self, **kwd):
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
274 GroupAbund.__init__( self, **kwd )
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
275 def init_meta( self, dataset, copy_from=None ):
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
276 GroupAbund.init_meta( self, dataset, copy_from=copy_from )
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
277 def sniff( self, filename ):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
278 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
279 Determines whether the file is a otu (operational taxonomic unit) Relative Abundance format
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
280 label<TAB>group<TAB>count[<TAB>value(1..n)]
7
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
281 The first line is column headings as of Mothur v 1.20
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
282 """
7
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
283 # return GroupAbund.sniff(self,filename,False)
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
284 isme = GroupAbund.sniff(self,filename,False)
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
285 return isme
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
286
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
287 class SecondaryStructureMap(Tabular):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
288 file_ext = 'map'
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
289 def __init__(self, **kwd):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
290 """Initialize secondary structure map datatype"""
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
291 Tabular.__init__( self, **kwd )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
292 self.column_names = ['Map']
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
293
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
294 def sniff( self, filename ):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
295 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
296 Determines whether the file is a secondary structure map format
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
297 A single column with an integer value which indicates the row that this row maps to.
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
298 check you make sure is structMap[10] = 380 then structMap[380] = 10.
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
299 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
300 try:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
301 fh = open( filename )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
302 line_num = 0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
303 rowidxmap = {}
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
304 while True:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
305 line = fh.readline()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
306 line_num += 1
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
307 line = line.strip()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
308 if not line:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
309 break #EOF
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
310 if line:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
311 try:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
312 pointer = int(line)
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
313 if pointer > 0:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
314 if pointer > line_num:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
315 rowidxmap[line_num] = pointer
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
316 elif pointer < line_num & rowidxmap[pointer] != line_num:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
317 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
318 except ValueError:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
319 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
320 fh.close()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
321 if count < 5 and count > 0:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
322 return True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
323 except:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
324 pass
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
325 finally:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
326 fh.close()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
327 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
328
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
329 class SequenceAlignment( Fasta ):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
330 file_ext = 'align'
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
331 def __init__(self, **kwd):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
332 Fasta.__init__( self, **kwd )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
333 """Initialize AlignCheck datatype"""
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
334
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
335 def sniff( self, filename ):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
336 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
337 Determines whether the file is in Mothur align fasta format
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
338 Each sequence line must be the same length
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
339 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
340
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
341 try:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
342 fh = open( filename )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
343 len = -1
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
344 while True:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
345 line = fh.readline()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
346 if not line:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
347 break #EOF
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
348 line = line.strip()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
349 if line: #first non-empty line
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
350 if line.startswith( '>' ):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
351 #The next line.strip() must not be '', nor startwith '>'
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
352 line = fh.readline().strip()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
353 if line == '' or line.startswith( '>' ):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
354 break
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
355 if len < 0:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
356 len = len(line)
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
357 elif len != len(line):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
358 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
359 else:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
360 break #we found a non-empty line, but its not a fasta header
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
361 if len > 0:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
362 return True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
363 except:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
364 pass
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
365 finally:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
366 fh.close()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
367 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
368
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
369 class AlignCheck( Tabular ):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
370 file_ext = 'align.check'
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
371 def __init__(self, **kwd):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
372 """Initialize AlignCheck datatype"""
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
373 Tabular.__init__( self, **kwd )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
374 self.column_names = ['name','pound','dash','plus','equal','loop','tilde','total']
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
375 self.column_types = ['str','int','int','int','int','int','int','int']
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
376 self.comment_lines = 1
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
377
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
378 def set_meta( self, dataset, overwrite = True, **kwd ):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
379 # Tabular.set_meta( self, dataset, overwrite = overwrite, first_line_is_header = True, skip = 1 )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
380 data_lines = 0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
381 if dataset.has_data():
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
382 dataset_fh = open( dataset.file_name )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
383 while True:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
384 line = dataset_fh.readline()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
385 if not line: break
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
386 data_lines += 1
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
387 dataset_fh.close()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
388 dataset.metadata.comment_lines = 1
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
389 dataset.metadata.data_lines = data_lines - 1 if data_lines > 0 else 0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
390 dataset.metadata.column_names = self.column_names
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
391 dataset.metadata.column_types = self.column_types
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
392
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
393 class AlignReport(Tabular):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
394 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
395 QueryName QueryLength TemplateName TemplateLength SearchMethod SearchScore AlignmentMethod QueryStart QueryEnd TemplateStart TemplateEnd PairwiseAlignmentLength GapsInQuery GapsInTemplate LongestInsert SimBtwnQuery&Template
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
396 AY457915 501 82283 1525 kmer 89.07 needleman 5 501 1 499 499 2 0 0 97.6
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
397 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
398 file_ext = 'align.report'
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
399 def __init__(self, **kwd):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
400 """Initialize AlignCheck datatype"""
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
401 Tabular.__init__( self, **kwd )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
402 self.column_names = ['QueryName','QueryLength','TemplateName','TemplateLength','SearchMethod','SearchScore',
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
403 'AlignmentMethod','QueryStart','QueryEnd','TemplateStart','TemplateEnd',
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
404 'PairwiseAlignmentLength','GapsInQuery','GapsInTemplate','LongestInsert','SimBtwnQuery&Template'
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
405 ]
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
406
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
407 class BellerophonChimera( Tabular ):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
408 file_ext = 'bellerophon.chimera'
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
409 def __init__(self, **kwd):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
410 """Initialize AlignCheck datatype"""
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
411 Tabular.__init__( self, **kwd )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
412 self.column_names = ['Name','Score','Left','Right']
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
413
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
414 class SecondaryStructureMatch(Tabular):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
415 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
416 name pound dash plus equal loop tilde total
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
417 9_1_12 42 68 8 28 275 420 872
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
418 9_1_14 36 68 6 26 266 422 851
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
419 9_1_15 44 68 8 28 276 418 873
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
420 9_1_16 34 72 6 30 267 430 860
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
421 9_1_18 46 80 2 36 261
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
422 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
423 def __init__(self, **kwd):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
424 """Initialize SecondaryStructureMatch datatype"""
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
425 Tabular.__init__( self, **kwd )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
426 self.column_names = ['name','pound','dash','plus','equal','loop','tilde','total']
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
427
17
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
428 class DistanceMatrix( Text ):
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
429 file_ext = 'dist'
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
430 """Add metadata elements"""
25
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
431 MetadataElement( name="sequence_count", default=0, desc="Number of sequences", readonly=True, visible=True, optional=True, no_value='?' )
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
432
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
433 def init_meta( self, dataset, copy_from=None ):
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
434 Text.init_meta( self, dataset, copy_from=copy_from )
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
435
25
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
436 def set_meta( self, dataset, overwrite = True, skip = 0, **kwd ):
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
437 Text.set_meta(self, dataset,overwrite = overwrite, skip = skip, **kwd )
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
438 try:
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
439 fh = open( dataset.file_name )
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
440 line = fh.readline().strip().strip()
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
441 dataset.metadata.sequence_count = int(line)
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
442 except Exception, e:
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
443 log.warn("DistanceMatrix set_meta %s" % e)
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
444 finally:
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
445 fh.close()
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
446
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
447 class LowerTriangleDistanceMatrix(DistanceMatrix):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
448 file_ext = 'lower.dist'
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
449 def __init__(self, **kwd):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
450 """Initialize secondary structure map datatype"""
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
451 DistanceMatrix.__init__( self, **kwd )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
452
25
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
453 def init_meta( self, dataset, copy_from=None ):
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
454 DistanceMatrix.init_meta( self, dataset, copy_from=copy_from )
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
455
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
456 def sniff( self, filename ):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
457 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
458 Determines whether the file is a lower-triangle distance matrix (phylip) format
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
459 The first line has the number of sequences in the matrix.
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
460 The remaining lines have the sequence name followed by a list of distances from all preceeding sequences
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
461 5
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
462 U68589
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
463 U68590 0.3371
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
464 U68591 0.3609 0.3782
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
465 U68592 0.4155 0.3197 0.4148
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
466 U68593 0.2872 0.1690 0.3361 0.2842
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
467 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
468 try:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
469 fh = open( filename )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
470 count = 0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
471 while True:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
472 line = fh.readline()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
473 line = line.strip()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
474 if not line:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
475 break #EOF
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
476 if line:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
477 if line[0] != '@':
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
478 linePieces = line.split('\t')
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
479 if len(linePieces) != 3:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
480 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
481 try:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
482 check = float(linePieces[2])
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
483 except ValueError:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
484 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
485 count += 1
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
486 if count == 5:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
487 return True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
488 fh.close()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
489 if count < 5 and count > 0:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
490 return True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
491 except:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
492 pass
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
493 finally:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
494 fh.close()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
495 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
496
25
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
497 class SquareDistanceMatrix(DistanceMatrix):
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
498 file_ext = 'square.dist'
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
499
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
500 def __init__(self, **kwd):
25
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
501 DistanceMatrix.__init__( self, **kwd )
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
502 def init_meta( self, dataset, copy_from=None ):
25
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
503 DistanceMatrix.init_meta( self, dataset, copy_from=copy_from )
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
504
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
505 def sniff( self, filename ):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
506 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
507 Determines whether the file is a square distance matrix (Column-formatted distance matrix) format
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
508 The first line has the number of sequences in the matrix.
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
509 The following lines have the sequence name in the first column plus a column for the distance to each sequence
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
510 in the row order in which they appear in the matrix.
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
511 3
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
512 U68589 0.0000 0.3371 0.3610
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
513 U68590 0.3371 0.0000 0.3783
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
514 U68590 0.3371 0.0000 0.3783
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
515 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
516 try:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
517 fh = open( filename )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
518 count = 0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
519 line = fh.readline()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
520 line = line.strip()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
521 sequence_count = int(line)
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
522 col_cnt = seq_cnt + 1
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
523 while True:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
524 line = fh.readline()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
525 line = line.strip()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
526 if not line:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
527 break #EOF
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
528 if line:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
529 if line[0] != '@':
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
530 linePieces = line.split('\t')
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
531 if len(linePieces) != col_cnt :
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
532 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
533 try:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
534 for i in range(1, col_cnt):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
535 check = float(linePieces[i])
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
536 except ValueError:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
537 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
538 count += 1
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
539 if count == 5:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
540 return True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
541 fh.close()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
542 if count < 5 and count > 0:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
543 return True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
544 except:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
545 pass
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
546 finally:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
547 fh.close()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
548 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
549
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
550 class PairwiseDistanceMatrix(DistanceMatrix,Tabular):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
551 file_ext = 'pair.dist'
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
552 def __init__(self, **kwd):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
553 """Initialize secondary structure map datatype"""
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
554 Tabular.__init__( self, **kwd )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
555 self.column_names = ['Sequence','Sequence','Distance']
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
556 self.column_types = ['str','str','float']
25
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
557 def set_meta( self, dataset, overwrite = True, skip = None, **kwd ):
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
558 Tabular.set_meta(self, dataset,overwrite = overwrite, skip = skip, **kwd )
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
559
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
560 def sniff( self, filename ):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
561 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
562 Determines whether the file is a pairwise distance matrix (Column-formatted distance matrix) format
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
563 The first and second columns have the sequence names and the third column is the distance between those sequences.
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
564 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
565 try:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
566 fh = open( filename )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
567 count = 0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
568 while True:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
569 line = fh.readline()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
570 line = line.strip()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
571 if not line:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
572 break #EOF
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
573 if line:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
574 if line[0] != '@':
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
575 linePieces = line.split('\t')
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
576 if len(linePieces) != 3:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
577 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
578 try:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
579 check = float(linePieces[2])
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
580 except ValueError:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
581 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
582 count += 1
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
583 if count == 5:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
584 return True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
585 fh.close()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
586 if count < 5 and count > 0:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
587 return True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
588 except:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
589 pass
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
590 finally:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
591 fh.close()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
592 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
593
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
594 class AlignCheck(Tabular):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
595 file_ext = 'align.check'
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
596 def __init__(self, **kwd):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
597 """Initialize secondary structure map datatype"""
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
598 Tabular.__init__( self, **kwd )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
599 self.column_names = ['name','pound','dash','plus','equal','loop','tilde','total']
1
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
600 self.columns = 8
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
601
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
602 class Names(Tabular):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
603 file_ext = 'names'
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
604 def __init__(self, **kwd):
1
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
605 """Name file shows the relationship between a representative sequence(col 1) and the sequences(comma-separated) it represents(col 2)"""
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
606 Tabular.__init__( self, **kwd )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
607 self.column_names = ['name','representatives']
1
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
608 self.columns = 2
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
609
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
610 class Summary(Tabular):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
611 file_ext = 'summary'
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
612 def __init__(self, **kwd):
1
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
613 """summarizes the quality of sequences in an unaligned or aligned fasta-formatted sequence file"""
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
614 Tabular.__init__( self, **kwd )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
615 self.column_names = ['seqname','start','end','nbases','ambigs','polymer']
1
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
616 self.columns = 6
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
617
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
618 class Group(Tabular):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
619 file_ext = 'groups'
25
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
620 MetadataElement( name="groups", default=[], desc="Group Names", readonly=True, visible=True, no_value=[] )
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
621 def __init__(self, **kwd):
25
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
622 """Group file assigns sequence (col 1) to a group (col 2)"""
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
623 Tabular.__init__( self, **kwd )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
624 self.column_names = ['name','group']
1
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
625 self.columns = 2
25
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
626 def set_meta( self, dataset, overwrite = True, skip = None, max_data_lines = None, **kwd ):
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
627 Tabular.set_meta(self, dataset, overwrite, skip, max_data_lines)
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
628 group_names = set()
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
629 try:
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
630 fh = open( dataset.file_name )
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
631 for line in fh:
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
632 fields = line.strip().split('\t')
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
633 group_names.add(fields[1])
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
634 dataset.metadata.groups = []
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
635 dataset.metadata.groups += group_names
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
636 finally:
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
637 fh.close()
1
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
638
25
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
639 class Design(Group):
1
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
640 file_ext = 'design'
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
641 def __init__(self, **kwd):
25
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
642 """Design file shows the relationship between a group(col 1) and a grouping (col 2), providing a way to merge groups."""
bfbaf823be4c Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents: 17
diff changeset
643 Group.__init__( self, **kwd )
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
644
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
645 class AccNos(Tabular):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
646 file_ext = 'accnos'
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
647 def __init__(self, **kwd):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
648 """A list of names"""
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
649 Tabular.__init__( self, **kwd )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
650 self.column_names = ['name']
1
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
651 self.columns = 1
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
652
17
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
653 class Oligos( Text ):
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
654 file_ext = 'oligos'
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
655
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
656 def sniff( self, filename ):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
657 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
658 Determines whether the file is a otu (operational taxonomic unit) format
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
659 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
660 try:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
661 fh = open( filename )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
662 count = 0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
663 while True:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
664 line = fh.readline()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
665 line = line.strip()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
666 if not line:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
667 break #EOF
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
668 else:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
669 if line[0] != '#':
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
670 linePieces = line.split('\t')
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
671 if len(linePieces) == 2 and re.match('forward|reverse',linePieces[0]):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
672 count += 1
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
673 continue
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
674 elif len(linePieces) == 3 and re.match('barcode',linePieces[0]):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
675 count += 1
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
676 continue
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
677 else:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
678 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
679 if count > 20:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
680 return True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
681 if count > 0:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
682 return True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
683 except:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
684 pass
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
685 finally:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
686 fh.close()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
687 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
688
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
689 class Frequency(Tabular):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
690 file_ext = 'freq'
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
691 def __init__(self, **kwd):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
692 """A list of names"""
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
693 Tabular.__init__( self, **kwd )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
694 self.column_names = ['position','frequency']
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
695 self.column_types = ['int','float']
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
696
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
697 def sniff( self, filename ):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
698 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
699 Determines whether the file is a frequency tabular format for chimera analysis
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
700 #1.14.0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
701 0 0.000
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
702 1 0.000
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
703 ...
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
704 155 0.975
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
705 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
706 try:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
707 fh = open( filename )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
708 count = 0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
709 while True:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
710 line = fh.readline()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
711 line = line.strip()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
712 if not line:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
713 break #EOF
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
714 else:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
715 if line[0] != '#':
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
716 try:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
717 linePieces = line.split('\t')
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
718 i = int(linePieces[0])
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
719 f = float(linePieces[1])
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
720 count += 1
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
721 continue
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
722 except:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
723 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
724 if count > 20:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
725 return True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
726 if count > 0:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
727 return True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
728 except:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
729 pass
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
730 finally:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
731 fh.close()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
732 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
733
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
734 class Quantile(Tabular):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
735 file_ext = 'quan'
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
736 MetadataElement( name="filtered", default=False, no_value=False, optional=True , desc="Quantiles calculated using a mask", readonly=True)
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
737 MetadataElement( name="masked", default=False, no_value=False, optional=True , desc="Quantiles calculated using a frequency filter", readonly=True)
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
738 def __init__(self, **kwd):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
739 """Quantiles for chimera analysis"""
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
740 Tabular.__init__( self, **kwd )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
741 self.column_names = ['num','ten','twentyfive','fifty','seventyfive','ninetyfive','ninetynine']
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
742 self.column_types = ['int','float','float','float','float','float','float']
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
743 def sniff( self, filename ):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
744 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
745 Determines whether the file is a quantiles tabular format for chimera analysis
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
746 1 0 0 0 0 0 0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
747 2 0.309198 0.309198 0.37161 0.37161 0.37161 0.37161
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
748 3 0.510982 0.563213 0.693529 0.858939 1.07442 1.20608
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
749 ...
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
750 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
751 try:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
752 fh = open( filename )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
753 count = 0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
754 while True:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
755 line = fh.readline()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
756 line = line.strip()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
757 if not line:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
758 break #EOF
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
759 else:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
760 if line[0] != '#':
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
761 try:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
762 linePieces = line.split('\t')
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
763 i = int(linePieces[0])
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
764 f = float(linePieces[1])
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
765 f = float(linePieces[2])
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
766 f = float(linePieces[3])
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
767 f = float(linePieces[4])
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
768 f = float(linePieces[5])
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
769 f = float(linePieces[6])
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
770 count += 1
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
771 continue
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
772 except:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
773 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
774 if count > 10:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
775 return True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
776 if count > 0:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
777 return True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
778 except:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
779 pass
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
780 finally:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
781 fh.close()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
782 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
783
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
784 class FilteredQuantile(Quantile):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
785 file_ext = 'filtered.quan'
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
786 def __init__(self, **kwd):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
787 """Quantiles for chimera analysis"""
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
788 Quantile.__init__( self, **kwd )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
789 self.filtered = True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
790
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
791 class MaskedQuantile(Quantile):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
792 file_ext = 'masked.quan'
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
793 def __init__(self, **kwd):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
794 """Quantiles for chimera analysis"""
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
795 Quantile.__init__( self, **kwd )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
796 self.masked = True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
797 self.filtered = False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
798
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
799 class FilteredMaskedQuantile(Quantile):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
800 file_ext = 'filtered.masked.quan'
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
801 def __init__(self, **kwd):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
802 """Quantiles for chimera analysis"""
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
803 Quantile.__init__( self, **kwd )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
804 self.masked = True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
805 self.filtered = True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
806
17
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
807 class LaneMask(Text):
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
808 file_ext = 'filter'
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
809
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
810 def sniff( self, filename ):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
811 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
812 Determines whether the file is a lane mask filter: 1 line consisting of zeros and ones.
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
813 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
814 try:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
815 fh = open( filename )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
816 while True:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
817 buff = fh.read(1000)
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
818 if not buff:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
819 break #EOF
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
820 else:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
821 if not re.match('^[01]+$',line):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
822 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
823 return True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
824 except:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
825 pass
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
826 finally:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
827 close(fh)
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
828 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
829
27
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
830 class CountTable(Tabular):
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
831 MetadataElement( name="groups", default=[], desc="Group Names", readonly=True, visible=True, no_value=[] )
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
832 file_ext = 'count_table'
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
833
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
834 def __init__(self, **kwd):
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
835 """
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
836 A table with first column names and following columns integer counts
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
837 # Example 1:
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
838 Representative_Sequence total
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
839 U68630 1
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
840 U68595 1
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
841 U68600 1
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
842 # Example 2 (with group columns):
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
843 Representative_Sequence total forest pasture
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
844 U68630 1 1 0
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
845 U68595 1 1 0
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
846 U68600 1 1 0
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
847 U68591 1 1 0
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
848 U68647 1 0 1
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
849 """
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
850 Tabular.__init__( self, **kwd )
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
851 self.column_names = ['name','total']
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
852
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
853 def set_meta( self, dataset, overwrite = True, skip = 1, max_data_lines = None, **kwd ):
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
854 try:
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
855 data_lines = 0;
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
856 fh = open( dataset.file_name )
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
857 line = fh.readline()
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
858 if line:
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
859 line = line.strip()
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
860 colnames = line.split()
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
861 if len(colnames) > 1:
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
862 dataset.metadata.columns = len( colnames )
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
863 if len(colnames) > 2:
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
864 dataset.metadata.groups = colnames[2:]
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
865 column_types = ['str']
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
866 for i in range(1,len(colnames)):
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
867 column_types.append('int')
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
868 dataset.metadata.column_types = column_types
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
869 dataset.metadata.comment_lines = 1
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
870 while line:
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
871 line = fh.readline()
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
872 if not line: break
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
873 data_lines += 1
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
874 dataset.metadata.data_lines = data_lines
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
875 finally:
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
876 close(fh)
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
877
15
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
878 class RefTaxonomy(Tabular):
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
879 file_ext = 'ref.taxonomy'
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
880 """
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
881 A table with 2 or 3 columns:
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
882 - SequenceName
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
883 - Taxonomy (semicolon-separated taxonomy in descending order)
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
884 - integer ?
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
885 Example: 2-column ( http://www.mothur.org/wiki/Taxonomy_outline )
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
886 X56533.1 Eukaryota;Alveolata;Ciliophora;Intramacronucleata;Oligohymenophorea;Hymenostomatida;Tetrahymenina;Glaucomidae;Glaucoma;
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
887 X97975.1 Eukaryota;Parabasalidea;Trichomonada;Trichomonadida;unclassified_Trichomonadida;
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
888 AF052717.1 Eukaryota;Parabasalidea;
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
889 Example: 3-column ( http://vamps.mbl.edu/resources/databases.php )
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
890 v3_AA008 Bacteria;Firmicutes;Bacilli;Lactobacillales;Streptococcaceae;Streptococcus 5
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
891 v3_AA016 Bacteria 120
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
892 v3_AA019 Archaea;Crenarchaeota;Marine_Group_I 1
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
893 """
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
894 def __init__(self, **kwd):
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
895 Tabular.__init__( self, **kwd )
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
896 self.column_names = ['name','taxonomy']
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
897
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
898 def sniff( self, filename ):
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
899 """
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
900 Determines whether the file is a SequenceTaxonomy
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
901 """
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
902 try:
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
903 pat = '^([^ \t\n\r\x0c\x0b;]+([(]\\d+[)])?(;[^ \t\n\r\x0c\x0b;]+([(]\\d+[)])?)*(;)?)$'
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
904 fh = open( filename )
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
905 count = 0
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
906 while True:
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
907 line = fh.readline()
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
908 if not line:
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
909 break #EOF
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
910 line = line.strip()
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
911 if line:
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
912 fields = line.split('\t')
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
913 if 2 <= len(fields) <= 3:
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
914 return False
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
915 if not re.match(pat,fields[1]):
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
916 return False
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
917 count += 1
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
918 if count > 10:
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
919 break
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
920 if count > 0:
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
921 return True
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
922 except:
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
923 pass
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
924 finally:
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
925 fh.close()
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
926 return False
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
927
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
928 class SequenceTaxonomy(RefTaxonomy):
2
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
929 file_ext = 'seq.taxonomy'
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
930 """
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
931 A table with 2 columns:
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
932 - SequenceName
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
933 - Taxonomy (semicolon-separated taxonomy in descending order)
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
934 Example:
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
935 X56533.1 Eukaryota;Alveolata;Ciliophora;Intramacronucleata;Oligohymenophorea;Hymenostomatida;Tetrahymenina;Glaucomidae;Glaucoma;
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
936 X97975.1 Eukaryota;Parabasalidea;Trichomonada;Trichomonadida;unclassified_Trichomonadida;
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
937 AF052717.1 Eukaryota;Parabasalidea;
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
938 """
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
939 def __init__(self, **kwd):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
940 Tabular.__init__( self, **kwd )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
941 self.column_names = ['name','taxonomy']
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
942
2
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
943 def sniff( self, filename ):
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
944 """
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
945 Determines whether the file is a SequenceTaxonomy
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
946 """
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
947 try:
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
948 pat = '^([^ \t\n\r\f\v;]+([(]\d+[)])?[;])+$'
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
949 fh = open( filename )
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
950 count = 0
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
951 while True:
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
952 line = fh.readline()
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
953 if not line:
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
954 break #EOF
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
955 line = line.strip()
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
956 if line:
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
957 fields = line.split('\t')
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
958 if len(fields) != 2:
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
959 return False
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
960 if not re.match(pat,fields[1]):
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
961 return False
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
962 count += 1
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
963 if count > 10:
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
964 break
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
965 if count > 0:
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
966 return True
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
967 except:
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
968 pass
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
969 finally:
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
970 fh.close()
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
971 return False
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
972
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
973 class RDPSequenceTaxonomy(SequenceTaxonomy):
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
974 file_ext = 'rdp.taxonomy'
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
975 """
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
976 A table with 2 columns:
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
977 - SequenceName
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
978 - Taxonomy (semicolon-separated taxonomy in descending order, RDP requires exactly 6 levels deep)
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
979 Example:
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
980 AB001518.1 Bacteria;Bacteroidetes;Sphingobacteria;Sphingobacteriales;unclassified_Sphingobacteriales;
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
981 AB001724.1 Bacteria;Cyanobacteria;Cyanobacteria;Family_II;GpIIa;
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
982 AB001774.1 Bacteria;Chlamydiae;Chlamydiae;Chlamydiales;Chlamydiaceae;Chlamydophila;
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
983 """
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
984 def sniff( self, filename ):
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
985 """
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
986 Determines whether the file is a SequenceTaxonomy
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
987 """
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
988 try:
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
989 pat = '^([^ \t\n\r\f\v;]+([(]\d+[)])?[;]){6}$'
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
990 fh = open( filename )
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
991 count = 0
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
992 while True:
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
993 line = fh.readline()
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
994 if not line:
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
995 break #EOF
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
996 line = line.strip()
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
997 if line:
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
998 fields = line.split('\t')
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
999 if len(fields) != 2:
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1000 return False
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1001 if not re.match(pat,fields[1]):
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1002 return False
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1003 count += 1
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1004 if count > 10:
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1005 break
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1006 if count > 0:
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1007 return True
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1008 except:
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1009 pass
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1010 finally:
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1011 fh.close()
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1012 return False
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1013
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1014 class ConsensusTaxonomy(Tabular):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1015 file_ext = 'cons.taxonomy'
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1016 def __init__(self, **kwd):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1017 """A list of names"""
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1018 Tabular.__init__( self, **kwd )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1019 self.column_names = ['OTU','count','taxonomy']
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1020
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1021 class TaxonomySummary(Tabular):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1022 file_ext = 'tax.summary'
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1023 def __init__(self, **kwd):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1024 """A Summary of taxon classification"""
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1025 Tabular.__init__( self, **kwd )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1026 self.column_names = ['taxlevel','rankID','taxon','daughterlevels','total']
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1027
17
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1028 class Phylip(Text):
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1029 file_ext = 'phy'
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1030
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1031 def sniff( self, filename ):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1032 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1033 Determines whether the file is in Phylip format (Interleaved or Sequential)
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1034 The first line of the input file contains the number of species and the
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1035 number of characters, in free format, separated by blanks (not by
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1036 commas). The information for each species follows, starting with a
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1037 ten-character species name (which can include punctuation marks and blanks),
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1038 and continuing with the characters for that species.
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1039 http://evolution.genetics.washington.edu/phylip/doc/main.html#inputfiles
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1040 Interleaved Example:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1041 6 39
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1042 Archaeopt CGATGCTTAC CGCCGATGCT
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1043 HesperorniCGTTACTCGT TGTCGTTACT
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1044 BaluchitheTAATGTTAAT TGTTAATGTT
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1045 B. virginiTAATGTTCGT TGTTAATGTT
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1046 BrontosaurCAAAACCCAT CATCAAAACC
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1047 B.subtilisGGCAGCCAAT CACGGCAGCC
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1048
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1049 TACCGCCGAT GCTTACCGC
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1050 CGTTGTCGTT ACTCGTTGT
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1051 AATTGTTAAT GTTAATTGT
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1052 CGTTGTTAAT GTTCGTTGT
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1053 CATCATCAAA ACCCATCAT
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1054 AATCACGGCA GCCAATCAC
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1055 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1056 try:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1057 fh = open( filename )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1058 # counts line
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1059 line = fh.readline().strip()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1060 linePieces = line.split()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1061 count = int(linePieces[0])
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1062 seq_len = int(linePieces[1])
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1063 # data lines
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1064 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1065 TODO check data lines
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1066 while True:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1067 line = fh.readline()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1068 # name is the first 10 characters
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1069 name = line[0:10]
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1070 seq = line[10:].strip()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1071 # nucleic base or amino acid 1-char designators (spaces allowed)
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1072 bases = ''.join(seq.split())
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1073 # float per base (each separated by space)
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1074 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1075 return True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1076 except:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1077 pass
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1078 finally:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1079 close(fh)
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1080 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1081
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1082
1
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1083 class Axes(Tabular):
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1084 file_ext = 'axes'
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1085
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1086 def __init__(self, **kwd):
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1087 """Initialize axes datatype"""
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1088 Tabular.__init__( self, **kwd )
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1089 def sniff( self, filename ):
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1090 """
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1091 Determines whether the file is an axes format
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1092 The first line may have column headings.
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1093 The following lines have the name in the first column plus float columns for each axis.
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1094 ==> 98_sq_phylip_amazon.fn.unique.pca.axes <==
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1095 group axis1 axis2
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1096 forest 0.000000 0.145743
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1097 pasture 0.145743 0.000000
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1098
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1099 ==> 98_sq_phylip_amazon.nmds.axes <==
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1100 axis1 axis2
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1101 U68589 0.262608 -0.077498
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1102 U68590 0.027118 0.195197
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1103 U68591 0.329854 0.014395
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1104 """
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1105 try:
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1106 fh = open( filename )
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1107 count = 0
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1108 line = fh.readline()
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1109 line = line.strip()
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1110 col_cnt = None
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1111 while True:
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1112 line = fh.readline()
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1113 line = line.strip()
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1114 if not line:
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1115 break #EOF
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1116 if line:
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1117 fields = line.split('\t')
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1118 if col_cnt == None: # ignore values in first line as they may be column headings
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1119 col_cnt = len(fields)
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1120 else:
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1121 if len(fields) != col_cnt :
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1122 return False
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1123 try:
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1124 for i in range(1, col_cnt):
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1125 check = float(fields[i])
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1126 except ValueError:
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1127 return False
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1128 count += 1
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1129 if count > 10:
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1130 return True
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1131 if count > 0:
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1132 return True
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1133 except:
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1134 pass
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1135 finally:
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1136 fh.close()
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1137 return False
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1138
15
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1139 class SffFlow(Tabular):
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1140 MetadataElement( name="flow_values", default="", no_value="", optional=True , desc="Total number of flow values", readonly=True)
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1141 MetadataElement( name="flow_order", default="TACG", no_value="TACG", desc="Total number of flow values", readonly=False)
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1142 file_ext = 'sff.flow'
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1143 """
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1144 The first line is the total number of flow values - 800 for Titanium data. For GS FLX it would be 400.
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1145 Following lines contain:
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1146 - SequenceName
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1147 - the number of useable flows as defined by 454's software
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1148 - the flow intensity for each base going in the order of TACG.
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1149 Example:
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1150 800
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1151 GQY1XT001CQL4K 85 1.04 0.00 1.00 0.02 0.03 1.02 0.05 ...
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1152 GQY1XT001CQIRF 84 1.02 0.06 0.98 0.06 0.09 1.05 0.07 ...
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1153 GQY1XT001CF5YW 88 1.02 0.02 1.01 0.04 0.06 1.02 0.03 ...
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1154 """
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1155 def __init__(self, **kwd):
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1156 Tabular.__init__( self, **kwd )
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1157
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1158 def set_meta( self, dataset, overwrite = True, skip = 1, max_data_lines = None, **kwd ):
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1159 Tabular.set_meta(self, dataset, overwrite, 1, max_data_lines)
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1160 try:
16
541e3c97c240 Mothur - fix set_meta for SffFlow in datatypes/metagenomics.py
Jim Johnson <jj@umn.edu>
parents: 15
diff changeset
1161 fh = open( dataset.file_name )
15
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1162 line = fh.readline()
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1163 line = line.strip()
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1164 flow_values = int(line)
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1165 dataset.metadata.flow_values = flow_values
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1166 finally:
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1167 fh.close()
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1168
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1169 def make_html_table( self, dataset, skipchars=[] ):
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1170 """Create HTML table, used for displaying peek"""
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1171 out = ['<table cellspacing="0" cellpadding="3">']
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1172 comments = []
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1173 try:
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1174 # Generate column header
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1175 out.append('<tr>')
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1176 out.append( '<th>%d. Name</th>' % 1 )
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1177 out.append( '<th>%d. Flows</th>' % 2 )
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1178 for i in range( 3, dataset.metadata.columns+1 ):
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1179 base = dataset.metadata.flow_order[(i+1)%4]
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1180 out.append( '<th>%d. %d %s</th>' % (i-2,base) )
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1181 out.append('</tr>')
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1182 out.append( self.make_html_peek_rows( dataset, skipchars=skipchars ) )
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1183 out.append( '</table>' )
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1184 out = "".join( out )
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1185 except Exception, exc:
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1186 out = "Can't create peek %s" % str( exc )
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1187 return out
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1188
17
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1189 class Newick( Text ):
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1190 """
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1191 The Newick Standard for representing trees in computer-readable form makes use of the correspondence between trees and nested parentheses.
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1192 http://evolution.genetics.washington.edu/phylip/newicktree.html
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1193 http://en.wikipedia.org/wiki/Newick_format
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1194 Example:
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1195 (B,(A,C,E),D);
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1196 or example with branch lengths:
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1197 (B:6.0,(A:5.0,C:3.0,E:4.0):5.0,D:11.0);
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1198 or an example with embedded comments but no branch lengths:
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1199 ((a [&&PRIME S=x], b [&&PRIME S=y]), c [&&PRIME S=z]);
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1200 Example with named interior noe:
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1201 (B:6.0,(A:5.0,C:3.0,E:4.0)Ancestor1:5.0,D:11.0);
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1202 """
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1203 file_ext = 'tre'
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1204
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1205 def __init__(self, **kwd):
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1206 Text.__init__( self, **kwd )
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1207
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1208 def sniff( self, filename ): ## TODO
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1209 """
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1210 Determine whether the file is in Newick format
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1211 Note: Last non-space char of a tree should be a semicolon: ';'
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1212 Usually the first char will be a open parenthesis: '('
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1213 (,,(,)); no nodes are named
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1214 (A,B,(C,D)); leaf nodes are named
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1215 (A,B,(C,D)E)F; all nodes are named
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1216 (:0.1,:0.2,(:0.3,:0.4):0.5); all but root node have a distance to parent
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1217 (:0.1,:0.2,(:0.3,:0.4):0.5):0.0; all have a distance to parent
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1218 (A:0.1,B:0.2,(C:0.3,D:0.4):0.5); distances and leaf names (popular)
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1219 (A:0.1,B:0.2,(C:0.3,D:0.4)E:0.5)F; distances and all names
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1220 ((B:0.2,(C:0.3,D:0.4)E:0.5)F:0.1)A; a tree rooted on a leaf node (rare)
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1221 """
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1222 if not os.path.exists(filename):
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1223 return False
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1224 try:
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1225 ## For now, guess this is a Newick file if it starts with a '(' and ends with a ';'
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1226 flen = os.path.getsize(filename)
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1227 fh = open( filename )
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1228 len = min(flen,2000)
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1229 # check end of the file for a semicolon
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1230 fh.seek(-len,os.SEEK_END)
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1231 buf = fh.read(len).strip()
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1232 buf = buf.strip()
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1233 if not buf.endswith(';'):
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1234 return False
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1235 # See if this starts with a open parenthesis
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1236 if len < flen:
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1237 fh.seek(0)
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1238 buf = fh.read(len).strip()
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1239 if buf.startswith('('):
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1240 return True
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1241 except:
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1242 pass
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1243 finally:
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1244 close(fh)
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1245 return False
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1246
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1247 class Nhx( Newick ):
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1248 """
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1249 New Hampshire eXtended Newick with embedded
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1250 The Newick Standard for representing trees in computer-readable form makes use of the correspondence between trees and nested parentheses.
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1251 http://evolution.genetics.washington.edu/phylip/newicktree.html
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1252 http://en.wikipedia.org/wiki/Newick_format
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1253 Example:
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1254 (gene1_Hu[&&NHX:S=Hu_Homo_sapiens], (gene2_Hu[&&NHX:S=Hu_Homo_sapiens], gene2_Mu[&&NHX:S=Mu_Mus_musculus]));
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1255 """
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1256 file_ext = 'nhx'
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1257
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1258 class Nexus( Text ):
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1259 """
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1260 http://en.wikipedia.org/wiki/Nexus_file
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1261 Example:
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1262 #NEXUS
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1263 BEGIN TAXA;
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1264 Dimensions NTax=4;
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1265 TaxLabels fish frog snake mouse;
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1266 END;
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1267
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1268 BEGIN CHARACTERS;
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1269 Dimensions NChar=20;
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1270 Format DataType=DNA;
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1271 Matrix
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1272 fish ACATA GAGGG TACCT CTAAG
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1273 frog ACATA GAGGG TACCT CTAAG
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1274 snake ACATA GAGGG TACCT CTAAG
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1275 mouse ACATA GAGGG TACCT CTAAG
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1276 END;
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1277
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1278 BEGIN TREES;
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1279 Tree best=(fish, (frog, (snake, mouse)));
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1280 END;
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1281 """
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1282 file_ext = 'nex'
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1283
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1284 def __init__(self, **kwd):
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1285 Text.__init__( self, **kwd )
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1286
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1287 def sniff( self, filename ):
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1288 """
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1289 Determines whether the file is in nexus format
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1290 First line should be:
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1291 #NEXUS
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1292 """
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1293 try:
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1294 fh = open( filename )
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1295 count = 0
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1296 line = fh.readline()
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1297 line = line.strip()
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1298 if line and line == '#NEXUS':
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1299 fh.close()
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1300 return True
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1301 except:
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1302 pass
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1303 finally:
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1304 fh.close()
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1305 return False
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1306
15
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1307
26
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1308 ## Biom
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1309
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1310 class BiologicalObservationMatrix( Text ):
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1311 file_ext = 'biom'
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1312 """
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1313 http://biom-format.org/documentation/biom_format.html
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1314 The format of the file is JSON:
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1315 {
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1316 "id":null,
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1317 "format": "Biological Observation Matrix 0.9.1-dev",
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1318 "format_url": "http://biom-format.org",
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1319 "type": "OTU table",
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1320 "generated_by": "QIIME revision 1.4.0-dev",
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1321 "date": "2011-12-19T19:00:00",
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1322 "rows":[
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1323 {"id":"GG_OTU_1", "metadata":null},
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1324 {"id":"GG_OTU_2", "metadata":null},
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1325 {"id":"GG_OTU_3", "metadata":null},
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1326 ],
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1327 "columns": [
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1328 {"id":"Sample1", "metadata":null},
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1329 {"id":"Sample2", "metadata":null}
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1330 ],
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1331 "matrix_type": "sparse",
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1332 "matrix_element_type": "int",
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1333 "shape": [3, 2],
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1334 "data":[[0,1,1],
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1335 [1,0,5],
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1336 [2,1,4]
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1337 ]
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1338 }
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1339
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1340 """
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1341
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1342 def __init__(self, **kwd):
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1343 Text.__init__( self, **kwd )
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1344
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1345 def sniff( self, filename ):
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1346 if os.path.getsize(filename) < 50000:
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1347 try:
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1348 data = simplejson.load(open(filename))
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1349 if data['format'].find('Biological Observation Matrix'):
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1350 return True
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1351 except:
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1352 pass
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1353 return False
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1354
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1355
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1356
5c77423823cb Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents: 25
diff changeset
1357
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1358 ## Qiime Classes
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1359
2
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1360 class QiimeMetadataMapping(Tabular):
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1361 MetadataElement( name="column_names", default=[], desc="Column Names", readonly=False, visible=True, no_value=[] )
2
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1362 file_ext = 'qiimemapping'
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1363
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1364 def __init__(self, **kwd):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1365 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1366 http://qiime.sourceforge.net/documentation/file_formats.html#mapping-file-overview
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1367 Information about the samples necessary to perform the data analysis.
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1368 # self.column_names = ['#SampleID','BarcodeSequence','LinkerPrimerSequence','Description']
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1369 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1370 Tabular.__init__( self, **kwd )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1371
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1372 def sniff( self, filename ):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1373 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1374 Determines whether the file is a qiime mapping file
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1375 Just checking for an appropriate header line for now, could be improved
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1376 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1377 try:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1378 pat = '#SampleID(\t[a-zA-Z][a-zA-Z0-9_]*)*\tDescription'
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1379 fh = open( filename )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1380 while True:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1381 line = dataset_fh.readline()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1382 if re.match(pat,line):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1383 return True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1384 except:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1385 pass
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1386 finally:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1387 close(fh)
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1388 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1389
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1390 def set_column_names(self, dataset):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1391 if dataset.has_data():
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1392 dataset_fh = open( dataset.file_name )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1393 line = dataset_fh.readline()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1394 if line.startswith('#SampleID'):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1395 dataset.metadata.column_names = line.strip().split('\t');
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1396 dataset_fh.close()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1397
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1398 def set_meta( self, dataset, overwrite = True, skip = None, max_data_lines = None, **kwd ):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1399 Tabular.set_meta(self, dataset, overwrite, skip, max_data_lines)
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1400 self.set_column_names(dataset)
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1401
2
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1402 class QiimeOTU(Tabular):
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1403 """
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1404 Associates OTUs with sequence IDs
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1405 Example:
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1406 0 FLP3FBN01C2MYD FLP3FBN01B2ALM
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1407 1 FLP3FBN01DF6NE FLP3FBN01CKW1J FLP3FBN01CHVM4
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1408 2 FLP3FBN01AXQ2Z
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1409 """
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1410 file_ext = 'qiimeotu'
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1411
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1412 class QiimeOTUTable(Tabular):
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1413 """
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1414 #Full OTU Counts
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1415 #OTU ID PC.354 PC.355 PC.356 Consensus Lineage
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1416 0 0 1 0 Root;Bacteria;Firmicutes;"Clostridia";Clostridiales
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1417 1 1 3 1 Root;Bacteria
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1418 2 0 2 2 Root;Bacteria;Bacteroidetes
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1419 """
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1420 MetadataElement( name="column_names", default=[], desc="Column Names", readonly=False, visible=True, no_value=[] )
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1421 file_ext = 'qiimeotutable'
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1422 def init_meta( self, dataset, copy_from=None ):
27
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
1423 Tabular.init_meta( self, dataset, copy_from=copy_from )
2
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1424 def set_meta( self, dataset, overwrite = True, skip = None, **kwd ):
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1425 self.set_column_names(dataset)
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1426 def set_column_names(self, dataset):
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1427 if dataset.has_data():
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1428 dataset_fh = open( dataset.file_name )
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1429 line = dataset_fh.readline()
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1430 line = dataset_fh.readline()
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1431 if line.startswith('#OTU ID'):
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1432 dataset.metadata.column_names = line.strip().split('\t');
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1433 dataset_fh.close()
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1434 dataset.metadata.comment_lines = 2
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1435
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1436 class QiimeDistanceMatrix(Tabular):
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1437 """
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1438 PC.354 PC.355 PC.356
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1439 PC.354 0.0 3.177 1.955
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1440 PC.355 3.177 0.0 3.444
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1441 PC.356 1.955 3.444 0.0
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1442 """
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1443 file_ext = 'qiimedistmat'
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1444 def init_meta( self, dataset, copy_from=None ):
27
49058b1f8d3f Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents: 26
diff changeset
1445 Tabular.init_meta( self, dataset, copy_from=copy_from )
2
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1446 def set_meta( self, dataset, overwrite = True, skip = None, **kwd ):
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1447 self.set_column_names(dataset)
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1448 def set_column_names(self, dataset):
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1449 if dataset.has_data():
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1450 dataset_fh = open( dataset.file_name )
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1451 line = dataset_fh.readline()
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1452 # first line contains the names
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1453 dataset.metadata.column_names = line.strip().split('\t');
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1454 dataset_fh.close()
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1455 dataset.metadata.comment_lines = 1
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1456
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1457 class QiimePCA(Tabular):
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1458 """
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1459 Principal Coordinate Analysis Data
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1460 The principal coordinate (PC) axes (columns) for each sample (rows).
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1461 Pairs of PCs can then be graphed to view the relationships between samples.
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1462 The bottom of the output file contains the eigenvalues and % variation explained for each PC.
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1463 Example:
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1464 pc vector number 1 2 3
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1465 PC.354 -0.309063936588 0.0398252112257 0.0744672231759
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1466 PC.355 -0.106593922619 0.141125998277 0.0780204374172
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1467 PC.356 -0.219869362955 0.00917241121781 0.0357281314115
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1468
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1469
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1470 eigvals 0.480220500471 0.163567082874 0.125594470811
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1471 % variation explained 51.6955484555 17.6079322939
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1472 """
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1473 file_ext = 'qiimepca'
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1474
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1475 class QiimeParams(Tabular):
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1476 """
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1477 ###pick_otus_through_otu_table.py parameters###
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1478
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1479 # OTU picker parameters
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1480 pick_otus:otu_picking_method uclust
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1481 pick_otus:clustering_algorithm furthest
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1482
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1483 # Representative set picker parameters
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1484 pick_rep_set:rep_set_picking_method first
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1485 pick_rep_set:sort_by otu
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1486 """
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1487 file_ext = 'qiimeparams'
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1488
17
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1489 class QiimePrefs(Text):
2
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1490 """
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1491 A text file, containing coloring preferences to be used by make_distance_histograms.py, make_2d_plots.py and make_3d_plots.py.
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1492 Example:
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1493 {
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1494 'background_color':'black',
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1495
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1496 'sample_coloring':
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1497 {
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1498 'Treatment':
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1499 {
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1500 'column':'Treatment',
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1501 'colors':(('red',(0,100,100)),('blue',(240,100,100)))
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1502 },
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1503 'DOB':
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1504 {
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1505 'column':'DOB',
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1506 'colors':(('red',(0,100,100)),('blue',(240,100,100)))
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1507 }
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1508 },
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1509 'MONTE_CARLO_GROUP_DISTANCES':
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1510 {
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1511 'Treatment': 10,
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1512 'DOB': 10
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1513 }
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1514 }
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1515 """
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1516 file_ext = 'qiimeprefs'
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1517
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1518 class QiimeTaxaSummary(Tabular):
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1519 """
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1520 Taxon PC.354 PC.355 PC.356
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1521 Root;Bacteria;Actinobacteria 0.0 0.177 0.955
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1522 Root;Bacteria;Firmicutes 0.177 0.0 0.444
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1523 Root;Bacteria;Proteobacteria 0.955 0.444 0.0
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1524 """
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1525 MetadataElement( name="column_names", default=[], desc="Column Names", readonly=False, visible=True, no_value=[] )
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1526 file_ext = 'qiimetaxsummary'
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1527
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1528 def set_column_names(self, dataset):
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1529 if dataset.has_data():
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1530 dataset_fh = open( dataset.file_name )
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1531 line = dataset_fh.readline()
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1532 if line.startswith('Taxon'):
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1533 dataset.metadata.column_names = line.strip().split('\t');
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1534 dataset_fh.close()
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1535
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1536 def set_meta( self, dataset, overwrite = True, skip = None, max_data_lines = None, **kwd ):
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1537 Tabular.set_meta(self, dataset, overwrite, skip, max_data_lines)
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1538 self.set_column_names(dataset)
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1539
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1540 if __name__ == '__main__':
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1541 import doctest, sys
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1542 doctest.testmod(sys.modules[__name__])
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1543