Mercurial > repos > jjohnson > mothur_toolsuite
annotate mothur/lib/galaxy/datatypes/metagenomics.py @ 36:040410b8167e default tip
Fixed reference to legacy blast repository in tool_dependencies.xml. Updated README with author information.
author | galaxyuser <galaxy_user@agr.g.ca> |
---|---|
date | Mon, 10 Nov 2014 15:40:02 -0500 |
parents | 95d75b35e4d2 |
children |
rev | line source |
---|---|
0
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
2 metagenomics datatypes |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
3 James E Johnson - University of Minnesota |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
4 for Mothur |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
5 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
6 |
17
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
7 import logging, os, os.path, sys, time, tempfile, shutil, string, glob, re |
0
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
8 import galaxy.model |
17
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
9 from galaxy.datatypes.sniff import * |
0
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
10 from galaxy.datatypes.metadata import MetadataElement |
17
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
11 from galaxy.datatypes.data import Text |
0
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
12 from galaxy.datatypes.tabular import Tabular |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
13 from galaxy.datatypes.sequence import Fasta |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
14 from galaxy import util |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
15 from galaxy.datatypes.images import Html |
26
5c77423823cb
Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents:
25
diff
changeset
|
16 import pkg_resources |
5c77423823cb
Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents:
25
diff
changeset
|
17 pkg_resources.require("simplejson") |
5c77423823cb
Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
Jim Johnson <jj@umn.edu>
parents:
25
diff
changeset
|
18 import simplejson |
0
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
19 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
20 log = logging.getLogger(__name__) |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
21 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
22 ## Mothur Classes |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
23 |
25
bfbaf823be4c
Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents:
17
diff
changeset
|
24 class Otu( Text ): |
35
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
25 |
0
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
26 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
|
27 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
|
28 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
|
29 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
|
30 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
|
31 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
|
32 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
|
33 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
|
34 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
|
35 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
|
36 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
|
37 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
|
38 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
|
39 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
|
40 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
|
41 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
|
42 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
|
43 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
|
44 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
|
45 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
|
46 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
|
47 # 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
|
48 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
|
49 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
|
50 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
|
51 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
|
52 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
|
53 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
|
54 fh.close() |
0
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
55 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
56 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
|
57 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
58 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
|
59 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
60 try: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
61 fh = open( filename ) |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
62 count = 0 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
63 while True: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
64 line = fh.readline() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
65 line = line.strip() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
66 if not line: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
67 break #EOF |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
68 if line: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
69 if line[0] != '@': |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
70 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
|
71 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
|
72 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
73 try: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
74 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
|
75 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
|
76 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
77 except ValueError: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
78 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
79 count += 1 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
80 if count == 5: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
81 return True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
82 fh.close() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
83 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
|
84 return True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
85 except: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
86 pass |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
87 finally: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
88 fh.close() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
89 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
90 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
91 class OtuList( Otu ): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
92 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
|
93 def __init__(self, **kwd): |
30
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
94 """ |
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
95 # http://www.mothur.org/wiki/List_file |
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
96 The first column is a label that represents the distance that sequences were assigned to OTUs. |
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
97 The number in the second column is the number of OTUs that have been formed. |
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
98 Subsequent columns contain the names of sequences within each OTU separated by a comma. |
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
99 distance_label otu_count OTU1 OTU2 OTUn |
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
100 """ |
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
|
101 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
|
102 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
|
103 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
|
104 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
|
105 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
|
106 """ |
bfbaf823be4c
Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than 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 # 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
|
108 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
|
109 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
|
110 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
|
111 """ |
0
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
112 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
113 class Sabund( Otu ): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
114 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
|
115 def __init__(self, **kwd): |
30
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
116 """ |
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
117 # http://www.mothur.org/wiki/Sabund_file |
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
118 """ |
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
|
119 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
|
120 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
|
121 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
|
122 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
|
123 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
124 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
|
125 label<TAB>count[<TAB>value(1..n)] |
7 | 126 |
0
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
127 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
128 try: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
129 fh = open( filename ) |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
130 count = 0 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
131 while True: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
132 line = fh.readline() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
133 line = line.strip() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
134 if not line: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
135 break #EOF |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
136 if line: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
137 if line[0] != '@': |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
138 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
|
139 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
|
140 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
141 try: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
142 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
|
143 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
|
144 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
145 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
|
146 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
|
147 except ValueError: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
148 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
149 count += 1 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
150 if count >= 5: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
151 return True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
152 fh.close() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
153 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
|
154 return True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
155 except: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
156 pass |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
157 finally: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
158 fh.close() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
159 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
160 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
161 class Rabund( Sabund ): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
162 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
|
163 def __init__(self, **kwd): |
30
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
164 """ |
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
165 # http://www.mothur.org/wiki/Rabund_file |
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
166 """ |
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
|
167 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
|
168 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
|
169 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
|
170 |
7 | 171 class GroupAbund( Otu ): |
172 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
|
173 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
|
174 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
|
175 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
|
176 # 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
|
177 # 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
|
178 # 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
|
179 """ |
bfbaf823be4c
Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than 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 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
|
181 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
|
182 """ |
7 | 183 def init_meta( self, dataset, copy_from=None ): |
184 Otu.init_meta( self, dataset, copy_from=copy_from ) | |
185 def set_meta( self, dataset, overwrite = True, skip=1, max_data_lines = 100000, **kwd ): | |
186 # See if file starts with header line | |
187 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
|
188 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
|
189 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
|
190 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
|
191 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
|
192 ncols = 0 |
7 | 193 try: |
194 fh = open( dataset.file_name ) | |
195 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
|
196 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
|
197 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
|
198 if fields[0] == 'label' and fields[1] == 'Group': |
7 | 199 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
|
200 comment_lines += 1 |
7 | 201 else: |
202 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
|
203 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
|
204 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
|
205 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
|
206 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
|
207 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
|
208 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
|
209 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
|
210 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
|
211 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
|
212 # 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
|
213 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
|
214 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
|
215 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
|
216 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
|
217 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
|
218 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
|
219 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
|
220 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
|
221 dataset.metadata.skip = skip |
7 | 222 finally: |
223 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
|
224 |
7 | 225 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
|
226 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
227 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
|
228 label<TAB>group<TAB>count[<TAB>value(1..n)] |
7 | 229 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
|
230 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
231 try: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
232 fh = open( filename ) |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
233 count = 0 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
234 while True: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
235 line = fh.readline() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
236 line = line.strip() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
237 if not line: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
238 break #EOF |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
239 if line: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
240 if line[0] != '@': |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
241 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
|
242 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
|
243 return False |
7 | 244 if count > 0 or linePieces[0] != 'label': |
245 try: | |
246 check = int(linePieces[2]) | |
247 if check + 3 != len(linePieces): | |
248 return False | |
249 for i in range( 3, len(linePieces)): | |
250 if vals_are_int: | |
251 ival = int(linePieces[i]) | |
252 else: | |
253 fval = float(linePieces[i]) | |
254 except ValueError: | |
0
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
255 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
256 count += 1 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
257 if count >= 5: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
258 return True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
259 fh.close() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
260 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
|
261 return True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
262 except: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
263 pass |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
264 finally: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
265 fh.close() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
266 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
267 |
7 | 268 class SharedRabund( GroupAbund ): |
269 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
|
270 def __init__(self, **kwd): |
30
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
271 """ |
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
272 # http://www.mothur.org/wiki/Shared_file |
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
273 A shared file is analogous to an rabund file. |
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
274 The data in a shared file represent the number of times that an OTU is observed in multiple samples. |
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
275 The structure of a shared file is analogous to an rabund file. |
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
276 The first column contains the label for the comparison - this will be the value for the first column of each line from the original list file. |
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
277 The second column contains the group name that designates where the data is coming from for that row. |
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
278 The third column is the number of OTUs that were found between each of the groups and is the number of columns that follow. |
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
279 Finally, the remaining columns indicate the number of sequences that belonged to each OTU from that group. |
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
280 """ |
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
|
281 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
|
282 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
|
283 GroupAbund.init_meta( self, dataset, copy_from=copy_from ) |
7 | 284 def sniff( self, filename ): |
285 """ | |
286 Determines whether the file is a otu (operational taxonomic unit) Shared format | |
287 label<TAB>group<TAB>count[<TAB>value(1..n)] | |
288 The first line is column headings as of Mothur v 1.20 | |
289 """ | |
290 # return GroupAbund.sniff(self,filename,True) | |
291 isme = GroupAbund.sniff(self,filename,True) | |
292 return isme | |
293 | |
294 | |
295 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
|
296 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
|
297 def __init__(self, **kwd): |
30
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
298 """ |
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
299 # http://www.mothur.org/wiki/Relabund_file |
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
300 The structure of a relabund file is analogous to an shared file. |
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
301 The first column contains the label for the comparison - this will be the value for the first column of each line from the original list file (e.g. final.an.list). |
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
302 The second column contains the group name that designates where the data is coming from for that row. Next is the number of OTUs that were found between each of the groups and is the number of columns that follow. |
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
303 Finally, the remaining columns indicate the relative abundance of each OTU from that group. |
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
304 """ |
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
|
305 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
|
306 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
|
307 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
|
308 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
|
309 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
310 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
|
311 label<TAB>group<TAB>count[<TAB>value(1..n)] |
7 | 312 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
|
313 """ |
7 | 314 # return GroupAbund.sniff(self,filename,False) |
315 isme = GroupAbund.sniff(self,filename,False) | |
316 return isme | |
0
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
317 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
318 class SecondaryStructureMap(Tabular): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
319 file_ext = 'map' |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
320 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
|
321 """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
|
322 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
|
323 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
|
324 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
325 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
|
326 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
327 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
|
328 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
|
329 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
|
330 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
331 try: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
332 fh = open( filename ) |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
333 line_num = 0 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
334 rowidxmap = {} |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
335 while True: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
336 line = fh.readline() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
337 line_num += 1 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
338 line = line.strip() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
339 if not line: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
340 break #EOF |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
341 if line: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
342 try: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
343 pointer = int(line) |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
344 if pointer > 0: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
345 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
|
346 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
|
347 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
|
348 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
349 except ValueError: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
350 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
351 fh.close() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
352 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
|
353 return True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
354 except: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
355 pass |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
356 finally: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
357 fh.close() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
358 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
359 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
360 class SequenceAlignment( Fasta ): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
361 file_ext = 'align' |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
362 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
|
363 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
|
364 """Initialize AlignCheck datatype""" |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
365 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
366 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
|
367 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
368 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
|
369 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
|
370 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
371 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
372 try: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
373 fh = open( filename ) |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
374 len = -1 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
375 while True: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
376 line = fh.readline() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
377 if not line: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
378 break #EOF |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
379 line = line.strip() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
380 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
|
381 if line.startswith( '>' ): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
382 #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
|
383 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
|
384 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
|
385 break |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
386 if len < 0: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
387 len = len(line) |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
388 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
|
389 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
390 else: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
391 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
|
392 if len > 0: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
393 return True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
394 except: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
395 pass |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
396 finally: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
397 fh.close() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
398 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
399 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
400 class AlignCheck( Tabular ): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
401 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
|
402 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
|
403 """Initialize AlignCheck datatype""" |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
404 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
|
405 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
|
406 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
|
407 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
|
408 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
409 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
|
410 # 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
|
411 data_lines = 0 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
412 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
|
413 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
|
414 while True: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
415 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
|
416 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
|
417 data_lines += 1 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
418 dataset_fh.close() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
419 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
|
420 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
|
421 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
|
422 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
|
423 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
424 class AlignReport(Tabular): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
425 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
426 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
|
427 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
|
428 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
429 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
|
430 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
|
431 """Initialize AlignCheck datatype""" |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
432 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
|
433 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
|
434 '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
|
435 '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
|
436 ] |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
437 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
438 class BellerophonChimera( Tabular ): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
439 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
|
440 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
|
441 """Initialize AlignCheck datatype""" |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
442 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
|
443 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
|
444 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
445 class SecondaryStructureMatch(Tabular): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
446 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
447 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
|
448 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
|
449 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
|
450 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
|
451 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
|
452 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
|
453 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
454 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
|
455 """Initialize SecondaryStructureMatch datatype""" |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
456 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
|
457 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
|
458 |
17
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
459 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
|
460 file_ext = 'dist' |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
461 """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
|
462 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
|
463 |
bfbaf823be4c
Change metagenomics datatypes to include labels and groups metadata. change Mothur tool configs to get label and group select options from a data_meta filter rather than using the options from_dataset attribute. This grealty decreases memory demand for the galaxy server.
Jim Johnson <jj@umn.edu>
parents:
17
diff
changeset
|
464 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
|
465 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
|
466 |
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
|
467 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
|
468 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
|
469 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
|
470 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
|
471 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
|
472 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
|
473 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
|
474 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
|
475 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
|
476 fh.close() |
0
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
477 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
478 class LowerTriangleDistanceMatrix(DistanceMatrix): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
479 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
|
480 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
|
481 """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
|
482 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
|
483 |
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
|
484 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
|
485 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
|
486 |
0
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
487 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
|
488 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
489 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
|
490 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
|
491 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
|
492 5 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
493 U68589 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
494 U68590 0.3371 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
495 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
|
496 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
|
497 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
|
498 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
499 try: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
500 fh = open( filename ) |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
501 count = 0 |
29
9c0cd3b92295
Fixes for metagenomics.py datatypes tahnks to Peter Briggs
Jim Johnson <jj@umn.edu>
parents:
27
diff
changeset
|
502 line = fh.readline() |
9c0cd3b92295
Fixes for metagenomics.py datatypes tahnks to Peter Briggs
Jim Johnson <jj@umn.edu>
parents:
27
diff
changeset
|
503 sequence_count = int(line.strip()) |
0
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
504 while True: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
505 line = fh.readline() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
506 line = line.strip() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
507 if not line: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
508 break #EOF |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
509 if line: |
29
9c0cd3b92295
Fixes for metagenomics.py datatypes tahnks to Peter Briggs
Jim Johnson <jj@umn.edu>
parents:
27
diff
changeset
|
510 # Split into fields |
9c0cd3b92295
Fixes for metagenomics.py datatypes tahnks to Peter Briggs
Jim Johnson <jj@umn.edu>
parents:
27
diff
changeset
|
511 linePieces = line.split('\t') |
9c0cd3b92295
Fixes for metagenomics.py datatypes tahnks to Peter Briggs
Jim Johnson <jj@umn.edu>
parents:
27
diff
changeset
|
512 # Each line should have the same number of |
9c0cd3b92295
Fixes for metagenomics.py datatypes tahnks to Peter Briggs
Jim Johnson <jj@umn.edu>
parents:
27
diff
changeset
|
513 # fields as the Python line index |
9c0cd3b92295
Fixes for metagenomics.py datatypes tahnks to Peter Briggs
Jim Johnson <jj@umn.edu>
parents:
27
diff
changeset
|
514 linePieces = line.split('\t') |
9c0cd3b92295
Fixes for metagenomics.py datatypes tahnks to Peter Briggs
Jim Johnson <jj@umn.edu>
parents:
27
diff
changeset
|
515 if len(linePieces) != (count + 1): |
9c0cd3b92295
Fixes for metagenomics.py datatypes tahnks to Peter Briggs
Jim Johnson <jj@umn.edu>
parents:
27
diff
changeset
|
516 return False |
9c0cd3b92295
Fixes for metagenomics.py datatypes tahnks to Peter Briggs
Jim Johnson <jj@umn.edu>
parents:
27
diff
changeset
|
517 # Distances should be floats |
9c0cd3b92295
Fixes for metagenomics.py datatypes tahnks to Peter Briggs
Jim Johnson <jj@umn.edu>
parents:
27
diff
changeset
|
518 try: |
9c0cd3b92295
Fixes for metagenomics.py datatypes tahnks to Peter Briggs
Jim Johnson <jj@umn.edu>
parents:
27
diff
changeset
|
519 for linePiece in linePieces[2:]: |
9c0cd3b92295
Fixes for metagenomics.py datatypes tahnks to Peter Briggs
Jim Johnson <jj@umn.edu>
parents:
27
diff
changeset
|
520 check = float(linePiece) |
9c0cd3b92295
Fixes for metagenomics.py datatypes tahnks to Peter Briggs
Jim Johnson <jj@umn.edu>
parents:
27
diff
changeset
|
521 except ValueError: |
9c0cd3b92295
Fixes for metagenomics.py datatypes tahnks to Peter Briggs
Jim Johnson <jj@umn.edu>
parents:
27
diff
changeset
|
522 return False |
9c0cd3b92295
Fixes for metagenomics.py datatypes tahnks to Peter Briggs
Jim Johnson <jj@umn.edu>
parents:
27
diff
changeset
|
523 # Increment line counter |
9c0cd3b92295
Fixes for metagenomics.py datatypes tahnks to Peter Briggs
Jim Johnson <jj@umn.edu>
parents:
27
diff
changeset
|
524 count += 1 |
9c0cd3b92295
Fixes for metagenomics.py datatypes tahnks to Peter Briggs
Jim Johnson <jj@umn.edu>
parents:
27
diff
changeset
|
525 # Only check first 5 lines |
9c0cd3b92295
Fixes for metagenomics.py datatypes tahnks to Peter Briggs
Jim Johnson <jj@umn.edu>
parents:
27
diff
changeset
|
526 if count == 5: |
9c0cd3b92295
Fixes for metagenomics.py datatypes tahnks to Peter Briggs
Jim Johnson <jj@umn.edu>
parents:
27
diff
changeset
|
527 return True |
0
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
528 fh.close() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
529 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
|
530 return True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
531 except: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
532 pass |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
533 finally: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
534 fh.close() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
535 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
536 |
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
|
537 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
|
538 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
|
539 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
540 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
|
541 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
|
542 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
|
543 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
|
544 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
545 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
|
546 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
547 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
|
548 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
|
549 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
|
550 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
|
551 3 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
552 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
|
553 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
|
554 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
|
555 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
556 try: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
557 fh = open( filename ) |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
558 count = 0 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
559 line = fh.readline() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
560 line = line.strip() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
561 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
|
562 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
|
563 while True: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
564 line = fh.readline() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
565 line = line.strip() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
566 if not line: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
567 break #EOF |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
568 if line: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
569 if line[0] != '@': |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
570 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
|
571 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
|
572 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
573 try: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
574 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
|
575 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
|
576 except ValueError: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
577 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
578 count += 1 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
579 if count == 5: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
580 return True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
581 fh.close() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
582 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
|
583 return True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
584 except: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
585 pass |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
586 finally: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
587 fh.close() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
588 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
589 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
590 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
|
591 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
|
592 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
|
593 """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
|
594 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
|
595 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
|
596 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
|
597 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
|
598 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
|
599 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
600 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
|
601 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
602 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
|
603 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
|
604 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
605 try: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
606 fh = open( filename ) |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
607 count = 0 |
29
9c0cd3b92295
Fixes for metagenomics.py datatypes tahnks to Peter Briggs
Jim Johnson <jj@umn.edu>
parents:
27
diff
changeset
|
608 all_ints = True |
0
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
609 while True: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
610 line = fh.readline() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
611 line = line.strip() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
612 if not line: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
613 break #EOF |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
614 if line: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
615 if line[0] != '@': |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
616 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
|
617 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
|
618 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
619 try: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
620 check = float(linePieces[2]) |
29
9c0cd3b92295
Fixes for metagenomics.py datatypes tahnks to Peter Briggs
Jim Johnson <jj@umn.edu>
parents:
27
diff
changeset
|
621 try: |
9c0cd3b92295
Fixes for metagenomics.py datatypes tahnks to Peter Briggs
Jim Johnson <jj@umn.edu>
parents:
27
diff
changeset
|
622 # See if it's also an integer |
9c0cd3b92295
Fixes for metagenomics.py datatypes tahnks to Peter Briggs
Jim Johnson <jj@umn.edu>
parents:
27
diff
changeset
|
623 check_int = int(linePieces[2]) |
9c0cd3b92295
Fixes for metagenomics.py datatypes tahnks to Peter Briggs
Jim Johnson <jj@umn.edu>
parents:
27
diff
changeset
|
624 except ValueError: |
9c0cd3b92295
Fixes for metagenomics.py datatypes tahnks to Peter Briggs
Jim Johnson <jj@umn.edu>
parents:
27
diff
changeset
|
625 # At least one value is not an |
9c0cd3b92295
Fixes for metagenomics.py datatypes tahnks to Peter Briggs
Jim Johnson <jj@umn.edu>
parents:
27
diff
changeset
|
626 # integer |
9c0cd3b92295
Fixes for metagenomics.py datatypes tahnks to Peter Briggs
Jim Johnson <jj@umn.edu>
parents:
27
diff
changeset
|
627 all_ints = False |
0
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
628 except ValueError: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
629 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
630 count += 1 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
631 if count == 5: |
29
9c0cd3b92295
Fixes for metagenomics.py datatypes tahnks to Peter Briggs
Jim Johnson <jj@umn.edu>
parents:
27
diff
changeset
|
632 if not all_ints: |
9c0cd3b92295
Fixes for metagenomics.py datatypes tahnks to Peter Briggs
Jim Johnson <jj@umn.edu>
parents:
27
diff
changeset
|
633 return True |
9c0cd3b92295
Fixes for metagenomics.py datatypes tahnks to Peter Briggs
Jim Johnson <jj@umn.edu>
parents:
27
diff
changeset
|
634 else: |
9c0cd3b92295
Fixes for metagenomics.py datatypes tahnks to Peter Briggs
Jim Johnson <jj@umn.edu>
parents:
27
diff
changeset
|
635 return False |
0
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
636 fh.close() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
637 if count < 5 and count > 0: |
29
9c0cd3b92295
Fixes for metagenomics.py datatypes tahnks to Peter Briggs
Jim Johnson <jj@umn.edu>
parents:
27
diff
changeset
|
638 if not all_ints: |
9c0cd3b92295
Fixes for metagenomics.py datatypes tahnks to Peter Briggs
Jim Johnson <jj@umn.edu>
parents:
27
diff
changeset
|
639 return True |
9c0cd3b92295
Fixes for metagenomics.py datatypes tahnks to Peter Briggs
Jim Johnson <jj@umn.edu>
parents:
27
diff
changeset
|
640 else: |
9c0cd3b92295
Fixes for metagenomics.py datatypes tahnks to Peter Briggs
Jim Johnson <jj@umn.edu>
parents:
27
diff
changeset
|
641 return False |
0
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
642 except: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
643 pass |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
644 finally: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
645 fh.close() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
646 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
647 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
648 class AlignCheck(Tabular): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
649 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
|
650 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
|
651 """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
|
652 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
|
653 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
|
654 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
|
655 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
656 class Names(Tabular): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
657 file_ext = 'names' |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
658 def __init__(self, **kwd): |
30
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
659 """ |
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
660 # http://www.mothur.org/wiki/Name_file |
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
661 Name file shows the relationship between a representative sequence(col 1) and the sequences(comma-separated) it represents(col 2) |
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
662 """ |
0
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
663 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
|
664 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
|
665 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
|
666 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
667 class Summary(Tabular): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
668 file_ext = 'summary' |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
669 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
|
670 """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
|
671 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
|
672 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
|
673 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
|
674 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
675 class Group(Tabular): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
676 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
|
677 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
|
678 def __init__(self, **kwd): |
30
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
679 """ |
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
680 # http://www.mothur.org/wiki/Groups_file |
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
681 Group file assigns sequence (col 1) to a group (col 2) |
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
682 """ |
0
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
683 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
|
684 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
|
685 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
|
686 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
|
687 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
|
688 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
|
689 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
|
690 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
|
691 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
|
692 fields = line.strip().split('\t') |
32 | 693 try: |
694 group_names.add(fields[1]) | |
695 except IndexError: | |
696 # Ignore missing 2nd column | |
697 pass | |
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
|
698 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
|
699 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
|
700 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
|
701 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
|
702 |
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
|
703 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
|
704 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
|
705 def __init__(self, **kwd): |
30
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
706 """ |
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
707 # http://www.mothur.org/wiki/Design_File |
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
708 Design file shows the relationship between a group(col 1) and a grouping (col 2), providing a way to merge groups. |
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
709 """ |
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
|
710 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
|
711 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
712 class AccNos(Tabular): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
713 file_ext = 'accnos' |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
714 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
|
715 """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
|
716 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
|
717 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
|
718 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
|
719 |
17
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
720 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
|
721 file_ext = 'oligos' |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
722 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
723 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
|
724 """ |
30
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
725 # http://www.mothur.org/wiki/Oligos_File |
0
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
726 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
|
727 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
728 try: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
729 fh = open( filename ) |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
730 count = 0 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
731 while True: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
732 line = fh.readline() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
733 line = line.strip() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
734 if not line: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
735 break #EOF |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
736 else: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
737 if line[0] != '#': |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
738 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
|
739 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
|
740 count += 1 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
741 continue |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
742 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
|
743 count += 1 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
744 continue |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
745 else: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
746 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
747 if count > 20: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
748 return True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
749 if count > 0: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
750 return True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
751 except: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
752 pass |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
753 finally: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
754 fh.close() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
755 return False |
35
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
756 """ |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
757 class OtuMap( Tabular ): |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
758 file_ext = 'otu_map' |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
759 |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
760 def __init__(self, **kwd): |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
761 Tabular.__init__(self,**kwd) |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
762 self.column_names = ['catdog','dog'] |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
763 self.column_types = ['int','float'] |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
764 |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
765 def sniff(self, filename): #sniffer that detects whether it's an otu table. |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
766 #it appears that self refers to the object passed in, and filename will be the name of the file? |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
767 try: |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
768 fh = open( filename) |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
769 line = fh.readline() |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
770 line = line.strip() |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
771 if line[0] != '#': |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
772 return False |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
773 count=0 |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
774 while True: |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
775 #go thru the file. |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
776 line = fh.readline() |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
777 line = line.strip() |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
778 if not line: |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
779 break |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
780 else: |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
781 if line[0] != '#': |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
782 try: |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
783 linePieces = line.split('\t') |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
784 i = int(linePieces[0]) |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
785 f = float(linePieces[1]) |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
786 continue |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
787 except: |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
788 return False |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
789 #went through the file, can split! |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
790 return True |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
791 except: |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
792 #failed to open file ? |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
793 pass |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
794 finally: |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
795 fh.close() |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
796 #at this point we might as well return false.. |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
797 return False |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
798 """ |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
799 class Metadata ( Tabular ): |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
800 file_ext='metadata' |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
801 """ |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
802 group dpw description |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
803 F003D000 0 "F003D000 description" |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
804 F003D002 2 "F003D002 description" |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
805 F003D004 4 "F003D004 description" |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
806 F003D006 6 "F003D006 description" |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
807 F003D008 8 "F003D008 description" |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
808 F003D142 142 "F003D142 description" |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
809 F003D144 144 "F003D144 description" |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
810 F003D146 146 "F003D146 description" |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
811 F003D148 148 "F003D148 description" |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
812 F003D150 150 "F003D150 description" |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
813 MOCK.GQY1XT001 12 "MOCK.GQY1XT001 description" |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
814 """ |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
815 def __init__(self, **kwd): |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
816 Tabular.__init__( self, **kwd ) |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
817 self.column_names = ['group','dpw','description'] |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
818 self.column_types = ['string','int','string'] |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
819 |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
820 def sniff (self,filename): |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
821 try: |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
822 fh = open (filename) |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
823 line = fh.readline() |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
824 line = line.strip() |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
825 headers = line.split('\t') |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
826 #check the header for the needed |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
827 if headers[0] == "group" and headers[1] == "dpw" and headers[2] == "description": |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
828 return True |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
829 except: |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
830 pass |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
831 finally: |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
832 fh.close() |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
833 return False |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
834 |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
835 |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
836 |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
837 class OtuMap(Tabular): |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
838 file_ext = 'otu_map' |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
839 def __init__(self, **kwd): |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
840 """A list of names""" |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
841 Tabular.__init__( self, **kwd ) |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
842 self.column_names = ['OTU','SEQIDS'] |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
843 self.column_types = ['int','float'] |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
844 |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
845 def sniff( self, filename ): |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
846 """ |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
847 Determines whether the file is a frequency tabular format for chimera analysis |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
848 #1.14.0 |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
849 0 0.000 |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
850 1 0.000 |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
851 ... |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
852 155 0.975 |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
853 """ |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
854 try: |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
855 fh = open( filename ) |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
856 count = 0 |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
857 while True: |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
858 line = fh.readline() |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
859 line = line.strip() |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
860 if not line: |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
861 break #EOF |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
862 else: |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
863 if line[0] != '#': |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
864 try: |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
865 linePieces = line.split('\t') |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
866 i = int(linePieces[0]) |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
867 continue |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
868 except: |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
869 return False |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
870 return True |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
871 except: |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
872 pass |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
873 finally: |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
874 fh.close() |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
875 return False |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
876 |
0
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
877 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
878 class Frequency(Tabular): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
879 file_ext = 'freq' |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
880 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
|
881 """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
|
882 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
|
883 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
|
884 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
|
885 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
886 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
|
887 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
888 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
|
889 #1.14.0 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
890 0 0.000 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
891 1 0.000 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
892 ... |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
893 155 0.975 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
894 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
895 try: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
896 fh = open( filename ) |
35
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
897 #checks first line for # |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
898 line = fh.readline() |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
899 line = line.strip() |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
900 if line[0] != '#': |
95d75b35e4d2
Updated tools to use Mothur 1.33. Added some misc. fixes and updates (blast repository, tool fixes)
certain cat
parents:
32
diff
changeset
|
901 return False |
0
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
902 count = 0 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
903 while True: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
904 line = fh.readline() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
905 line = line.strip() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
906 if not line: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
907 break #EOF |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
908 else: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
909 if line[0] != '#': |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
910 try: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
911 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
|
912 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
|
913 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
|
914 count += 1 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
915 continue |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
916 except: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
917 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
918 if count > 20: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
919 return True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
920 if count > 0: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
921 return True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
922 except: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
923 pass |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
924 finally: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
925 fh.close() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
926 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
927 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
928 class Quantile(Tabular): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
929 file_ext = 'quan' |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
930 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
|
931 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
|
932 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
|
933 """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
|
934 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
|
935 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
|
936 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
|
937 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
|
938 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
939 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
|
940 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
|
941 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
|
942 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
|
943 ... |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
944 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
945 try: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
946 fh = open( filename ) |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
947 count = 0 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
948 while True: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
949 line = fh.readline() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
950 line = line.strip() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
951 if not line: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
952 break #EOF |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
953 else: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
954 if line[0] != '#': |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
955 try: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
956 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
|
957 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
|
958 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
|
959 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
|
960 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
|
961 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
|
962 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
|
963 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
|
964 count += 1 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
965 continue |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
966 except: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
967 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
968 if count > 10: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
969 return True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
970 if count > 0: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
971 return True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
972 except: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
973 pass |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
974 finally: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
975 fh.close() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
976 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
977 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
978 class FilteredQuantile(Quantile): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
979 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
|
980 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
|
981 """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
|
982 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
|
983 self.filtered = True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
984 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
985 class MaskedQuantile(Quantile): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
986 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
|
987 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
|
988 """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
|
989 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
|
990 self.masked = True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
991 self.filtered = False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
992 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
993 class FilteredMaskedQuantile(Quantile): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
994 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
|
995 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
|
996 """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
|
997 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
|
998 self.masked = True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
999 self.filtered = True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1000 |
17
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1001 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
|
1002 file_ext = 'filter' |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1003 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1004 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
|
1005 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1006 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
|
1007 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1008 try: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1009 fh = open( filename ) |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1010 while True: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1011 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
|
1012 if not buff: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1013 break #EOF |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1014 else: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1015 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
|
1016 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1017 return True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1018 except: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1019 pass |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1020 finally: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1021 close(fh) |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1022 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1023 |
27
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1024 class CountTable(Tabular): |
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1025 MetadataElement( name="groups", default=[], desc="Group Names", readonly=True, visible=True, no_value=[] ) |
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1026 file_ext = 'count_table' |
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1027 |
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1028 def __init__(self, **kwd): |
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1029 """ |
30
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
1030 # http://www.mothur.org/wiki/Count_File |
27
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1031 A table with first column names and following columns integer counts |
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1032 # Example 1: |
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1033 Representative_Sequence total |
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1034 U68630 1 |
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1035 U68595 1 |
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1036 U68600 1 |
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1037 # Example 2 (with group columns): |
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1038 Representative_Sequence total forest pasture |
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1039 U68630 1 1 0 |
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1040 U68595 1 1 0 |
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1041 U68600 1 1 0 |
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1042 U68591 1 1 0 |
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1043 U68647 1 0 1 |
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1044 """ |
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1045 Tabular.__init__( self, **kwd ) |
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1046 self.column_names = ['name','total'] |
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1047 |
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1048 def set_meta( self, dataset, overwrite = True, skip = 1, max_data_lines = None, **kwd ): |
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1049 try: |
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1050 data_lines = 0; |
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1051 fh = open( dataset.file_name ) |
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1052 line = fh.readline() |
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1053 if line: |
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1054 line = line.strip() |
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1055 colnames = line.split() |
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1056 if len(colnames) > 1: |
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1057 dataset.metadata.columns = len( colnames ) |
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1058 if len(colnames) > 2: |
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1059 dataset.metadata.groups = colnames[2:] |
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1060 column_types = ['str'] |
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1061 for i in range(1,len(colnames)): |
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1062 column_types.append('int') |
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1063 dataset.metadata.column_types = column_types |
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1064 dataset.metadata.comment_lines = 1 |
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1065 while line: |
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1066 line = fh.readline() |
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1067 if not line: break |
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1068 data_lines += 1 |
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1069 dataset.metadata.data_lines = data_lines |
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1070 finally: |
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1071 close(fh) |
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1072 |
15
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1073 class RefTaxonomy(Tabular): |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1074 file_ext = 'ref.taxonomy' |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1075 """ |
30
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
1076 # http://www.mothur.org/wiki/Taxonomy_outline |
15
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1077 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
|
1078 - SequenceName |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1079 - 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
|
1080 - integer ? |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1081 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
|
1082 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
|
1083 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
|
1084 AF052717.1 Eukaryota;Parabasalidea; |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1085 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
|
1086 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
|
1087 v3_AA016 Bacteria 120 |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1088 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
|
1089 """ |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1090 def __init__(self, **kwd): |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1091 Tabular.__init__( self, **kwd ) |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1092 self.column_names = ['name','taxonomy'] |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1093 |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1094 def sniff( self, filename ): |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1095 """ |
30
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
1096 Determines whether the file is a Reference Taxonomy |
15
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1097 """ |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1098 try: |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1099 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
|
1100 fh = open( filename ) |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1101 count = 0 |
30
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
1102 # VAMPS taxonomy files do not require a semicolon after the last taxonomy category |
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
1103 # but assume assume the file will have some multi-level taxonomy assignments |
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
1104 found_semicolons = False |
15
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1105 while True: |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1106 line = fh.readline() |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1107 if not line: |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1108 break #EOF |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1109 line = line.strip() |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1110 if line: |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1111 fields = line.split('\t') |
29
9c0cd3b92295
Fixes for metagenomics.py datatypes tahnks to Peter Briggs
Jim Johnson <jj@umn.edu>
parents:
27
diff
changeset
|
1112 if not (2 <= len(fields) <= 3): |
15
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1113 return False |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1114 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
|
1115 return False |
30
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
1116 if not found_semicolons and str(fields[1]).count(';') > 0: |
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
1117 found_semicolons = True |
29
9c0cd3b92295
Fixes for metagenomics.py datatypes tahnks to Peter Briggs
Jim Johnson <jj@umn.edu>
parents:
27
diff
changeset
|
1118 if len(fields) == 3: |
9c0cd3b92295
Fixes for metagenomics.py datatypes tahnks to Peter Briggs
Jim Johnson <jj@umn.edu>
parents:
27
diff
changeset
|
1119 check = int(fields[2]) |
15
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1120 count += 1 |
30
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
1121 if count > 100: |
15
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1122 break |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1123 if count > 0: |
30
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
1124 # This will be true if at least one entry |
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
1125 # has semicolons in the 2nd column |
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
1126 return found_semicolons |
15
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1127 except: |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1128 pass |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1129 finally: |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1130 fh.close() |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1131 return False |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1132 |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1133 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
|
1134 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
|
1135 """ |
30
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
1136 # http://www.mothur.org/wiki/Taxonomy_outline |
2
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1137 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
|
1138 - SequenceName |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1139 - 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
|
1140 Example: |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1141 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
|
1142 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
|
1143 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
|
1144 """ |
0
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1145 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
|
1146 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
|
1147 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
|
1148 |
2
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1149 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
|
1150 """ |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1151 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
|
1152 """ |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1153 try: |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1154 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
|
1155 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
|
1156 count = 0 |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1157 while True: |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1158 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
|
1159 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
|
1160 break #EOF |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1161 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
|
1162 if line: |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1163 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
|
1164 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
|
1165 return False |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1166 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
|
1167 return False |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1168 count += 1 |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1169 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
|
1170 break |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1171 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
|
1172 return True |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1173 except: |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1174 pass |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1175 finally: |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1176 fh.close() |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1177 return False |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1178 |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1179 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
|
1180 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
|
1181 """ |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1182 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
|
1183 - SequenceName |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1184 - 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
|
1185 Example: |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1186 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
|
1187 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
|
1188 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
|
1189 """ |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1190 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
|
1191 """ |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1192 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
|
1193 """ |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1194 try: |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1195 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
|
1196 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
|
1197 count = 0 |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1198 while True: |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1199 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
|
1200 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
|
1201 break #EOF |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1202 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
|
1203 if line: |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1204 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
|
1205 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
|
1206 return False |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1207 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
|
1208 return False |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1209 count += 1 |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1210 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
|
1211 break |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1212 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
|
1213 return True |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1214 except: |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1215 pass |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1216 finally: |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1217 fh.close() |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1218 return False |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1219 |
0
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1220 class ConsensusTaxonomy(Tabular): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1221 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
|
1222 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
|
1223 """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
|
1224 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
|
1225 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
|
1226 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1227 class TaxonomySummary(Tabular): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1228 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
|
1229 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
|
1230 """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
|
1231 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
|
1232 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
|
1233 |
17
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1234 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
|
1235 file_ext = 'phy' |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1236 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1237 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
|
1238 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1239 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
|
1240 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
|
1241 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
|
1242 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
|
1243 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
|
1244 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
|
1245 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
|
1246 Interleaved Example: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1247 6 39 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1248 Archaeopt CGATGCTTAC CGCCGATGCT |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1249 HesperorniCGTTACTCGT TGTCGTTACT |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1250 BaluchitheTAATGTTAAT TGTTAATGTT |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1251 B. virginiTAATGTTCGT TGTTAATGTT |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1252 BrontosaurCAAAACCCAT CATCAAAACC |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1253 B.subtilisGGCAGCCAAT CACGGCAGCC |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1254 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1255 TACCGCCGAT GCTTACCGC |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1256 CGTTGTCGTT ACTCGTTGT |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1257 AATTGTTAAT GTTAATTGT |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1258 CGTTGTTAAT GTTCGTTGT |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1259 CATCATCAAA ACCCATCAT |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1260 AATCACGGCA GCCAATCAC |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1261 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1262 try: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1263 fh = open( filename ) |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1264 # counts line |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1265 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
|
1266 linePieces = line.split() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1267 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
|
1268 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
|
1269 # data lines |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1270 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1271 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
|
1272 while True: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1273 line = fh.readline() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1274 # 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
|
1275 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
|
1276 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
|
1277 # 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
|
1278 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
|
1279 # 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
|
1280 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1281 return True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1282 except: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1283 pass |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1284 finally: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1285 close(fh) |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1286 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1287 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1288 |
1
fcc0778f6987
Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
0
diff
changeset
|
1289 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
|
1290 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
|
1291 |
fcc0778f6987
Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
0
diff
changeset
|
1292 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
|
1293 """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
|
1294 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
|
1295 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
|
1296 """ |
fcc0778f6987
Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
0
diff
changeset
|
1297 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
|
1298 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
|
1299 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
|
1300 ==> 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
|
1301 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
|
1302 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
|
1303 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
|
1304 |
fcc0778f6987
Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
0
diff
changeset
|
1305 ==> 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
|
1306 axis1 axis2 |
fcc0778f6987
Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
0
diff
changeset
|
1307 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
|
1308 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
|
1309 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
|
1310 """ |
fcc0778f6987
Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
0
diff
changeset
|
1311 try: |
fcc0778f6987
Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
0
diff
changeset
|
1312 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
|
1313 count = 0 |
fcc0778f6987
Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
0
diff
changeset
|
1314 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
|
1315 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
|
1316 col_cnt = None |
30
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
1317 all_integers = True |
1
fcc0778f6987
Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
0
diff
changeset
|
1318 while True: |
fcc0778f6987
Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
0
diff
changeset
|
1319 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
|
1320 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
|
1321 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
|
1322 break #EOF |
fcc0778f6987
Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
0
diff
changeset
|
1323 if line: |
fcc0778f6987
Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
0
diff
changeset
|
1324 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
|
1325 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
|
1326 col_cnt = len(fields) |
29
9c0cd3b92295
Fixes for metagenomics.py datatypes tahnks to Peter Briggs
Jim Johnson <jj@umn.edu>
parents:
27
diff
changeset
|
1327 # There should be at least 2 columns |
9c0cd3b92295
Fixes for metagenomics.py datatypes tahnks to Peter Briggs
Jim Johnson <jj@umn.edu>
parents:
27
diff
changeset
|
1328 if col_cnt < 2: |
9c0cd3b92295
Fixes for metagenomics.py datatypes tahnks to Peter Briggs
Jim Johnson <jj@umn.edu>
parents:
27
diff
changeset
|
1329 return False |
1
fcc0778f6987
Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
0
diff
changeset
|
1330 else: |
fcc0778f6987
Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
0
diff
changeset
|
1331 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
|
1332 return False |
fcc0778f6987
Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
0
diff
changeset
|
1333 try: |
fcc0778f6987
Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
0
diff
changeset
|
1334 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
|
1335 check = float(fields[i]) |
32 | 1336 # Check abs value is <= 1.0 |
1337 if abs(check) > 1.0: | |
1338 return False | |
30
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
1339 # Also test for whether value is an integer |
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
1340 try: |
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
1341 check = int(fields[i]) |
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
1342 except ValueError: |
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
1343 all_integers = False |
1
fcc0778f6987
Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
0
diff
changeset
|
1344 except ValueError: |
fcc0778f6987
Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
0
diff
changeset
|
1345 return False |
fcc0778f6987
Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
0
diff
changeset
|
1346 count += 1 |
fcc0778f6987
Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
0
diff
changeset
|
1347 if count > 10: |
30
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
1348 break |
1
fcc0778f6987
Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
0
diff
changeset
|
1349 if count > 0: |
30
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
1350 if not all_integers: |
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
1351 # At least one value was a float |
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
1352 return True |
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
1353 else: |
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
1354 return False |
1
fcc0778f6987
Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
0
diff
changeset
|
1355 except: |
fcc0778f6987
Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
0
diff
changeset
|
1356 pass |
fcc0778f6987
Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
0
diff
changeset
|
1357 finally: |
fcc0778f6987
Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
0
diff
changeset
|
1358 fh.close() |
fcc0778f6987
Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
0
diff
changeset
|
1359 return False |
fcc0778f6987
Migrated tool version 1.16.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
0
diff
changeset
|
1360 |
15
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1361 class SffFlow(Tabular): |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1362 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
|
1363 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
|
1364 file_ext = 'sff.flow' |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1365 """ |
30
a90d1915a176
metagenomics.py - require ref.taxonomy sniff to find at least 1 multi-level tax assignment with semicolon separators
Jim Johnson <jj@umn.edu>
parents:
29
diff
changeset
|
1366 # http://www.mothur.org/wiki/Flow_file |
15
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1367 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
|
1368 Following lines contain: |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1369 - SequenceName |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1370 - 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
|
1371 - 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
|
1372 Example: |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1373 800 |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1374 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
|
1375 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
|
1376 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
|
1377 """ |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1378 def __init__(self, **kwd): |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1379 Tabular.__init__( self, **kwd ) |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1380 |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1381 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
|
1382 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
|
1383 try: |
16
541e3c97c240
Mothur - fix set_meta for SffFlow in datatypes/metagenomics.py
Jim Johnson <jj@umn.edu>
parents:
15
diff
changeset
|
1384 fh = open( dataset.file_name ) |
15
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1385 line = fh.readline() |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1386 line = line.strip() |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1387 flow_values = int(line) |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1388 dataset.metadata.flow_values = flow_values |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1389 finally: |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1390 fh.close() |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1391 |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1392 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
|
1393 """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
|
1394 out = ['<table cellspacing="0" cellpadding="3">'] |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1395 comments = [] |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1396 try: |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1397 # Generate column header |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1398 out.append('<tr>') |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1399 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
|
1400 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
|
1401 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
|
1402 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
|
1403 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
|
1404 out.append('</tr>') |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1405 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
|
1406 out.append( '</table>' ) |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1407 out = "".join( out ) |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1408 except Exception, exc: |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1409 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
|
1410 return out |
a6189f58fedb
Mothur - updated for Mothur version 1.22.0
Jim Johnson <jj@umn.edu>
parents:
7
diff
changeset
|
1411 |
17
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1412 class Newick( Text ): |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1413 """ |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1414 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
|
1415 http://evolution.genetics.washington.edu/phylip/newicktree.html |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1416 http://en.wikipedia.org/wiki/Newick_format |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1417 Example: |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1418 (B,(A,C,E),D); |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1419 or example with branch lengths: |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1420 (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
|
1421 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
|
1422 ((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
|
1423 Example with named interior noe: |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1424 (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
|
1425 """ |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1426 file_ext = 'tre' |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1427 |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1428 def __init__(self, **kwd): |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1429 Text.__init__( self, **kwd ) |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1430 |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1431 def sniff( self, filename ): ## TODO |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1432 """ |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1433 Determine whether the file is in Newick format |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1434 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
|
1435 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
|
1436 (,,(,)); no nodes are named |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1437 (A,B,(C,D)); leaf nodes are named |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1438 (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
|
1439 (: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
|
1440 (: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
|
1441 (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
|
1442 (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
|
1443 ((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
|
1444 """ |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1445 if not os.path.exists(filename): |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1446 return False |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1447 try: |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1448 ## 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
|
1449 flen = os.path.getsize(filename) |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1450 fh = open( filename ) |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1451 len = min(flen,2000) |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1452 # check end of the file for a semicolon |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1453 fh.seek(-len,os.SEEK_END) |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1454 buf = fh.read(len).strip() |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1455 buf = buf.strip() |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1456 if not buf.endswith(';'): |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1457 return False |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1458 # See if this starts with a open parenthesis |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1459 if len < flen: |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1460 fh.seek(0) |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1461 buf = fh.read(len).strip() |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1462 if buf.startswith('('): |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1463 return True |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1464 except: |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1465 pass |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1466 finally: |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1467 close(fh) |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1468 return False |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1469 |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1470 class Nhx( Newick ): |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1471 """ |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1472 New Hampshire eXtended Newick with embedded |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1473 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
|
1474 http://evolution.genetics.washington.edu/phylip/newicktree.html |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1475 http://en.wikipedia.org/wiki/Newick_format |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1476 Example: |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1477 (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
|
1478 """ |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1479 file_ext = 'nhx' |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1480 |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1481 class Nexus( Text ): |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1482 """ |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1483 http://en.wikipedia.org/wiki/Nexus_file |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1484 Example: |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1485 #NEXUS |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1486 BEGIN TAXA; |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1487 Dimensions NTax=4; |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1488 TaxLabels fish frog snake mouse; |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1489 END; |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1490 |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1491 BEGIN CHARACTERS; |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1492 Dimensions NChar=20; |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1493 Format DataType=DNA; |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1494 Matrix |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1495 fish ACATA GAGGG TACCT CTAAG |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1496 frog ACATA GAGGG TACCT CTAAG |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1497 snake ACATA GAGGG TACCT CTAAG |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1498 mouse ACATA GAGGG TACCT CTAAG |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1499 END; |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1500 |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1501 BEGIN TREES; |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1502 Tree best=(fish, (frog, (snake, mouse))); |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1503 END; |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1504 """ |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1505 file_ext = 'nex' |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1506 |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1507 def __init__(self, **kwd): |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1508 Text.__init__( self, **kwd ) |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1509 |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1510 def sniff( self, filename ): |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1511 """ |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1512 Determines whether the file is in nexus format |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1513 First line should be: |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1514 #NEXUS |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1515 """ |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1516 try: |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1517 fh = open( filename ) |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1518 count = 0 |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1519 line = fh.readline() |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1520 line = line.strip() |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1521 if line and line == '#NEXUS': |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1522 fh.close() |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1523 return True |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1524 except: |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1525 pass |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1526 finally: |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1527 fh.close() |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1528 return False |
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1529 |
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
|
1530 ## 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
|
1531 |
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
|
1532 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
|
1533 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
|
1534 """ |
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
|
1535 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
|
1536 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
|
1537 { |
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
|
1538 "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
|
1539 "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
|
1540 "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
|
1541 "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
|
1542 "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
|
1543 "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
|
1544 "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
|
1545 {"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
|
1546 {"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
|
1547 {"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
|
1548 ], |
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
|
1549 "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
|
1550 {"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
|
1551 {"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
|
1552 ], |
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
|
1553 "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
|
1554 "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
|
1555 "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
|
1556 "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
|
1557 [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
|
1558 [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
|
1559 ] |
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
|
1560 } |
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
|
1561 |
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
|
1562 """ |
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
|
1563 |
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
|
1564 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
|
1565 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
|
1566 |
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
|
1567 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
|
1568 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
|
1569 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
|
1570 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
|
1571 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
|
1572 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
|
1573 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
|
1574 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
|
1575 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
|
1576 |
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
|
1577 |
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
|
1578 |
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
|
1579 |
0
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1580 ## Qiime Classes |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1581 |
2
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1582 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
|
1583 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
|
1584 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
|
1585 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1586 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
|
1587 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1588 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
|
1589 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
|
1590 # 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
|
1591 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1592 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
|
1593 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1594 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
|
1595 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1596 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
|
1597 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
|
1598 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1599 try: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1600 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
|
1601 fh = open( filename ) |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1602 while True: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1603 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
|
1604 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
|
1605 return True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1606 except: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1607 pass |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1608 finally: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1609 close(fh) |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1610 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1611 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1612 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
|
1613 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
|
1614 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
|
1615 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
|
1616 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
|
1617 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
|
1618 dataset_fh.close() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1619 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1620 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
|
1621 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
|
1622 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
|
1623 |
2
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1624 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
|
1625 """ |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1626 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
|
1627 Example: |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1628 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
|
1629 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
|
1630 2 FLP3FBN01AXQ2Z |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1631 """ |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1632 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
|
1633 |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1634 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
|
1635 """ |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1636 #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
|
1637 #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
|
1638 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
|
1639 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
|
1640 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
|
1641 """ |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1642 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
|
1643 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
|
1644 def init_meta( self, dataset, copy_from=None ): |
27
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1645 Tabular.init_meta( self, dataset, copy_from=copy_from ) |
2
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1646 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
|
1647 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
|
1648 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
|
1649 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
|
1650 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
|
1651 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
|
1652 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
|
1653 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
|
1654 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
|
1655 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
|
1656 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
|
1657 |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1658 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
|
1659 """ |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1660 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
|
1661 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
|
1662 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
|
1663 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
|
1664 """ |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1665 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
|
1666 def init_meta( self, dataset, copy_from=None ): |
27
49058b1f8d3f
Update to mothur version 1.27 and add tool_dependencies.xml to automatically install mothur
Jim Johnson <jj@umn.edu>
parents:
26
diff
changeset
|
1667 Tabular.init_meta( self, dataset, copy_from=copy_from ) |
2
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1668 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
|
1669 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
|
1670 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
|
1671 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
|
1672 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
|
1673 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
|
1674 # 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
|
1675 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
|
1676 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
|
1677 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
|
1678 |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1679 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
|
1680 """ |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1681 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
|
1682 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
|
1683 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
|
1684 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
|
1685 Example: |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1686 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
|
1687 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
|
1688 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
|
1689 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
|
1690 |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1691 |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1692 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
|
1693 % 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
|
1694 """ |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1695 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
|
1696 |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1697 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
|
1698 """ |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1699 ###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
|
1700 |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1701 # 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
|
1702 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
|
1703 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
|
1704 |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1705 # 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
|
1706 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
|
1707 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
|
1708 """ |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1709 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
|
1710 |
17
57df76d861e4
Modifications for ToolShed proprietary data types
Jim Johnson <jj@umn.edu>
parents:
16
diff
changeset
|
1711 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
|
1712 """ |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1713 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
|
1714 Example: |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1715 { |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1716 '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
|
1717 |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1718 'sample_coloring': |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1719 { |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1720 'Treatment': |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1721 { |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1722 'column':'Treatment', |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1723 '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
|
1724 }, |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1725 'DOB': |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1726 { |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1727 'column':'DOB', |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1728 '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
|
1729 } |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1730 }, |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1731 '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
|
1732 { |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1733 'Treatment': 10, |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1734 'DOB': 10 |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1735 } |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1736 } |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1737 """ |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1738 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
|
1739 |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1740 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
|
1741 """ |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1742 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
|
1743 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
|
1744 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
|
1745 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
|
1746 """ |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1747 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
|
1748 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
|
1749 |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1750 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
|
1751 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
|
1752 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
|
1753 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
|
1754 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
|
1755 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
|
1756 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
|
1757 |
e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
1
diff
changeset
|
1758 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
|
1759 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
|
1760 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
|
1761 |
0
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1762 if __name__ == '__main__': |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1763 import doctest, sys |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
1764 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
|
1765 |