mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-28 02:58:18 +08:00
additional linting of datatypes to make it more strict
This commit is contained in:
committed by
Nicola Soranzo
parent
1dab5f9384
commit
f1fa2ab316
@@ -71,4 +71,5 @@ def __main__():
|
||||
info_msg += "Skipped %d blank/comment/invalid lines starting with line #%d." % ( skipped_lines, first_skipped_line )
|
||||
print info_msg
|
||||
|
||||
if __name__ == "__main__": __main__()
|
||||
if __name__ == "__main__":
|
||||
__main__()
|
||||
|
||||
@@ -5,8 +5,7 @@ Output: tabular
|
||||
Return titles with lengths of corresponding seq
|
||||
"""
|
||||
|
||||
import sys, os
|
||||
|
||||
import sys
|
||||
assert sys.version_info[:2] >= ( 2, 4 )
|
||||
|
||||
|
||||
@@ -32,7 +31,7 @@ def compute_fasta_length( fasta_file, out_file, keep_first_char, keep_first_word
|
||||
if not line or line.startswith( '#' ):
|
||||
continue
|
||||
if line[0] == '>':
|
||||
if first_entry == False:
|
||||
if first_entry is False:
|
||||
if keep_first_word:
|
||||
fasta_title = fasta_title.split()[0]
|
||||
out.write( "%s\t%d\n" % ( fasta_title[ 1:keep_first_char ], seq_len ) )
|
||||
|
||||
@@ -11,7 +11,8 @@ Input: fasta
|
||||
Output: tabular
|
||||
"""
|
||||
|
||||
import sys, os
|
||||
import sys
|
||||
import os
|
||||
|
||||
seq_hash = {}
|
||||
|
||||
@@ -47,4 +48,5 @@ def __main__():
|
||||
out.write("".join(sequence.split()) + '\n')
|
||||
|
||||
|
||||
if __name__ == "__main__" : __main__()
|
||||
if __name__ == "__main__" :
|
||||
__main__()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys, os, gzip
|
||||
import sys
|
||||
from galaxy.datatypes.checkers import is_gzip
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ def main():
|
||||
|
||||
in_file = open(input_fname)
|
||||
|
||||
out_file.write('{"sections" : [');
|
||||
out_file.write('{"sections" : [')
|
||||
|
||||
for line in in_file:
|
||||
current_line += 1
|
||||
|
||||
@@ -14,9 +14,7 @@ Usage:
|
||||
%python fastqsolexa_to_fasta_converter.py <your_fastqsolexa_filename> <output_seq_filename> <output_score_filename>
|
||||
"""
|
||||
|
||||
import sys, os
|
||||
from math import *
|
||||
|
||||
import sys
|
||||
assert sys.version_info[:2] >= ( 2, 4 )
|
||||
|
||||
|
||||
@@ -43,15 +41,14 @@ def __main__():
|
||||
seq_title_startswith = line_startswith
|
||||
if seq_title_startswith != line_startswith:
|
||||
stop_err( 'Invalid fastqsolexa format at line %d: %s.' % ( i + 1, line ) )
|
||||
read_title = line[ 1: ]
|
||||
outfile.write( '>%s\n' % line[1:] )
|
||||
elif fastq_block_lines == 2:
|
||||
# line 2 is nucleotides
|
||||
read_length = len( line )
|
||||
outfile.write( '%s\n' % line )
|
||||
else:
|
||||
pass
|
||||
|
||||
outfile.close()
|
||||
|
||||
if __name__ == "__main__": __main__()
|
||||
if __name__ == "__main__":
|
||||
__main__()
|
||||
|
||||
@@ -13,8 +13,7 @@ the order should be:
|
||||
Usage:
|
||||
%python fastqsolexa_to_qual_converter.py <your_fastqsolexa_filename> <output_seq_filename> <output_score_filename>
|
||||
"""
|
||||
import sys, os
|
||||
from math import *
|
||||
import sys
|
||||
|
||||
assert sys.version_info[:2] >= ( 2, 4 )
|
||||
|
||||
@@ -27,7 +26,7 @@ def stop_err( msg ):
|
||||
def __main__():
|
||||
infile_name = sys.argv[1]
|
||||
outfile_score = open( sys.argv[2], 'w' )
|
||||
datatype = sys.argv[3]
|
||||
# datatype = sys.argv[3]
|
||||
qual_title_startswith = ''
|
||||
seq_title_startswith = ''
|
||||
default_coding_value = 64
|
||||
@@ -70,7 +69,7 @@ def __main__():
|
||||
val = line.split()[0]
|
||||
|
||||
try:
|
||||
check = int( val )
|
||||
int( val )
|
||||
fastq_integer = True
|
||||
except:
|
||||
fastq_integer = False
|
||||
@@ -94,4 +93,5 @@ def __main__():
|
||||
|
||||
outfile_score.close()
|
||||
|
||||
if __name__ == "__main__": __main__()
|
||||
if __name__ == "__main__":
|
||||
__main__()
|
||||
|
||||
@@ -40,4 +40,5 @@ def __main__():
|
||||
info_msg += "Skipped %d blank/comment/invalid lines starting with line #%d." % ( skipped_lines, first_skipped_line )
|
||||
print info_msg
|
||||
|
||||
if __name__ == "__main__": __main__()
|
||||
if __name__ == "__main__":
|
||||
__main__()
|
||||
|
||||
@@ -9,10 +9,12 @@ usage:
|
||||
|
||||
from __future__ import division
|
||||
|
||||
import sys, fileinput
|
||||
from galaxy import eggs
|
||||
import pkg_resources; pkg_resources.require( "bx-python" )
|
||||
from galaxy.datatypes.util.gff_util import *
|
||||
import sys
|
||||
import fileinput
|
||||
import pkg_resources
|
||||
pkg_resources.require( "bx-python" )
|
||||
|
||||
from galaxy.datatypes.util.gff_util import GFFReaderWrapper, GenomicInterval, convert_gff_coords_to_bed
|
||||
from bx.interval_index_file import Indexes
|
||||
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
# Dan Blankenberg
|
||||
|
||||
import sys
|
||||
from galaxy import eggs
|
||||
import pkg_resources; pkg_resources.require( "bx-python" )
|
||||
import pkg_resources
|
||||
pkg_resources.require( "bx-python" )
|
||||
import bx.intervals.io
|
||||
|
||||
assert sys.version_info[:2] >= ( 2, 4 )
|
||||
@@ -51,7 +51,7 @@ def __main__():
|
||||
name = "region_%i" % count
|
||||
try:
|
||||
|
||||
out.write( "%s\t%i\t%i\t%s\t%i\t%s\n" % ( region.chrom, region.start, region.end, name, 0, region.strand ) )
|
||||
out.write( "%s\t%i\t%i\t%s\t%i\t%s\n" % ( region.chrom, region.start, region.end, name, 0, region.strand ) )
|
||||
except:
|
||||
skipped_lines += 1
|
||||
if not first_skipped_line:
|
||||
@@ -61,4 +61,5 @@ def __main__():
|
||||
if skipped_lines > 0:
|
||||
print "Skipped %d blank or invalid lines starting with line # %d." % ( skipped_lines, first_skipped_line )
|
||||
|
||||
if __name__ == "__main__": __main__()
|
||||
if __name__ == "__main__":
|
||||
__main__()
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
# Dan Blankenberg
|
||||
|
||||
import sys
|
||||
from galaxy import eggs
|
||||
import pkg_resources; pkg_resources.require( "bx-python" )
|
||||
import pkg_resources
|
||||
pkg_resources.require( "bx-python" )
|
||||
import bx.intervals.io
|
||||
|
||||
assert sys.version_info[:2] >= ( 2, 4 )
|
||||
@@ -153,4 +153,5 @@ def __main__():
|
||||
if skipped_lines > 0:
|
||||
print "Skipped %d blank or invalid lines starting with line # %d." % ( skipped_lines, first_skipped_line )
|
||||
|
||||
if __name__ == "__main__": __main__()
|
||||
if __name__ == "__main__":
|
||||
__main__()
|
||||
|
||||
@@ -6,14 +6,12 @@ usage: %prog bed_file out_file
|
||||
-1, --cols1=N,N,N,N: Columns for chrom, start, end, strand in interval file
|
||||
-2, --cols2=N,N,N,N: Columns for chrom, start, end, strand in coverage file
|
||||
"""
|
||||
import sys
|
||||
from galaxy import eggs
|
||||
import pkg_resources; pkg_resources.require( "bx-python" )
|
||||
import pkg_resources
|
||||
pkg_resources.require( "bx-python" )
|
||||
from bx.intervals import io
|
||||
from bx.cookbook import doc_optparse
|
||||
import psyco_full
|
||||
import commands
|
||||
import os
|
||||
from os import environ
|
||||
import tempfile
|
||||
from bisect import bisect
|
||||
@@ -41,7 +39,6 @@ def main( interval, coverage ):
|
||||
partitions = []
|
||||
forward_covs = []
|
||||
reverse_covs = []
|
||||
offset = 0
|
||||
chrom = None
|
||||
lastchrom = None
|
||||
for record in interval:
|
||||
@@ -114,7 +111,8 @@ class CoverageWriter( object ):
|
||||
self.template = "%(0)s\t%(1)s\t%(2)s\t%(3)s\n" % positions
|
||||
|
||||
def write(self, **kwargs ):
|
||||
if self.reverseCol < 0: kwargs['forward'] += kwargs['reverse']
|
||||
if self.reverseCol < 0:
|
||||
kwargs['forward'] += kwargs['reverse']
|
||||
posgen = kwargs['position']
|
||||
for position in posgen:
|
||||
kwargs['position'] = position
|
||||
|
||||
@@ -13,10 +13,9 @@ where location is formatted as:
|
||||
|
||||
and symbols are sorted in lexigraphical order.
|
||||
'''
|
||||
|
||||
import sys, optparse
|
||||
from galaxy import eggs
|
||||
import pkg_resources; pkg_resources.require( "bx-python" )
|
||||
import optparse
|
||||
import pkg_resources
|
||||
pkg_resources.require( "bx-python" )
|
||||
from bx.tabular.io import Comment
|
||||
from galaxy.datatypes.util.gff_util import GFFReaderWrapper, read_unordered_gtf, convert_gff_coords_to_bed
|
||||
|
||||
@@ -83,7 +82,7 @@ def main():
|
||||
name_loc_dict[ fields[3] ] = {
|
||||
'contig': fields[0],
|
||||
'start': int( fields[1] ),
|
||||
'end': int ( fields[2] )
|
||||
'end': int( fields[2] )
|
||||
}
|
||||
|
||||
# Create sorted list of entries.
|
||||
|
||||
@@ -7,9 +7,12 @@ Supported presets: bed, gff, vcf
|
||||
usage: %prog in_file out_file
|
||||
"""
|
||||
|
||||
from galaxy import eggs
|
||||
import pkg_resources; pkg_resources.require( "pysam" )
|
||||
import ctabix, subprocess, tempfile, sys, os, optparse
|
||||
import pkg_resources
|
||||
pkg_resources.require( "pysam" )
|
||||
import ctabix
|
||||
import sys
|
||||
import os
|
||||
import optparse
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
# much slower so best to always
|
||||
# use numeric alleles internally
|
||||
|
||||
import sys, os, time
|
||||
import sys
|
||||
import os
|
||||
import time
|
||||
|
||||
|
||||
prog = os.path.split(sys.argv[0])[-1]
|
||||
|
||||
@@ -4,8 +4,10 @@
|
||||
# eg lped/eigen/fbat/snpmatrix all to pbed
|
||||
# and pbed to lped/eigen/fbat/snpmatrix ?
|
||||
# that's a lot of converters
|
||||
import sys, os, time, subprocess
|
||||
|
||||
import sys
|
||||
import os
|
||||
import time
|
||||
import subprocess
|
||||
|
||||
prog = os.path.split(sys.argv[0])[-1]
|
||||
myversion = 'Oct 10 2009'
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
# Dan Blankenberg
|
||||
|
||||
import sys
|
||||
from galaxy import eggs
|
||||
import pkg_resources; pkg_resources.require( "bx-python" )
|
||||
import pkg_resources
|
||||
pkg_resources.require( "bx-python" )
|
||||
import bx.align.maf
|
||||
from galaxy.tools.util import maf_utilities
|
||||
|
||||
@@ -30,4 +30,5 @@ def __main__():
|
||||
print "%i MAF blocks converted to FASTA." % ( count )
|
||||
|
||||
|
||||
if __name__ == "__main__": __main__()
|
||||
if __name__ == "__main__":
|
||||
__main__()
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
# Dan Blankenberg
|
||||
|
||||
import sys
|
||||
from galaxy import eggs
|
||||
import pkg_resources; pkg_resources.require( "bx-python" )
|
||||
import pkg_resources
|
||||
pkg_resources.require( "bx-python" )
|
||||
import bx.align.maf
|
||||
from galaxy.tools.util import maf_utilities
|
||||
|
||||
@@ -22,7 +22,7 @@ def __main__():
|
||||
for block in bx.align.maf.Reader( open( input_name, 'r' ) ):
|
||||
for c in maf_utilities.iter_components_by_src_start( block, species ):
|
||||
if c is not None:
|
||||
out.write( "%s\t%i\t%i\t%s\n" % ( maf_utilities.src_split( c.src )[-1], c.get_forward_strand_start(), c.get_forward_strand_end(), c.strand ) )
|
||||
out.write( "%s\t%i\t%i\t%s\n" % ( maf_utilities.src_split( c.src )[-1], c.get_forward_strand_start(), c.get_forward_strand_end(), c.strand ) )
|
||||
count += 1
|
||||
except Exception as e:
|
||||
print >> sys.stderr, "There was a problem processing your input: %s" % e
|
||||
@@ -30,4 +30,5 @@ def __main__():
|
||||
print "%i MAF blocks converted to Genomic Intervals for species %s." % ( count, species )
|
||||
|
||||
|
||||
if __name__ == "__main__": __main__()
|
||||
if __name__ == "__main__":
|
||||
__main__()
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
# used for grr and eigenstrat - shellfish if we get around to it
|
||||
#
|
||||
|
||||
import os, sys, tempfile, subprocess, time
|
||||
|
||||
from galaxy import eggs
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
prog = "pbed_ldreduced_converter.py"
|
||||
|
||||
@@ -40,11 +42,11 @@ def pruneLD(plinktasks=[], cd='./', vclbase=[]):
|
||||
vcl = vclbase + task
|
||||
sto = file(plog, 'w')
|
||||
x = subprocess.Popen(' '.join(vcl), shell=True, stdout=sto, stderr=sto, cwd=cd)
|
||||
retval = x.wait()
|
||||
x.wait()
|
||||
sto.close()
|
||||
try:
|
||||
lplog = file(plog, 'r').readlines()
|
||||
lplog = [x for x in lplog if x.find('Pruning SNP') == -1]
|
||||
lplog = [elem for elem in lplog if elem.find('Pruning SNP') == -1]
|
||||
alog += lplog
|
||||
alog.append('\n')
|
||||
os.unlink(plog) # no longer needed
|
||||
@@ -57,22 +59,14 @@ def makeLDreduced(basename, infpath=None, outfpath=None, plinke='plink', forcere
|
||||
winsize="60", winmove="40", r2thresh="0.1" ):
|
||||
""" not there so make and leave in output dir for post job hook to copy back into input extra files path for next time
|
||||
"""
|
||||
ldr = basename # we store ld reduced and thinned data
|
||||
ldreduced = os.path.join(outfpath, ldr) # note where this is going
|
||||
outbase = os.path.join(outfpath, basename)
|
||||
inbase = os.path.join(infpath)
|
||||
loglines = []
|
||||
ldbedname = '%s.bed' % ldreduced
|
||||
bedname = '%s.bed' % basename
|
||||
ldbedfn = os.path.join(infpath, ldbedname)
|
||||
bedfn = os.path.join(infpath, bedname)
|
||||
bmap = os.path.join(infpath, '%s.bim' % basename)
|
||||
plinktasks = []
|
||||
vclbase = [plinke, '--noweb']
|
||||
plinktasks += [['--bfile', inbase, '--indep-pairwise %s %s %s' % (winsize, winmove, r2thresh), '--out %s' % outbase],
|
||||
['--bfile', inbase, '--extract %s.prune.in --make-bed --out %s' % (outbase, outbase)]]
|
||||
vclbase = [plinke, '--noweb']
|
||||
loglines = pruneLD(plinktasks=plinktasks, cd=outfpath, vclbase=vclbase)
|
||||
pruneLD(plinktasks=plinktasks, cd=outfpath, vclbase=vclbase)
|
||||
|
||||
|
||||
def main():
|
||||
@@ -120,4 +114,4 @@ def main():
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
main()
|
||||
|
||||
@@ -16,7 +16,6 @@ def __main__():
|
||||
out = open( output_name, 'w' )
|
||||
i = 0
|
||||
for i, line in enumerate( open( input_name ) ):
|
||||
complete_interval = False
|
||||
line = line.rstrip( '\r\n' )
|
||||
if line:
|
||||
if line.startswith( HEADER_STARTS_WITH ):
|
||||
@@ -24,8 +23,6 @@ def __main__():
|
||||
else:
|
||||
try:
|
||||
elems = line.split( '\t' )
|
||||
if len( elems ) >= 5:
|
||||
complete_interval = True
|
||||
out.write( '%s\t%s\t%s\t%s\t0\t%s\n' % ( elems[0], int(elems[1]) - 1, elems[2], elems[4], elems[3] ) )
|
||||
except Exception as e:
|
||||
print e
|
||||
@@ -42,4 +39,5 @@ def __main__():
|
||||
info_msg += "Skipped %d blank/comment/invalid lines starting with line #%d." % ( skipped_lines, first_skipped_line )
|
||||
print info_msg
|
||||
|
||||
if __name__ == "__main__": __main__()
|
||||
if __name__ == "__main__":
|
||||
__main__()
|
||||
|
||||
@@ -5,8 +5,12 @@
|
||||
A wrapper script for converting SAM to BAM, with sorting.
|
||||
%prog input_filename.sam output_filename.bam
|
||||
"""
|
||||
|
||||
import sys, optparse, os, tempfile, subprocess, shutil
|
||||
import os
|
||||
import sys
|
||||
import optparse
|
||||
import tempfile
|
||||
import subprocess
|
||||
import shutil
|
||||
|
||||
CHUNK_SIZE = 2 ** 20 # 1mb
|
||||
|
||||
@@ -67,4 +71,5 @@ def __main__():
|
||||
|
||||
cleanup_before_exit( tmp_dir )
|
||||
|
||||
if __name__ == "__main__": __main__()
|
||||
if __name__ == "__main__":
|
||||
__main__()
|
||||
|
||||
@@ -7,8 +7,8 @@ Convert from VCF file to interval index file.
|
||||
from __future__ import division
|
||||
|
||||
import optparse
|
||||
from galaxy import eggs
|
||||
import pkg_resources; pkg_resources.require( "bx-python" )
|
||||
import pkg_resources
|
||||
pkg_resources.require( "bx-python" )
|
||||
import galaxy_utils.sequence.vcf
|
||||
from bx.interval_index_file import Indexes
|
||||
|
||||
|
||||
@@ -7,10 +7,10 @@ Original ordering, which may be specifically needed by tools or external displa
|
||||
|
||||
usage: %prog in_file out_file
|
||||
"""
|
||||
|
||||
from galaxy import eggs
|
||||
import pkg_resources; pkg_resources.require( "pysam" )
|
||||
import ctabix, optparse
|
||||
import pkg_resources
|
||||
pkg_resources.require( "pysam" )
|
||||
import ctabix
|
||||
import optparse
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@@ -7,10 +7,10 @@ Read a wiggle track and print out a series of lines containing
|
||||
and fixedStep wiggle lines.
|
||||
"""
|
||||
import sys
|
||||
from galaxy import eggs
|
||||
import pkg_resources; pkg_resources.require( "bx-python" )
|
||||
import pkg_resources
|
||||
pkg_resources.require( "bx-python" )
|
||||
import bx.wiggle
|
||||
from galaxy.tools.exception_handling import *
|
||||
from galaxy.tools.exception_handling import UCSCOutWrapper, UCSCLimitException
|
||||
|
||||
|
||||
def stop_err( msg ):
|
||||
@@ -43,4 +43,5 @@ def main():
|
||||
in_file.close()
|
||||
out_file.close()
|
||||
|
||||
if __name__ == "__main__": main()
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -929,47 +929,47 @@ class CSV( TabularData ):
|
||||
dataset.metadata.column_names = header_row
|
||||
dataset.metadata.delimiter = reader.dialect.delimiter
|
||||
|
||||
|
||||
class ConnectivityTable( Tabular ):
|
||||
edam_format = "format_3309"
|
||||
file_ext = "ct"
|
||||
|
||||
|
||||
header_regexp = re.compile( "^[0-9]+" + "(?:\t|[ ]+)" + ".*?" + "(?:ENERGY|energy|dG)" + "[ \t].*?=")
|
||||
structure_regexp = re.compile( "^[0-9]+" + "(?:\t|[ ]+)" + "[ACGTURYKMSWBDHVN]+" + "(?:\t|[ ]+)" + "[^\t]+" + "(?:\t|[ ]+)" + "[^\t]+" + "(?:\t|[ ]+)" + "[^\t]+" + "(?:\t|[ ]+)" + "[^\t]+")
|
||||
|
||||
structure_regexp = re.compile( "^[0-9]+" + "(?:\t|[ ]+)" + "[ACGTURYKMSWBDHVN]+" + "(?:\t|[ ]+)" + "[^\t]+" + "(?:\t|[ ]+)" + "[^\t]+" + "(?:\t|[ ]+)" + "[^\t]+" + "(?:\t|[ ]+)" + "[^\t]+")
|
||||
|
||||
def __init__(self, **kwd):
|
||||
Tabular.__init__( self, **kwd )
|
||||
|
||||
self.columns = 6
|
||||
self.column_names = ['base_index', 'base', 'neighbor_left', 'neighbor_right', 'partner', 'natural_numbering']
|
||||
self.column_types = ['int', 'str', 'int', 'int', 'int', 'int']
|
||||
|
||||
def set_meta( self, dataset, **kwd ):
|
||||
data_lines = 0
|
||||
|
||||
|
||||
for line in file( dataset.file_name ):
|
||||
data_lines += 1
|
||||
|
||||
|
||||
dataset.metadata.data_lines = data_lines
|
||||
|
||||
|
||||
def sniff(self, filename):
|
||||
"""
|
||||
The ConnectivityTable (CT) is a file format used for describing
|
||||
RNA 2D structures by tools including MFOLD, UNAFOLD and
|
||||
the RNAStructure package. The tabular file format is defined as
|
||||
follows:
|
||||
|
||||
|
||||
5 energy = -12.3 sequence name
|
||||
1 G 0 2 0 1
|
||||
2 A 1 3 0 2
|
||||
3 A 2 4 0 3
|
||||
4 A 3 5 0 4
|
||||
5 C 4 6 1 5
|
||||
|
||||
|
||||
The links given at the edam ontology page do not indicate what
|
||||
type of separator is used (space or tab) while different
|
||||
implementations exist. The implementation that uses spaces as
|
||||
separator (implemented in RNAStructure) is as follows:
|
||||
|
||||
|
||||
10 ENERGY = -34.8 seqname
|
||||
1 G 0 2 9 1
|
||||
2 G 1 3 8 2
|
||||
@@ -982,26 +982,26 @@ class ConnectivityTable( Tabular ):
|
||||
9 C 8 10 1 9
|
||||
10 a 9 0 0 10
|
||||
"""
|
||||
|
||||
|
||||
i = 0
|
||||
j = 1
|
||||
|
||||
|
||||
try:
|
||||
with open( filename ) as handle:
|
||||
for line in handle:
|
||||
line = line.strip()
|
||||
|
||||
|
||||
if len(line) > 0:
|
||||
if i == 0:
|
||||
if not self.header_regexp.match(line):
|
||||
return False
|
||||
else:
|
||||
length = int(re.split('\W+', line,1)[0])
|
||||
length = int(re.split('\W+', line, 1)[0])
|
||||
else:
|
||||
if not self.structure_regexp.match(line.upper()):
|
||||
return False
|
||||
else:
|
||||
if j != int(re.split('\W+', line,1)[0]):
|
||||
if j != int(re.split('\W+', line, 1)[0]):
|
||||
return False
|
||||
elif j == length: # Last line of first sequence has been recheached
|
||||
return True
|
||||
@@ -1011,7 +1011,7 @@ class ConnectivityTable( Tabular ):
|
||||
return False
|
||||
except:
|
||||
return False
|
||||
|
||||
|
||||
def get_chunk(self, trans, dataset, chunk):
|
||||
ck_index = int(chunk)
|
||||
f = open(dataset.file_name)
|
||||
@@ -1026,12 +1026,12 @@ class ConnectivityTable( Tabular ):
|
||||
while cursor and ck_data[-1] != '\n':
|
||||
ck_data += cursor
|
||||
cursor = f.read(1)
|
||||
|
||||
|
||||
# The ConnectivityTable format has several derivatives of which one is delimited by (multiple) spaces.
|
||||
# By converting these spaces back to tabs, chucks can still be interpreted by tab delimited file parsers
|
||||
ck_data_header, ck_data_body = ck_data.split('\n', 1)
|
||||
ck_data_header = re.sub('^([0-9]+)[ ]+',r'\1\t',ck_data_header)
|
||||
ck_data_body = re.sub('\n[ \t]+','\n',ck_data_body)
|
||||
ck_data_body = re.sub('[ ]+','\t',ck_data_body)
|
||||
|
||||
ck_data_header = re.sub('^([0-9]+)[ ]+', r'\1\t', ck_data_header)
|
||||
ck_data_body = re.sub('\n[ \t]+', '\n', ck_data_body)
|
||||
ck_data_body = re.sub('[ ]+', '\t', ck_data_body)
|
||||
|
||||
return dumps( { 'ck_data': util.unicodify(ck_data_header + "\n" + ck_data_body ), 'ck_index': ck_index + 1 } )
|
||||
|
||||
@@ -1234,12 +1234,11 @@ class History( object, Dictifiable, UsesAnnotations, HasName ):
|
||||
.filter( HistoryDatasetAssociation.table.c.history_id == self.id )
|
||||
.filter( not_( HistoryDatasetAssociation.deleted ) )
|
||||
.order_by( HistoryDatasetAssociation.table.c.hid.asc() )
|
||||
.options(
|
||||
joinedload("children"),
|
||||
joinedload("dataset"),
|
||||
joinedload("dataset.actions"),
|
||||
joinedload("dataset.actions.role"),
|
||||
))
|
||||
.options( joinedload("children"),
|
||||
joinedload("dataset"),
|
||||
joinedload("dataset.actions"),
|
||||
joinedload("dataset.actions.role"),
|
||||
))
|
||||
self._active_datasets_children_and_roles = query.all()
|
||||
return self._active_datasets_children_and_roles
|
||||
|
||||
|
||||
@@ -120,8 +120,8 @@ class ASync( BaseUIController ):
|
||||
try:
|
||||
key = hmac_new( trans.app.config.tool_secret, "%d:%d" % ( data.id, data.history_id ) )
|
||||
galaxy_url = trans.request.base + '/async/%s/%s/%s' % ( tool_id, data.id, key )
|
||||
params.update( { 'GALAXY_URL' :galaxy_url } )
|
||||
params.update( { 'data_id' :data.id } )
|
||||
params.update( { 'GALAXY_URL': galaxy_url } )
|
||||
params.update( { 'data_id': data.id } )
|
||||
# Use provided URL or fallback to tool action
|
||||
url = URL or tool.action
|
||||
# Does url already have query params?
|
||||
|
||||
@@ -62,7 +62,7 @@ class HistoryDatasetAssociationListGrid( grids.Grid ):
|
||||
# Link name to dataset's history.
|
||||
link=( lambda item: iff( item.history.deleted, None, dict( operation="switch", id=item.id ) ) ), filterable="advanced", attach_popup=True, inbound=True ),
|
||||
HistoryColumn( "History", key="history", sortable=False, inbound=True,
|
||||
link=( lambda item: iff( item.history.deleted, None, dict( operation="switch_history", id=item.id ) ) ) ),
|
||||
link=( lambda item: iff( item.history.deleted, None, dict( operation="switch_history", id=item.id ) ) ) ),
|
||||
grids.IndividualTagsColumn( "Tags", key="tags", model_tag_association_class=model.HistoryDatasetAssociationTagAssociation, filterable="advanced", grid_name="HistoryDatasetAssocationListGrid" ),
|
||||
StatusColumn( "Status", key="deleted", attach_popup=False ),
|
||||
grids.GridColumn( "Last Updated", key="update_time", format=time_ago ),
|
||||
|
||||
@@ -391,13 +391,13 @@ class PageController( BaseUIController, SharableMixin,
|
||||
web.FormBuilder( web.url_for(controller='page', action='create'), "Create new page", submit_text="Submit" )
|
||||
.add_text( "page_title", "Page title", value=page_title, error=page_title_err )
|
||||
.add_text( "page_slug", "Page identifier", value=page_slug, error=page_slug_err,
|
||||
help="""A unique identifier that will be used for
|
||||
public links to this page. A default is generated
|
||||
from the page title, but can be edited. This field
|
||||
must contain only lowercase letters, numbers, and
|
||||
the '-' character.""" )
|
||||
help="""A unique identifier that will be used for
|
||||
public links to this page. A default is generated
|
||||
from the page title, but can be edited. This field
|
||||
must contain only lowercase letters, numbers, and
|
||||
the '-' character.""" )
|
||||
.add_text( "page_annotation", "Page annotation", value=page_annotation, error=page_annotation_err,
|
||||
help="A description of the page; annotation is shown alongside published pages."),
|
||||
help="A description of the page; annotation is shown alongside published pages."),
|
||||
template="page/create.mako" )
|
||||
|
||||
@web.expose
|
||||
@@ -442,13 +442,13 @@ class PageController( BaseUIController, SharableMixin,
|
||||
web.FormBuilder( web.url_for(controller='page', action='edit', id=encoded_id ), "Edit page attributes", submit_text="Submit" )
|
||||
.add_text( "page_title", "Page title", value=page_title, error=page_title_err )
|
||||
.add_text( "page_slug", "Page identifier", value=page_slug, error=page_slug_err,
|
||||
help="""A unique identifier that will be used for
|
||||
public links to this page. A default is generated
|
||||
from the page title, but can be edited. This field
|
||||
must contain only lowercase letters, numbers, and
|
||||
the '-' character.""" )
|
||||
help="""A unique identifier that will be used for
|
||||
public links to this page. A default is generated
|
||||
from the page title, but can be edited. This field
|
||||
must contain only lowercase letters, numbers, and
|
||||
the '-' character.""" )
|
||||
.add_text( "page_annotation", "Page annotation", value=page_annotation, error=page_annotation_err,
|
||||
help="A description of the page; annotation is shown alongside published pages."),
|
||||
help="A description of the page; annotation is shown alongside published pages."),
|
||||
template="page/create.mako" )
|
||||
|
||||
@web.expose
|
||||
|
||||
@@ -656,14 +656,14 @@ class VisualizationController( BaseUIController, SharableMixin, UsesVisualizatio
|
||||
.add_text( "visualization_title", "Visualization title", value=visualization_title, error=visualization_title_err )
|
||||
.add_select( "visualization_type", "Type", options=viz_type_options, error=None )
|
||||
.add_text( "visualization_slug", "Visualization identifier", value=visualization_slug, error=visualization_slug_err,
|
||||
help="""A unique identifier that will be used for
|
||||
public links to this visualization. A default is generated
|
||||
from the visualization title, but can be edited. This field
|
||||
must contain only lowercase letters, numbers, and
|
||||
the '-' character.""" )
|
||||
help="""A unique identifier that will be used for
|
||||
public links to this visualization. A default is generated
|
||||
from the visualization title, but can be edited. This field
|
||||
must contain only lowercase letters, numbers, and
|
||||
the '-' character.""" )
|
||||
.add_select( "visualization_dbkey", "Visualization DbKey/Build", value=visualization_dbkey, options=trans.app.genomes.get_dbkeys( trans, chrom_info=True ), error=None)
|
||||
.add_text( "visualization_annotation", "Visualization annotation", value=visualization_annotation, error=visualization_annotation_err,
|
||||
help="A description of the visualization; annotation is shown alongside published visualizations."),
|
||||
help="A description of the visualization; annotation is shown alongside published visualizations."),
|
||||
template="visualization/create.mako"
|
||||
)
|
||||
|
||||
@@ -723,13 +723,13 @@ class VisualizationController( BaseUIController, SharableMixin, UsesVisualizatio
|
||||
web.FormBuilder( web.url_for(controller='visualization', action='edit', id=id ), "Edit visualization attributes", submit_text="Submit" )
|
||||
.add_text( "visualization_title", "Visualization title", value=visualization_title, error=visualization_title_err )
|
||||
.add_text( "visualization_slug", "Visualization identifier", value=visualization_slug, error=visualization_slug_err,
|
||||
help="""A unique identifier that will be used for
|
||||
public links to this visualization. A default is generated
|
||||
from the visualization title, but can be edited. This field
|
||||
must contain only lowercase letters, numbers, and
|
||||
the '-' character.""" )
|
||||
help="""A unique identifier that will be used for
|
||||
public links to this visualization. A default is generated
|
||||
from the visualization title, but can be edited. This field
|
||||
must contain only lowercase letters, numbers, and
|
||||
the '-' character.""" )
|
||||
.add_text( "visualization_annotation", "Visualization annotation", value=visualization_annotation, error=visualization_annotation_err,
|
||||
help="A description of the visualization; annotation is shown alongside published visualizations."),
|
||||
help="A description of the visualization; annotation is shown alongside published visualizations."),
|
||||
template="visualization/create.mako" )
|
||||
|
||||
# ------------------------- registry.
|
||||
|
||||
@@ -52,7 +52,7 @@ class ToolsController( BaseAPIController ):
|
||||
page_size = kwd.get( 'page_size', 10 )
|
||||
try:
|
||||
page = int( page )
|
||||
page_size = int ( page_size )
|
||||
page_size = int( page_size )
|
||||
except ValueError:
|
||||
raise RequestParameterInvalidException( 'The "page" and "page_size" have to be integers.' )
|
||||
return_jsonp = util.asbool( kwd.get( 'jsonp', False ) )
|
||||
|
||||
+5
-1
@@ -1,16 +1,19 @@
|
||||
# override tempfile methods for debugging
|
||||
|
||||
import tempfile, traceback
|
||||
import tempfile
|
||||
import traceback
|
||||
|
||||
import logging
|
||||
log = logging.getLogger( __name__ )
|
||||
|
||||
|
||||
class TempFile( object ):
|
||||
def __init__( self ):
|
||||
tempfile._NamedTemporaryFile = tempfile.NamedTemporaryFile
|
||||
tempfile._mkstemp = tempfile.mkstemp
|
||||
tempfile.NamedTemporaryFile = self.NamedTemporaryFile
|
||||
tempfile.mkstemp = self.mkstemp
|
||||
|
||||
def NamedTemporaryFile( self, *args, **kwargs ):
|
||||
f = tempfile._NamedTemporaryFile( *args, **kwargs )
|
||||
try:
|
||||
@@ -18,6 +21,7 @@ class TempFile( object ):
|
||||
except AttributeError:
|
||||
pass
|
||||
return f
|
||||
|
||||
def mkstemp( self, *args, **kwargs ):
|
||||
f = tempfile._mkstemp( *args, **kwargs )
|
||||
try:
|
||||
|
||||
+16
-10
@@ -19,6 +19,7 @@ __author__ = 'Joe Gregorio'
|
||||
__email__ = "joe@bitworking.org"
|
||||
__credits__ = ""
|
||||
|
||||
|
||||
def parse_mime_type(mime_type):
|
||||
"""Carves up a mime-type and returns a tuple of the
|
||||
(type, subtype, params) where 'params' is a dictionary
|
||||
@@ -29,15 +30,16 @@ def parse_mime_type(mime_type):
|
||||
('application', 'xhtml', {'q', '0.5'})
|
||||
"""
|
||||
parts = mime_type.split(";")
|
||||
params = dict([tuple([s.strip() for s in param.split("=")])\
|
||||
for param in parts[1:] ])
|
||||
params = dict( [tuple([s.strip() for s in param.split("=")]) for param in parts[1:] ] )
|
||||
full_type = parts[0].strip()
|
||||
# Java URLConnection class sends an Accept header that includes a single "*"
|
||||
# Turn it into a legal wildcard.
|
||||
if full_type == '*': full_type = '*/*'
|
||||
if full_type == '*':
|
||||
full_type = '*/*'
|
||||
(type, subtype) = full_type.split("/")
|
||||
return (type.strip(), subtype.strip(), params)
|
||||
|
||||
|
||||
def parse_media_range(range):
|
||||
r"""
|
||||
Carves up a media range and returns a tuple of the
|
||||
@@ -55,12 +57,13 @@ def parse_media_range(range):
|
||||
in with a proper default if necessary.
|
||||
"""
|
||||
(type, subtype, params) = parse_mime_type(range)
|
||||
if not params.has_key('q') or not params['q'] or \
|
||||
if 'q' not in params or not params['q'] or \
|
||||
not float(params['q']) or float(params['q']) > 1\
|
||||
or float(params['q']) < 0:
|
||||
params['q'] = '1'
|
||||
return (type, subtype, params)
|
||||
|
||||
|
||||
def fitness_and_quality_parsed(mime_type, parsed_ranges):
|
||||
"""Find the best match for a given mime-type against
|
||||
a list of media_ranges that have already been
|
||||
@@ -72,13 +75,13 @@ def fitness_and_quality_parsed(mime_type, parsed_ranges):
|
||||
best_fitness = -1
|
||||
best_fit_q = 0
|
||||
(target_type, target_subtype, target_params) =\
|
||||
parse_media_range(mime_type)
|
||||
parse_media_range(mime_type)
|
||||
for (type, subtype, params) in parsed_ranges:
|
||||
if (type == target_type or type == '*' or target_type == '*') and \
|
||||
(subtype == target_subtype or subtype == '*' or target_subtype == '*'):
|
||||
param_matches = reduce(lambda x, y: x+y, [1 for (key, value) in \
|
||||
target_params.iteritems() if key != 'q' and \
|
||||
params.has_key(key) and value == params[key]], 0)
|
||||
param_matches = reduce(lambda x, y: x + y, [1 for (key, value) in
|
||||
target_params.iteritems() if key != 'q' and
|
||||
key in params and value == params[key]], 0)
|
||||
fitness = (type == target_type) and 100 or 0
|
||||
fitness += (subtype == target_subtype) and 10 or 0
|
||||
fitness += param_matches
|
||||
@@ -88,6 +91,7 @@ def fitness_and_quality_parsed(mime_type, parsed_ranges):
|
||||
|
||||
return best_fitness, float(best_fit_q)
|
||||
|
||||
|
||||
def quality_parsed(mime_type, parsed_ranges):
|
||||
"""Find the best match for a given mime-type against
|
||||
a list of media_ranges that have already been
|
||||
@@ -98,6 +102,7 @@ def quality_parsed(mime_type, parsed_ranges):
|
||||
parsed media ranges. """
|
||||
return fitness_and_quality_parsed(mime_type, parsed_ranges)[1]
|
||||
|
||||
|
||||
def quality(mime_type, ranges):
|
||||
"""Returns the quality 'q' of a mime-type when compared
|
||||
against the media-ranges in ranges. For example:
|
||||
@@ -109,6 +114,7 @@ def quality(mime_type, ranges):
|
||||
parsed_ranges = [parse_media_range(r) for r in ranges.split(",")]
|
||||
return quality_parsed(mime_type, parsed_ranges)
|
||||
|
||||
|
||||
def best_match(supported, header):
|
||||
"""Takes a list of supported mime-types and finds the best
|
||||
match for all the media-ranges listed in header. The value of
|
||||
@@ -120,8 +126,8 @@ def best_match(supported, header):
|
||||
'text/xml'
|
||||
"""
|
||||
parsed_header = [parse_media_range(r) for r in header.split(",")]
|
||||
weighted_matches = [(fitness_and_quality_parsed(mime_type, parsed_header), mime_type)\
|
||||
for mime_type in supported]
|
||||
weighted_matches = [(fitness_and_quality_parsed(mime_type, parsed_header), mime_type)
|
||||
for mime_type in supported]
|
||||
weighted_matches.sort()
|
||||
return weighted_matches[-1][0][1] and weighted_matches[-1][1] or ''
|
||||
|
||||
|
||||
+1
-6
@@ -1,10 +1,5 @@
|
||||
import sys
|
||||
|
||||
try:
|
||||
import psyco
|
||||
psyco.full()
|
||||
except:
|
||||
pass
|
||||
#print >> sys.stderr, "Psyco not found, continuing without it"
|
||||
|
||||
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user