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