Mercurial > repos > jjohnson > mothur_toolsuite
annotate mothur/lib/galaxy/datatypes/metagenomics.py @ 0:3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
author | jjohnson |
---|---|
date | Tue, 07 Jun 2011 17:32:23 -0400 |
parents | |
children | fcc0778f6987 |
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 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
7 import data |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
8 import logging, os, sys, time, tempfile, shutil, string, glob, re |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
9 import galaxy.model |
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 import metadata |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
11 from galaxy.datatypes import tabular |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
12 from galaxy.datatypes import sequence |
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.metadata import MetadataElement |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
14 from galaxy.datatypes.tabular import Tabular |
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.sequence import Fasta |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
16 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
|
17 from galaxy.datatypes.images import Html |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
18 from sniff import * |
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 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
23 ## Mothur Classes |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
24 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
25 class Otu( data.Text ): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
26 file_ext = 'otu' |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
27 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
28 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
|
29 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
30 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
|
31 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
32 try: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
33 fh = open( filename ) |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
34 count = 0 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
35 while True: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
36 line = fh.readline() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
37 line = line.strip() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
38 if not line: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
39 break #EOF |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
40 if line: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
41 if line[0] != '@': |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
42 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
|
43 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
|
44 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
45 try: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
46 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
|
47 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
|
48 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
49 except ValueError: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
50 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
51 count += 1 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
52 if count == 5: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
53 return True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
54 fh.close() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
55 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
|
56 return True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
57 except: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
58 pass |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
59 finally: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
60 fh.close() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
61 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
62 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
63 class OtuList( Otu ): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
64 file_ext = 'list' |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
65 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
66 class Sabund( Otu ): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
67 file_ext = 'sabund' |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
68 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
69 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
|
70 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
71 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
|
72 label<TAB>count[<TAB>value(1..n)] |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
73 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
74 try: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
75 fh = open( filename ) |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
76 count = 0 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
77 while True: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
78 line = fh.readline() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
79 line = line.strip() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
80 if not line: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
81 break #EOF |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
82 if line: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
83 if line[0] != '@': |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
84 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
|
85 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
|
86 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
87 try: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
88 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
|
89 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
|
90 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
91 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
|
92 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
|
93 except ValueError: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
94 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
95 count += 1 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
96 if count >= 5: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
97 return True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
98 fh.close() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
99 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
|
100 return True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
101 except: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
102 pass |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
103 finally: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
104 fh.close() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
105 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
106 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
107 class Rabund( Sabund ): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
108 file_ext = 'rabund' |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
109 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
110 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
111 class SharedRabund( Rabund ): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
112 file_ext = 'shared' |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
113 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
114 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
|
115 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
116 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
|
117 label<TAB>group<TAB>count[<TAB>value(1..n)] |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
118 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
119 try: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
120 fh = open( filename ) |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
121 count = 0 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
122 while True: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
123 line = fh.readline() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
124 line = line.strip() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
125 if not line: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
126 break #EOF |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
127 if line: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
128 if line[0] != '@': |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
129 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
|
130 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
|
131 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
132 try: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
133 check = int(linePieces[2]) |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
134 if check + 3 != len(linePieces): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
135 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
136 for i in range( 3, len(linePieces)): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
137 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
|
138 except ValueError: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
139 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
140 count += 1 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
141 if count >= 5: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
142 return True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
143 fh.close() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
144 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
|
145 return True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
146 except: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
147 pass |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
148 finally: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
149 fh.close() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
150 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
151 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
152 class RelAbund( Rabund ): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
153 file_ext = 'relabund' |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
154 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
155 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
|
156 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
157 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
|
158 label<TAB>group<TAB>count[<TAB>value(1..n)] |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
159 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
160 try: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
161 fh = open( filename ) |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
162 count = 0 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
163 while True: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
164 line = fh.readline() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
165 line = line.strip() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
166 if not line: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
167 break #EOF |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
168 if line: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
169 if line[0] != '@': |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
170 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
|
171 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
|
172 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
173 try: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
174 check = int(linePieces[2]) |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
175 if check + 3 != len(linePieces): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
176 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
177 for i in range( 3, len(linePieces)): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
178 fval = float(linePieces[i]) |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
179 except ValueError: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
180 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
181 count += 1 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
182 if count >= 5: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
183 return True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
184 fh.close() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
185 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
|
186 return True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
187 except: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
188 pass |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
189 finally: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
190 fh.close() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
191 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
192 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
193 class SecondaryStructureMap(Tabular): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
194 file_ext = 'map' |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
195 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
|
196 """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
|
197 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
|
198 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
|
199 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
200 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
|
201 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
202 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
|
203 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
|
204 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
|
205 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
206 try: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
207 fh = open( filename ) |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
208 line_num = 0 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
209 rowidxmap = {} |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
210 while True: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
211 line = fh.readline() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
212 line_num += 1 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
213 line = line.strip() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
214 if not line: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
215 break #EOF |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
216 if line: |
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 pointer = int(line) |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
219 if pointer > 0: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
220 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
|
221 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
|
222 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
|
223 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
224 except ValueError: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
225 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
226 fh.close() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
227 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
|
228 return True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
229 except: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
230 pass |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
231 finally: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
232 fh.close() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
233 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
234 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
235 class SequenceAlignment( Fasta ): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
236 file_ext = 'align' |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
237 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
|
238 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
|
239 """Initialize AlignCheck datatype""" |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
240 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
241 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
|
242 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
243 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
|
244 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
|
245 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
246 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
247 try: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
248 fh = open( filename ) |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
249 len = -1 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
250 while True: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
251 line = fh.readline() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
252 if not line: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
253 break #EOF |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
254 line = line.strip() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
255 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
|
256 if line.startswith( '>' ): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
257 #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
|
258 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
|
259 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
|
260 break |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
261 if len < 0: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
262 len = len(line) |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
263 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
|
264 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
265 else: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
266 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
|
267 if len > 0: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
268 return True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
269 except: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
270 pass |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
271 finally: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
272 fh.close() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
273 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
274 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
275 class AlignCheck( Tabular ): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
276 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
|
277 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
|
278 """Initialize AlignCheck datatype""" |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
279 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
|
280 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
|
281 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
|
282 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
|
283 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
284 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
|
285 # 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
|
286 data_lines = 0 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
287 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
|
288 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
|
289 while True: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
290 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
|
291 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
|
292 data_lines += 1 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
293 dataset_fh.close() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
294 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
|
295 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
|
296 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
|
297 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
|
298 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
299 class AlignReport(Tabular): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
300 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
301 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
|
302 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
|
303 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
304 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
|
305 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
|
306 """Initialize AlignCheck datatype""" |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
307 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
|
308 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
|
309 '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
|
310 '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
|
311 ] |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
312 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
313 class BellerophonChimera( Tabular ): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
314 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
|
315 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
|
316 """Initialize AlignCheck datatype""" |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
317 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
|
318 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
|
319 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
320 class SecondaryStructureMatch(Tabular): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
321 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
322 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
|
323 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
|
324 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
|
325 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
|
326 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
|
327 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
|
328 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
329 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
|
330 """Initialize SecondaryStructureMatch datatype""" |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
331 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
|
332 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
|
333 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
334 class DistanceMatrix(data.Text): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
335 file_ext = 'dist' |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
336 """Add metadata elements""" |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
337 MetadataElement( name="sequence_count", default=0, desc="Number of sequences", readonly=False, optional=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
|
338 |
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 class LowerTriangleDistanceMatrix(DistanceMatrix): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
341 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
|
342 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
|
343 """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
|
344 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
|
345 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
346 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
|
347 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
348 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
|
349 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
|
350 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
|
351 5 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
352 U68589 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
353 U68590 0.3371 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
354 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
|
355 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
|
356 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
|
357 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
358 try: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
359 fh = open( filename ) |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
360 count = 0 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
361 while True: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
362 line = fh.readline() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
363 line = line.strip() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
364 if not line: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
365 break #EOF |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
366 if line: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
367 if line[0] != '@': |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
368 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
|
369 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
|
370 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
371 try: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
372 check = float(linePieces[2]) |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
373 except ValueError: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
374 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
375 count += 1 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
376 if count == 5: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
377 return True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
378 fh.close() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
379 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
|
380 return True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
381 except: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
382 pass |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
383 finally: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
384 fh.close() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
385 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
386 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
387 class SquareDistanceMatrix(DistanceMatrix,Tabular): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
388 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
|
389 sequence_count = -1 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
390 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
391 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
|
392 """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
|
393 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
|
394 def init_meta( self, dataset, copy_from=None ): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
395 data.Text.init_meta( self, dataset, copy_from=copy_from ) |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
396 def set_meta( self, dataset, overwrite = True, skip = None, **kwd ): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
397 dataset.metadata.sequences = 0 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
398 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
399 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
|
400 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
401 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
|
402 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
|
403 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
|
404 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
|
405 3 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
406 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
|
407 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
|
408 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
|
409 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
410 try: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
411 fh = open( filename ) |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
412 count = 0 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
413 line = fh.readline() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
414 line = line.strip() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
415 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
|
416 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
|
417 while True: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
418 line = fh.readline() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
419 line = line.strip() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
420 if not line: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
421 break #EOF |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
422 if line: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
423 if line[0] != '@': |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
424 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
|
425 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
|
426 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
427 try: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
428 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
|
429 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
|
430 except ValueError: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
431 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
432 count += 1 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
433 if count == 5: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
434 return True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
435 fh.close() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
436 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
|
437 return True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
438 except: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
439 pass |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
440 finally: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
441 fh.close() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
442 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
443 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
444 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
|
445 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
|
446 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
|
447 """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
|
448 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
|
449 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
|
450 self.column_types = ['str','str','float'] |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
451 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
|
452 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
453 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
|
454 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
455 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
|
456 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
|
457 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
458 try: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
459 fh = open( filename ) |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
460 count = 0 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
461 while True: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
462 line = fh.readline() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
463 line = line.strip() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
464 if not line: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
465 break #EOF |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
466 if line: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
467 if line[0] != '@': |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
468 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
|
469 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
|
470 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
471 try: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
472 check = float(linePieces[2]) |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
473 except ValueError: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
474 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
475 count += 1 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
476 if count == 5: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
477 return True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
478 fh.close() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
479 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
|
480 return True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
481 except: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
482 pass |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
483 finally: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
484 fh.close() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
485 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
486 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
487 class Alignment(Tabular): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
488 file_ext = 'align' |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
489 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
|
490 """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
|
491 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
|
492 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
|
493 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
494 class AlignCheck(Tabular): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
495 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
|
496 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
|
497 """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
|
498 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
|
499 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
|
500 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
501 class Names(Tabular): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
502 file_ext = 'names' |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
503 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
|
504 """Name file shows the relationship between a representative sequence(col 1) and the sequences it represents(col 2)""" |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
505 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
|
506 self.column_names = ['name','representatives'] |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
507 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
508 class Summary(Tabular): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
509 file_ext = 'summary' |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
510 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
|
511 """Name file shows the relationship between a representative sequence(col 1) and the sequences it represents(col 2)""" |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
512 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
|
513 self.column_names = ['seqname','start','end','nbases','ambigs','polymer'] |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
514 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
515 class Group(Tabular): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
516 file_ext = 'groups' |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
517 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
|
518 """Name file shows the relationship between a representative sequence(col 1) and the sequences it represents(col 2)""" |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
519 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
|
520 self.column_names = ['name','group'] |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
521 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
522 class AccNos(Tabular): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
523 file_ext = 'accnos' |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
524 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
|
525 """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
|
526 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
|
527 self.column_names = ['name'] |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
528 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
529 class Oligos( data.Text ): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
530 file_ext = 'oligos' |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
531 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
532 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
|
533 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
534 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
|
535 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
536 try: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
537 fh = open( filename ) |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
538 count = 0 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
539 while True: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
540 line = fh.readline() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
541 line = line.strip() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
542 if not line: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
543 break #EOF |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
544 else: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
545 if line[0] != '#': |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
546 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
|
547 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
|
548 count += 1 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
549 continue |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
550 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
|
551 count += 1 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
552 continue |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
553 else: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
554 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
555 if count > 20: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
556 return True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
557 if count > 0: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
558 return True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
559 except: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
560 pass |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
561 finally: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
562 fh.close() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
563 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
564 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
565 class Frequency(Tabular): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
566 file_ext = 'freq' |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
567 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
|
568 """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
|
569 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
|
570 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
|
571 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
|
572 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
573 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
|
574 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
575 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
|
576 #1.14.0 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
577 0 0.000 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
578 1 0.000 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
579 ... |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
580 155 0.975 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
581 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
582 try: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
583 fh = open( filename ) |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
584 count = 0 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
585 while True: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
586 line = fh.readline() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
587 line = line.strip() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
588 if not line: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
589 break #EOF |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
590 else: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
591 if line[0] != '#': |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
592 try: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
593 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
|
594 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
|
595 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
|
596 count += 1 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
597 continue |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
598 except: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
599 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
600 if count > 20: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
601 return True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
602 if count > 0: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
603 return True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
604 except: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
605 pass |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
606 finally: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
607 fh.close() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
608 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
609 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
610 class Quantile(Tabular): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
611 file_ext = 'quan' |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
612 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
|
613 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
|
614 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
|
615 """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
|
616 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
|
617 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
|
618 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
|
619 def set_meta( self, dataset, overwrite = True, skip = None, **kwd ): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
620 log.info( "Mothur Quantile set_meta %s" % kwd) |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
621 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
|
622 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
623 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
|
624 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
|
625 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
|
626 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
|
627 ... |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
628 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
629 try: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
630 fh = open( filename ) |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
631 count = 0 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
632 while True: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
633 line = fh.readline() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
634 line = line.strip() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
635 if not line: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
636 break #EOF |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
637 else: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
638 if line[0] != '#': |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
639 try: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
640 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
|
641 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
|
642 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
|
643 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
|
644 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
|
645 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
|
646 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
|
647 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
|
648 count += 1 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
649 continue |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
650 except: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
651 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
652 if count > 10: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
653 return True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
654 if count > 0: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
655 return True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
656 except: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
657 pass |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
658 finally: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
659 fh.close() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
660 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
661 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
662 class FilteredQuantile(Quantile): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
663 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
|
664 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
|
665 """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
|
666 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
|
667 self.filtered = True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
668 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
669 class MaskedQuantile(Quantile): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
670 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
|
671 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
|
672 """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
|
673 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
|
674 self.masked = True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
675 self.filtered = False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
676 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
677 class FilteredMaskedQuantile(Quantile): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
678 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
|
679 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
|
680 """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
|
681 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
|
682 self.masked = True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
683 self.filtered = True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
684 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
685 class LaneMask(data.Text): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
686 file_ext = 'filter' |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
687 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
688 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
|
689 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
690 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
|
691 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
692 try: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
693 fh = open( filename ) |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
694 while True: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
695 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
|
696 if not buff: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
697 break #EOF |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
698 else: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
699 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
|
700 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
701 return True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
702 except: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
703 pass |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
704 finally: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
705 close(fh) |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
706 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
707 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
708 class SequenceTaxonomy(Tabular): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
709 file_ext = 'taxonomy' |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
710 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
|
711 """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
|
712 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
|
713 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
|
714 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
715 class ConsensusTaxonomy(Tabular): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
716 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
|
717 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
|
718 """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
|
719 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
|
720 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
|
721 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
722 class TaxonomySummary(Tabular): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
723 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
|
724 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
|
725 """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
|
726 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
|
727 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
|
728 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
729 class Phylip(data.Text): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
730 file_ext = 'phy' |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
731 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
732 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
|
733 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
734 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
|
735 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
|
736 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
|
737 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
|
738 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
|
739 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
|
740 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
|
741 Interleaved Example: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
742 6 39 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
743 Archaeopt CGATGCTTAC CGCCGATGCT |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
744 HesperorniCGTTACTCGT TGTCGTTACT |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
745 BaluchitheTAATGTTAAT TGTTAATGTT |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
746 B. virginiTAATGTTCGT TGTTAATGTT |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
747 BrontosaurCAAAACCCAT CATCAAAACC |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
748 B.subtilisGGCAGCCAAT CACGGCAGCC |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
749 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
750 TACCGCCGAT GCTTACCGC |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
751 CGTTGTCGTT ACTCGTTGT |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
752 AATTGTTAAT GTTAATTGT |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
753 CGTTGTTAAT GTTCGTTGT |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
754 CATCATCAAA ACCCATCAT |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
755 AATCACGGCA GCCAATCAC |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
756 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
757 try: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
758 fh = open( filename ) |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
759 # counts line |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
760 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
|
761 linePieces = line.split() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
762 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
|
763 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
|
764 # data lines |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
765 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
766 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
|
767 while True: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
768 line = fh.readline() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
769 # 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
|
770 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
|
771 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
|
772 # 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
|
773 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
|
774 # 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
|
775 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
776 return True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
777 except: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
778 pass |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
779 finally: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
780 close(fh) |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
781 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
782 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
783 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
784 ## Qiime Classes |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
785 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
786 class MetadataMapping(Tabular): |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
787 MetadataElement( name="column_names", default=[], desc="Column Names", readonly=False, visible=True, no_value=[] ) |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
788 file_ext = 'mapping' |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
789 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
790 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
|
791 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
792 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
|
793 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
|
794 # 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
|
795 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
796 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
|
797 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
798 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
|
799 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
800 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
|
801 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
|
802 """ |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
803 try: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
804 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
|
805 fh = open( filename ) |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
806 while True: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
807 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
|
808 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
|
809 return True |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
810 except: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
811 pass |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
812 finally: |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
813 close(fh) |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
814 return False |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
815 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
816 def 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
|
817 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
|
818 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
|
819 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
|
820 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
|
821 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
|
822 dataset_fh.close() |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
823 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
824 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
|
825 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
|
826 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
|
827 |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
828 if __name__ == '__main__': |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
829 import doctest, sys |
3202a38e44d9
Migrated tool version 1.15.1 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff
changeset
|
830 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
|
831 |