annotate mothur/lib/galaxy/datatypes/metagenomics.py @ 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)
author Jim Johnson <jj@umn.edu>
date Wed, 16 May 2012 13:12:05 -0500
parents bfbaf823be4c
children 49058b1f8d3f
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 import data
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
10 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
11 from galaxy.datatypes import metadata
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 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 import sequence
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
14 from galaxy.datatypes.metadata import MetadataElement
17
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
15 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
16 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
17 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
18 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
19 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
20 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
21 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
22 import simplejson
0
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
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
25 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
26
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
27
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
28 ## Mothur Classes
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
29
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
30 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
31 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
32 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
33 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
34 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
35 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
36 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
37 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
38 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
39 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
40 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
41 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
42 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
43 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
44 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
45 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
46 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
47 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
48 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
49 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
50 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
51 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
52 # 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
53 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
54 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
55 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
56 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
57 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
58 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
59 fh.close()
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
60
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
61 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
62 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
63 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
64 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
65 try:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
66 fh = open( filename )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
67 count = 0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
68 while True:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
69 line = fh.readline()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
70 line = line.strip()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
71 if not line:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
72 break #EOF
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
73 if line:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
74 if line[0] != '@':
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
75 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
76 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
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 try:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
79 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
80 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
81 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
82 except ValueError:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
83 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
84 count += 1
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
85 if count == 5:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
86 return True
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 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
89 return True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
90 except:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
91 pass
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
92 finally:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
93 fh.close()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
94 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
95
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
96 class OtuList( Otu ):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
97 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
98 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
99 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
100 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
101 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
102 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
103 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
104 """
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
105 # 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
106 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
107 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
108 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
109 """
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
110
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
111 class Sabund( Otu ):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
112 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
113 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
114 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
115 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
116 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
117 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
118 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
119 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
120 label<TAB>count[<TAB>value(1..n)]
7
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
121
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
122 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
123 try:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
124 fh = open( filename )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
125 count = 0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
126 while True:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
127 line = fh.readline()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
128 line = line.strip()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
129 if not line:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
130 break #EOF
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
131 if line:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
132 if line[0] != '@':
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
133 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
134 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
135 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
136 try:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
137 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
138 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
139 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
140 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
141 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
142 except ValueError:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
143 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
144 count += 1
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
145 if count >= 5:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
146 return True
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 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
149 return True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
150 except:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
151 pass
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
152 finally:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
153 fh.close()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
154 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
155
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
156 class Rabund( Sabund ):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
157 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
158 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
159 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
160 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
161 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
162
7
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
163 class GroupAbund( Otu ):
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
164 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
165 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
166 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
167 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
168 # 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
169 # 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
170 # 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
171 """
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
172 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
173 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
174 """
7
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
175 def init_meta( self, dataset, copy_from=None ):
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
176 Otu.init_meta( self, dataset, copy_from=copy_from )
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
177 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
178 # See if file starts with header line
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
179 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
180 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
181 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
182 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
183 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
184 ncols = 0
7
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
185 try:
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
186 fh = open( dataset.file_name )
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
187 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
188 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
189 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
190 if fields[0] == 'label' and fields[1] == 'Group':
7
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
191 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
192 comment_lines += 1
7
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
193 else:
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
194 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
195 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
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 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
199 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
200 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
201 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
202 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
203 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
204 # 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
205 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
206 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
207 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
208 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
209 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
210 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
211 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
212 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
213 dataset.metadata.skip = skip
7
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
214 finally:
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
215 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
216
7
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
217 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
218 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
219 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
220 label<TAB>group<TAB>count[<TAB>value(1..n)]
7
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
221 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
222 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
223 try:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
224 fh = open( filename )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
225 count = 0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
226 while True:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
227 line = fh.readline()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
228 line = line.strip()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
229 if not line:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
230 break #EOF
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
231 if line:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
232 if line[0] != '@':
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
233 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
234 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
235 return False
7
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
236 if count > 0 or linePieces[0] != 'label':
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
237 try:
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
238 check = int(linePieces[2])
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
239 if check + 3 != len(linePieces):
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
240 return False
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
241 for i in range( 3, len(linePieces)):
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
242 if vals_are_int:
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
243 ival = int(linePieces[i])
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
244 else:
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
245 fval = float(linePieces[i])
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
246 except ValueError:
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
247 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
248 count += 1
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
249 if count >= 5:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
250 return True
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 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
253 return True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
254 except:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
255 pass
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
256 finally:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
257 fh.close()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
258 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
259
7
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
260 class SharedRabund( GroupAbund ):
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
261 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
262 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
263 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
264 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
265 GroupAbund.init_meta( self, dataset, copy_from=copy_from )
7
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
266 def sniff( self, filename ):
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
267 """
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
268 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
269 label<TAB>group<TAB>count[<TAB>value(1..n)]
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
270 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
271 """
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
272 # return GroupAbund.sniff(self,filename,True)
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
273 isme = GroupAbund.sniff(self,filename,True)
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
274 return isme
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
275
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
276
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
277 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
278 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
279 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
280 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
281 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
282 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
283 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
284 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
285 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
286 label<TAB>group<TAB>count[<TAB>value(1..n)]
7
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
287 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
288 """
7
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
289 # return GroupAbund.sniff(self,filename,False)
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
290 isme = GroupAbund.sniff(self,filename,False)
7bfe1f843858 Support Mothur v1.20
Jim Johnson <jj@umn.edu>
parents: 2
diff changeset
291 return isme
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
292
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
293 class SecondaryStructureMap(Tabular):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
294 file_ext = 'map'
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
295 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
296 """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
297 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
298 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
299
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
300 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
301 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
302 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
303 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
304 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
305 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
306 try:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
307 fh = open( filename )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
308 line_num = 0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
309 rowidxmap = {}
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
310 while True:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
311 line = fh.readline()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
312 line_num += 1
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
313 line = line.strip()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
314 if not line:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
315 break #EOF
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
316 if line:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
317 try:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
318 pointer = int(line)
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
319 if pointer > 0:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
320 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
321 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
322 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
323 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
324 except ValueError:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
325 return False
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 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
328 return True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
329 except:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
330 pass
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
331 finally:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
332 fh.close()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
333 return False
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 class SequenceAlignment( Fasta ):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
336 file_ext = 'align'
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
337 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
338 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
339 """Initialize AlignCheck datatype"""
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 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
342 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
343 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
344 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
345 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
346
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
347 try:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
348 fh = open( filename )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
349 len = -1
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
350 while True:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
351 line = fh.readline()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
352 if not line:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
353 break #EOF
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
354 line = line.strip()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
355 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
356 if line.startswith( '>' ):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
357 #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
358 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
359 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
360 break
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 len = len(line)
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
363 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
364 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
365 else:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
366 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
367 if len > 0:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
368 return True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
369 except:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
370 pass
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
371 finally:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
372 fh.close()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
373 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
374
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
375 class AlignCheck( Tabular ):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
376 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
377 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
378 """Initialize AlignCheck datatype"""
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
379 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
380 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
381 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
382 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
383
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
384 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
385 # 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
386 data_lines = 0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
387 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
388 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
389 while True:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
390 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
391 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
392 data_lines += 1
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
393 dataset_fh.close()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
394 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
395 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
396 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
397 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
398
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
399 class AlignReport(Tabular):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
400 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
401 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
402 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
403 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
404 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
405 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
406 """Initialize AlignCheck datatype"""
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
407 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
408 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
409 '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
410 '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
411 ]
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
412
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
413 class BellerophonChimera( Tabular ):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
414 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
415 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
416 """Initialize AlignCheck datatype"""
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
417 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
418 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
419
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
420 class SecondaryStructureMatch(Tabular):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
421 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
422 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
423 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
424 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
425 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
426 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
427 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
428 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
429 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
430 """Initialize SecondaryStructureMatch datatype"""
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
431 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
432 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
433
17
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
434 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
435 file_ext = 'dist'
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
436 """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
437 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
438
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 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
440 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
441
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
442 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
443 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
444 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
445 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
446 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
447 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
448 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
449 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
450 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
451 fh.close()
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
452
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
453 class LowerTriangleDistanceMatrix(DistanceMatrix):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
454 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
455 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
456 """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
457 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
458
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
459 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
460 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
461
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
462 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
463 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
464 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
465 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
466 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
467 5
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
468 U68589
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
469 U68590 0.3371
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
470 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
471 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
472 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
473 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
474 try:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
475 fh = open( filename )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
476 count = 0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
477 while True:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
478 line = fh.readline()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
479 line = line.strip()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
480 if not line:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
481 break #EOF
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
482 if line:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
483 if line[0] != '@':
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
484 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
485 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
486 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
487 try:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
488 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
489 except ValueError:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
490 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
491 count += 1
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
492 if count == 5:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
493 return True
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 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
496 return True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
497 except:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
498 pass
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
499 finally:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
500 fh.close()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
501 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
502
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 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
504 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
505
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
506 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
507 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
508 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
509 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
510
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
511 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
512 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
513 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
514 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
515 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
516 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
517 3
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
518 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
519 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
520 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
521 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
522 try:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
523 fh = open( filename )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
524 count = 0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
525 line = fh.readline()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
526 line = line.strip()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
527 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
528 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
529 while True:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
530 line = fh.readline()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
531 line = line.strip()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
532 if not line:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
533 break #EOF
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
534 if line:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
535 if line[0] != '@':
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
536 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
537 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
538 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
539 try:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
540 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
541 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
542 except ValueError:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
543 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
544 count += 1
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
545 if count == 5:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
546 return True
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 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
549 return True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
550 except:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
551 pass
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
552 finally:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
553 fh.close()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
554 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
555
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
556 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
557 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
558 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
559 """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
560 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
561 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
562 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
563 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
564 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
565
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
566 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
567 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
568 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
569 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
570 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
571 try:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
572 fh = open( filename )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
573 count = 0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
574 while True:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
575 line = fh.readline()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
576 line = line.strip()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
577 if not line:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
578 break #EOF
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
579 if line:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
580 if line[0] != '@':
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
581 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
582 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
583 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
584 try:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
585 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
586 except ValueError:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
587 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
588 count += 1
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
589 if count == 5:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
590 return True
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 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
593 return True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
594 except:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
595 pass
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
596 finally:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
597 fh.close()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
598 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
599
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
600 class AlignCheck(Tabular):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
601 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
602 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
603 """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
604 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
605 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
606 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
607
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
608 class Names(Tabular):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
609 file_ext = 'names'
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
610 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
611 """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
612 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
613 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
614 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
615
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
616 class Summary(Tabular):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
617 file_ext = 'summary'
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
618 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
619 """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
620 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
621 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
622 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
623
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
624 class Group(Tabular):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
625 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
626 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
627 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
628 """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
629 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
630 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
631 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
632 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
633 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
634 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
635 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
636 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
637 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
638 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
639 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
640 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
641 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
642 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
643 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
644
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
645 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
646 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
647 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
648 """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
649 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
650
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
651 class AccNos(Tabular):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
652 file_ext = 'accnos'
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
653 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
654 """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
655 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
656 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
657 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
658
17
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
659 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
660 file_ext = 'oligos'
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
661
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
662 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
663 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
664 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
665 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
666 try:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
667 fh = open( filename )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
668 count = 0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
669 while True:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
670 line = fh.readline()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
671 line = line.strip()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
672 if not line:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
673 break #EOF
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
674 else:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
675 if line[0] != '#':
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
676 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
677 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
678 count += 1
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
679 continue
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
680 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
681 count += 1
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
682 continue
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
683 else:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
684 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
685 if count > 20:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
686 return True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
687 if count > 0:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
688 return True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
689 except:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
690 pass
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
691 finally:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
692 fh.close()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
693 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
694
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
695 class Frequency(Tabular):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
696 file_ext = 'freq'
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
697 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
698 """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
699 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
700 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
701 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
702
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
703 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
704 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
705 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
706 #1.14.0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
707 0 0.000
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
708 1 0.000
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
709 ...
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
710 155 0.975
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
711 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
712 try:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
713 fh = open( filename )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
714 count = 0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
715 while True:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
716 line = fh.readline()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
717 line = line.strip()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
718 if not line:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
719 break #EOF
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
720 else:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
721 if line[0] != '#':
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
722 try:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
723 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
724 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
725 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
726 count += 1
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
727 continue
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 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
730 if count > 20:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
731 return True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
732 if count > 0:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
733 return True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
734 except:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
735 pass
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
736 finally:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
737 fh.close()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
738 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
739
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
740 class Quantile(Tabular):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
741 file_ext = 'quan'
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
742 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
743 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
744 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
745 """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
746 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
747 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
748 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
749 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
750 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
751 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
752 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
753 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
754 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
755 ...
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
756 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
757 try:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
758 fh = open( filename )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
759 count = 0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
760 while True:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
761 line = fh.readline()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
762 line = line.strip()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
763 if not line:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
764 break #EOF
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
765 else:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
766 if line[0] != '#':
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
767 try:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
768 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
769 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
770 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
771 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
772 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
773 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
774 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
775 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
776 count += 1
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
777 continue
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 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
780 if count > 10:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
781 return True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
782 if count > 0:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
783 return True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
784 except:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
785 pass
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
786 finally:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
787 fh.close()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
788 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
789
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
790 class FilteredQuantile(Quantile):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
791 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
792 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
793 """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
794 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
795 self.filtered = True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
796
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
797 class MaskedQuantile(Quantile):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
798 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
799 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
800 """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
801 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
802 self.masked = True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
803 self.filtered = False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
804
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
805 class FilteredMaskedQuantile(Quantile):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
806 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
807 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
808 """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
809 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
810 self.masked = True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
811 self.filtered = True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
812
17
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
813 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
814 file_ext = 'filter'
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
815
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
816 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
817 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
818 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
819 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
820 try:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
821 fh = open( filename )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
822 while True:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
823 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
824 if not buff:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
825 break #EOF
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
826 else:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
827 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
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 return True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
830 except:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
831 pass
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
832 finally:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
833 close(fh)
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
834 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
835
15
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
836 class RefTaxonomy(Tabular):
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
837 file_ext = 'ref.taxonomy'
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
838 """
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
839 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
840 - SequenceName
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
841 - 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
842 - integer ?
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
843 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
844 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
845 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
846 AF052717.1 Eukaryota;Parabasalidea;
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
847 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
848 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
849 v3_AA016 Bacteria 120
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
850 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
851 """
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
852 def __init__(self, **kwd):
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
853 Tabular.__init__( self, **kwd )
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
854 self.column_names = ['name','taxonomy']
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
855
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
856 def sniff( self, filename ):
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
857 """
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
858 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
859 """
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
860 try:
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
861 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
862 fh = open( filename )
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
863 count = 0
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
864 while True:
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
865 line = fh.readline()
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
866 if not line:
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
867 break #EOF
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
868 line = line.strip()
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
869 if line:
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
870 fields = line.split('\t')
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
871 if 2 <= len(fields) <= 3:
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
872 return False
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
873 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
874 return False
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
875 count += 1
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
876 if count > 10:
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
877 break
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
878 if count > 0:
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
879 return True
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
880 except:
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
881 pass
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
882 finally:
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
883 fh.close()
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
884 return False
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
885
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
886 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
887 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
888 """
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
889 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
890 - SequenceName
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
891 - 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
892 Example:
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
893 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
894 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
895 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
896 """
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
897 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
898 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
899 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
900
2
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
901 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
902 """
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
903 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
904 """
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
905 try:
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
906 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
907 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
908 count = 0
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
909 while True:
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
910 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
911 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
912 break #EOF
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
913 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
914 if line:
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
915 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
916 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
917 return False
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
918 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
919 return False
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
920 count += 1
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
921 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
922 break
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
923 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
924 return True
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
925 except:
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
926 pass
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
927 finally:
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
928 fh.close()
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
929 return False
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 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
932 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
933 """
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
934 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
935 - SequenceName
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
936 - 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
937 Example:
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
938 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
939 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
940 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
941 """
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
942 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
943 """
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
944 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
945 """
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
946 try:
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
947 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
948 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
949 count = 0
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
950 while True:
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
951 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
952 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
953 break #EOF
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
954 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
955 if line:
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
956 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
957 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
958 return False
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
959 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
960 return False
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
961 count += 1
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
962 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
963 break
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
964 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
965 return True
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
966 except:
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
967 pass
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
968 finally:
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
969 fh.close()
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
970 return False
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
971
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
972 class ConsensusTaxonomy(Tabular):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
973 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
974 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
975 """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
976 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
977 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
978
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
979 class TaxonomySummary(Tabular):
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
980 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
981 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
982 """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
983 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
984 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
985
17
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
986 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
987 file_ext = 'phy'
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
988
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
989 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
990 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
991 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
992 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
993 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
994 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
995 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
996 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
997 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
998 Interleaved Example:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
999 6 39
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1000 Archaeopt CGATGCTTAC CGCCGATGCT
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1001 HesperorniCGTTACTCGT TGTCGTTACT
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1002 BaluchitheTAATGTTAAT TGTTAATGTT
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1003 B. virginiTAATGTTCGT TGTTAATGTT
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1004 BrontosaurCAAAACCCAT CATCAAAACC
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1005 B.subtilisGGCAGCCAAT CACGGCAGCC
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1006
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1007 TACCGCCGAT GCTTACCGC
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1008 CGTTGTCGTT ACTCGTTGT
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1009 AATTGTTAAT GTTAATTGT
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1010 CGTTGTTAAT GTTCGTTGT
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1011 CATCATCAAA ACCCATCAT
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1012 AATCACGGCA GCCAATCAC
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1013 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1014 try:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1015 fh = open( filename )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1016 # counts line
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1017 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
1018 linePieces = line.split()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1019 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
1020 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
1021 # data lines
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1022 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1023 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
1024 while True:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1025 line = fh.readline()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1026 # 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
1027 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
1028 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
1029 # 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
1030 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
1031 # 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
1032 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1033 return True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1034 except:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1035 pass
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1036 finally:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1037 close(fh)
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1038 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1039
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1040
1
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1041 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
1042 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
1043
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1044 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
1045 """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
1046 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
1047 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
1048 """
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1049 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
1050 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
1051 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
1052 ==> 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
1053 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
1054 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
1055 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
1056
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1057 ==> 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
1058 axis1 axis2
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1059 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
1060 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
1061 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
1062 """
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1063 try:
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1064 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
1065 count = 0
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1066 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
1067 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
1068 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
1069 while True:
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1070 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
1071 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
1072 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
1073 break #EOF
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1074 if line:
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1075 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
1076 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
1077 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
1078 else:
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1079 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
1080 return False
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1081 try:
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1082 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
1083 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
1084 except ValueError:
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1085 return False
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1086 count += 1
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1087 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
1088 return True
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1089 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
1090 return True
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1091 except:
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1092 pass
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1093 finally:
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1094 fh.close()
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1095 return False
fcc0778f6987 Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 0
diff changeset
1096
15
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1097 class SffFlow(Tabular):
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1098 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
1099 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
1100 file_ext = 'sff.flow'
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1101 """
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1102 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
1103 Following lines contain:
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1104 - SequenceName
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1105 - 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
1106 - 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
1107 Example:
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1108 800
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1109 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
1110 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
1111 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
1112 """
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1113 def __init__(self, **kwd):
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1114 Tabular.__init__( self, **kwd )
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1115
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1116 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
1117 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
1118 try:
16
541e3c97c240 Mothur - fix set_meta for SffFlow in datatypes/metagenomics.py
Jim Johnson <jj@umn.edu>
parents: 15
diff changeset
1119 fh = open( dataset.file_name )
15
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1120 line = fh.readline()
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1121 line = line.strip()
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1122 flow_values = int(line)
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1123 dataset.metadata.flow_values = flow_values
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1124 finally:
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1125 fh.close()
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1126
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1127 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
1128 """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
1129 out = ['<table cellspacing="0" cellpadding="3">']
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1130 comments = []
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1131 try:
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1132 # Generate column header
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1133 out.append('<tr>')
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1134 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
1135 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
1136 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
1137 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
1138 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
1139 out.append('</tr>')
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1140 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
1141 out.append( '</table>' )
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1142 out = "".join( out )
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1143 except Exception, exc:
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1144 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
1145 return out
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1146
17
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1147 class Newick( Text ):
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1148 """
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1149 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
1150 http://evolution.genetics.washington.edu/phylip/newicktree.html
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1151 http://en.wikipedia.org/wiki/Newick_format
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1152 Example:
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1153 (B,(A,C,E),D);
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1154 or example with branch lengths:
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1155 (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
1156 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
1157 ((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
1158 Example with named interior noe:
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1159 (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
1160 """
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1161 file_ext = 'tre'
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1162
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1163 def __init__(self, **kwd):
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1164 Text.__init__( self, **kwd )
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1165
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1166 def sniff( self, filename ): ## TODO
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1167 """
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1168 Determine whether the file is in Newick format
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1169 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
1170 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
1171 (,,(,)); no nodes are named
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1172 (A,B,(C,D)); leaf nodes are named
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1173 (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
1174 (: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
1175 (: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
1176 (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
1177 (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
1178 ((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
1179 """
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1180 if not os.path.exists(filename):
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1181 return False
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1182 try:
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1183 ## 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
1184 flen = os.path.getsize(filename)
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1185 fh = open( filename )
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1186 len = min(flen,2000)
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1187 # check end of the file for a semicolon
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1188 fh.seek(-len,os.SEEK_END)
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1189 buf = fh.read(len).strip()
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1190 buf = buf.strip()
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1191 if not buf.endswith(';'):
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1192 return False
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1193 # See if this starts with a open parenthesis
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1194 if len < flen:
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1195 fh.seek(0)
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1196 buf = fh.read(len).strip()
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1197 if buf.startswith('('):
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1198 return True
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1199 except:
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1200 pass
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1201 finally:
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1202 close(fh)
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1203 return False
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 class Nhx( Newick ):
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1206 """
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1207 New Hampshire eXtended Newick with embedded
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1208 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
1209 http://evolution.genetics.washington.edu/phylip/newicktree.html
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1210 http://en.wikipedia.org/wiki/Newick_format
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1211 Example:
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1212 (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
1213 """
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1214 file_ext = 'nhx'
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1215
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1216 class Nexus( Text ):
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1217 """
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1218 http://en.wikipedia.org/wiki/Nexus_file
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1219 Example:
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1220 #NEXUS
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1221 BEGIN TAXA;
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1222 Dimensions NTax=4;
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1223 TaxLabels fish frog snake mouse;
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1224 END;
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1225
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1226 BEGIN CHARACTERS;
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1227 Dimensions NChar=20;
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1228 Format DataType=DNA;
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1229 Matrix
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1230 fish ACATA GAGGG TACCT CTAAG
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1231 frog ACATA GAGGG TACCT CTAAG
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1232 snake ACATA GAGGG TACCT CTAAG
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1233 mouse ACATA GAGGG TACCT CTAAG
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1234 END;
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1235
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1236 BEGIN TREES;
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1237 Tree best=(fish, (frog, (snake, mouse)));
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1238 END;
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1239 """
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1240 file_ext = 'nex'
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1241
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1242 def __init__(self, **kwd):
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1243 Text.__init__( self, **kwd )
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1244
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1245 def sniff( self, filename ):
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 Determines whether the file is in nexus format
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1248 First line should be:
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1249 #NEXUS
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1250 """
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1251 try:
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1252 fh = open( filename )
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1253 count = 0
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1254 line = fh.readline()
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1255 line = line.strip()
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1256 if line and line == '#NEXUS':
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1257 fh.close()
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1258 return True
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1259 except:
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1260 pass
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1261 finally:
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1262 fh.close()
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1263 return False
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1264
15
a6189f58fedb Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents: 7
diff changeset
1265
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
1266 ## 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
1267
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
1268 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
1269 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
1270 """
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
1271 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
1272 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
1273 {
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
1274 "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
1275 "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
1276 "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
1277 "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
1278 "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
1279 "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
1280 "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
1281 {"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
1282 {"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
1283 {"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
1284 ],
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
1285 "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
1286 {"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
1287 {"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
1288 ],
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
1289 "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
1290 "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
1291 "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
1292 "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
1293 [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
1294 [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
1295 ]
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
1296 }
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
1297
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
1298 """
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
1299
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
1300 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
1301 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
1302
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
1303 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
1304 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
1305 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
1306 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
1307 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
1308 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
1309 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
1310 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
1311 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
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
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
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
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1316 ## Qiime Classes
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1317
2
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1318 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
1319 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
1320 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
1321
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1322 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
1323 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1324 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
1325 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
1326 # 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
1327 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1328 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
1329
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1330 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
1331 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1332 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
1333 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
1334 """
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1335 try:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1336 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
1337 fh = open( filename )
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1338 while True:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1339 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
1340 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
1341 return True
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1342 except:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1343 pass
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1344 finally:
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1345 close(fh)
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1346 return False
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1347
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1348 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
1349 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
1350 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
1351 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
1352 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
1353 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
1354 dataset_fh.close()
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1355
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1356 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
1357 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
1358 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
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 QiimeOTU(Tabular):
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1361 """
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1362 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
1363 Example:
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1364 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
1365 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
1366 2 FLP3FBN01AXQ2Z
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1367 """
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1368 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
1369
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1370 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
1371 """
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1372 #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
1373 #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
1374 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
1375 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
1376 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
1377 """
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1378 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
1379 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
1380 def init_meta( self, dataset, copy_from=None ):
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1381 tabular.Tabular.init_meta( self, dataset, copy_from=copy_from )
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1382 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
1383 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
1384 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
1385 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
1386 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
1387 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
1388 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
1389 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
1390 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
1391 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
1392 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
1393
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1394 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
1395 """
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1396 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
1397 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
1398 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
1399 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
1400 """
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1401 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
1402 def init_meta( self, dataset, copy_from=None ):
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1403 tabular.Tabular.init_meta( self, dataset, copy_from=copy_from )
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1404 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
1405 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
1406 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
1407 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
1408 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
1409 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
1410 # 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
1411 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
1412 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
1413 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
1414
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1415 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
1416 """
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1417 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
1418 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
1419 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
1420 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
1421 Example:
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1422 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
1423 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
1424 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
1425 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
1426
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1427
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1428 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
1429 % 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
1430 """
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1431 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
1432
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1433 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
1434 """
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1435 ###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
1436
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1437 # 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
1438 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
1439 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
1440
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1441 # 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
1442 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
1443 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
1444 """
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1445 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
1446
17
57df76d861e4 Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents: 16
diff changeset
1447 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
1448 """
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1449 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
1450 Example:
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1451 {
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1452 '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
1453
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1454 'sample_coloring':
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1455 {
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1456 'Treatment':
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1457 {
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1458 'column':'Treatment',
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1459 '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
1460 },
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1461 'DOB':
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1462 {
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1463 'column':'DOB',
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1464 '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
1465 }
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1466 },
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1467 '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
1468 {
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1469 'Treatment': 10,
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1470 'DOB': 10
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1471 }
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 """
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1474 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
1475
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1476 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
1477 """
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1478 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
1479 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
1480 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
1481 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
1482 """
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1483 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
1484 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
1485
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1486 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
1487 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
1488 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
1489 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
1490 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
1491 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
1492 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
1493
e990ac8a0f58 Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents: 1
diff changeset
1494 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
1495 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
1496 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
1497
0
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1498 if __name__ == '__main__':
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1499 import doctest, sys
3202a38e44d9 Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1500 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
1501