idx int64 0 63k | question stringlengths 61 4.03k | target stringlengths 6 1.23k |
|---|---|---|
12,100 | def join ( self , a , * args ) : mapping = self . _mapping set_a = mapping . setdefault ( a , [ a ] ) for arg in args : set_b = mapping . get ( arg ) if set_b is None : set_a . append ( arg ) mapping [ arg ] = set_a elif set_b is not set_a : if len ( set_b ) > len ( set_a ) : set_a , set_b = set_b , set_a set_a . exten... | Join given arguments into the same set . Accepts one or more arguments . |
12,101 | def joined ( self , a , b ) : mapping = self . _mapping try : return mapping [ a ] is mapping [ b ] except KeyError : return False | Returns True if a and b are members of the same set . |
12,102 | def fromcsv ( args ) : from csv import reader from xlwt import Workbook , easyxf from jcvi . formats . base import flexible_cast p = OptionParser ( fromcsv . __doc__ ) p . add_option ( "--noheader" , default = False , action = "store_true" , help = "Do not treat the first row as header" ) p . add_option ( "--rgb" , def... | %prog fromcsv csvfile |
12,103 | def csv ( args ) : from xlrd import open_workbook p = OptionParser ( csv . __doc__ ) p . set_sep ( sep = ',' ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) excelfile , = args sep = opts . sep csvfile = excelfile . rsplit ( "." , 1 ) [ 0 ] + ".csv" wb = open_workbook... | %prog csv excelfile |
12,104 | def match_color_index ( self , color ) : from jcvi . utils . webcolors import color_diff if isinstance ( color , int ) : return color if color : if isinstance ( color , six . string_types ) : rgb = map ( int , color . split ( ',' ) ) else : rgb = color . Get ( ) logging . disable ( logging . DEBUG ) distances = [ color... | Takes an R G B string or wx . Color and returns a matching xlwt color . |
12,105 | def get_unused_color ( self ) : if not self . unused_colors : self . reset ( ) used_colors = [ c for c in self . xlwt_colors if c not in self . unused_colors ] result_color = max ( self . unused_colors , key = lambda c : min ( self . color_distance ( c , c2 ) for c2 in used_colors ) ) result_index = self . xlwt_colors ... | Returns an xlwt color index that has not been previously returned by this instance . Attempts to maximize the distance between the color and all previously used colors . |
12,106 | def validate ( args ) : import pyfasta p = OptionParser ( validate . __doc__ ) p . add_option ( "--prefix" , help = "Add prefix to seqid" ) opts , args = p . parse_args ( args ) vcffile , fastafile = args pf = opts . prefix genome = pyfasta . Fasta ( fastafile , record_class = pyfasta . MemoryRecord ) fp = must_open ( ... | %prog validate input . vcf genome . fasta |
12,107 | def uniq ( args ) : from six . moves . urllib . parse import parse_qs p = OptionParser ( uniq . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) vcffile , = args fp = must_open ( vcffile ) data = [ ] for row in fp : if row [ 0 ] == '#' : print ( row . strip ( ... | %prog uniq vcffile |
12,108 | def sample ( args ) : from random import random p = OptionParser ( sample . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) vcffile , ratio = args ratio = float ( ratio ) fp = open ( vcffile ) pf = vcffile . rsplit ( "." , 1 ) [ 0 ] kept = pf + ".kept.vcf" wi... | %prog sample vcffile 0 . 9 |
12,109 | def fromimpute2 ( args ) : p = OptionParser ( fromimpute2 . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 3 : sys . exit ( not p . print_help ( ) ) impute2file , fastafile , chr = args fasta = Fasta ( fastafile ) print ( get_vcfstanza ( fastafile , fasta ) ) fp = open ( impute2file ) seen = set ( )... | %prog fromimpute2 impute2file fastafile 1 |
12,110 | def refallele ( args ) : p = OptionParser ( refallele . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) vcffile , = args fp = open ( vcffile ) for row in fp : if row [ 0 ] == '#' : continue atoms = row . split ( ) marker = "{0}:{1}" . format ( * atoms [ : 2 ]... | %prog refallele vcffile > out . refAllele |
12,111 | def location ( args ) : from jcvi . formats . bed import BedLine from jcvi . graphics . histogram import stem_leaf_plot p = OptionParser ( location . __doc__ ) p . add_option ( "--dist" , default = 100 , type = "int" , help = "Distance cutoff to call 5` and 3` [default: %default]" ) opts , args = p . parse_args ( args ... | %prog location bedfile fastafile |
12,112 | def liftover ( args ) : p = OptionParser ( liftover . __doc__ ) p . add_option ( "--newid" , default = False , action = "store_true" , help = "Make new identifiers" ) opts , args = p . parse_args ( args ) if len ( args ) != 3 : sys . exit ( not p . print_help ( ) ) oldvcf , chainfile , newvcf = args ul = UniqueLiftover... | %prog liftover old . vcf hg19ToHg38 . over . chain . gz new . vcf |
12,113 | def multilineplot ( args ) : p = OptionParser ( multilineplot . __doc__ ) p . add_option ( "--lines" , help = "Features to plot in lineplot [default: %default]" ) p . add_option ( "--colors" , help = "List of colors matching number of input bed files" ) p . add_option ( "--mode" , default = "span" , choices = ( "span" ... | %prog multilineplot fastafile chr1 |
12,114 | def _needle ( fa , fb , needlefile , a , b , results ) : from Bio . Emboss . Applications import NeedleCommandline needle_cline = NeedleCommandline ( asequence = fa , bsequence = fb , gapopen = 10 , gapextend = 0.5 , outfile = needlefile ) stdout , stderr = needle_cline ( ) nh = NeedleHeader ( needlefile ) FileShredder... | Run single needle job |
12,115 | def needle ( args ) : from jcvi . formats . fasta import Fasta , SeqIO p = OptionParser ( needle . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 3 : sys . exit ( not p . print_help ( ) ) manager = mp . Manager ( ) results = manager . list ( ) needle_pool = mp . Pool ( processes = mp . cpu_count ( )... | %prog needle nw . pairs a . pep . fasta b . pep . fasta |
12,116 | def maker ( args ) : from jcvi . formats . base import SetFile , FileShredder A , T , P = "ABINITIO_PREDICTION" , "TRANSCRIPT" , "PROTEIN" Registry = { "maker" : ( A , 5 ) , "augustus_masked" : ( A , 1 ) , "snap_masked" : ( A , 1 ) , "genemark" : ( A , 1 ) , "est2genome" : ( T , 5 ) , "est_gff" : ( T , 5 ) , "protein2g... | %prog maker maker . gff3 genome . fasta |
12,117 | def tigrload ( args ) : p = OptionParser ( tigrload . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) db , ev_type = args runfile = "load.sh" contents = EVMLOAD . format ( db , ev_type ) write_file ( runfile , contents ) | %prog tigrload db ev_type |
12,118 | def pasa ( args ) : p = OptionParser ( pasa . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) pasa_db , fastafile = args termexons = "pasa.terminal_exons.gff3" if need_update ( fastafile , termexons ) : cmd = "$ANNOT_DEVEL/PASA2/scripts/pasa_asmbls_to_trainin... | %prog pasa pasa_db fastafile |
12,119 | def tigrprepare ( args ) : p = OptionParser ( tigrprepare . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 4 : sys . exit ( not p . print_help ( ) ) fastafile , asmbl_id , db , pasa_db = args if asmbl_id == 'all' : idsfile = fastafile + ".ids" if need_update ( fastafile , idsfile ) : ids ( [ fastafi... | %prog tigrprepare asmbl . fasta asmbl . ids db pasa . terminal_exons . gff3 |
12,120 | def uniq ( args ) : p = OptionParser ( uniq . __doc__ ) p . set_outfile ( ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) gffile , cdsfasta = args gff = Gff ( gffile ) sizes = Sizes ( cdsfasta ) . mapping gene_register = { } for g in gff : if g . type != "mRNA" : con... | %prog uniq gffile cdsfasta |
12,121 | def nmd ( args ) : import __builtin__ from jcvi . utils . cbook import enumerate_reversed p = OptionParser ( nmd . __doc__ ) p . set_outfile ( ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) gffile , = args gff = make_index ( gffile ) fw = must_open ( opts . outfile ... | %prog nmd gffile |
12,122 | def print_edges ( G , bed , families ) : symbols = { '+' : '>' , '-' : '<' } for seqid , bs in bed . sub_beds ( ) : prev_node , prev_strand = None , '+' for b in bs : accn = b . accn strand = b . strand node = "=" . join ( families [ accn ] ) if prev_node : print ( "{}{}--{}{}" . format ( prev_node , symbols [ prev_str... | Instead of going through the graph construction just print the edges . |
12,123 | def adjgraph ( args ) : import pygraphviz as pgv from jcvi . utils . iter import pairwise from jcvi . formats . base import SetFile p = OptionParser ( adjgraph . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) infile , subgraph = args subgraph = SetFile ( sub... | %prog adjgraph adjacency . txt subgraph . txt |
12,124 | def pairs ( args ) : p = OptionParser ( pairs . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) anchorfile , prefix = args outfile = prefix + ".pairs" fw = open ( outfile , "w" ) af = AnchorFile ( anchorfile ) blocks = af . blocks pad = len ( str ( len ( bloc... | %prog pairs anchorsfile prefix |
12,125 | def zipbed ( args ) : p = OptionParser ( zipbed . __doc__ ) p . add_option ( "--prefix" , default = "b" , help = "Prefix for the new seqid [default: %default]" ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) bedfile , anchorfile = args prefix = opts . prefix bed = Be... | %prog zipbed species . bed collinear . anchors |
12,126 | def collinear ( args ) : p = OptionParser ( collinear . __doc__ ) p . set_beds ( ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) anchorfile , = args qbed , sbed , qorder , sorder , is_self = check_beds ( anchorfile , p , opts ) af = AnchorFile ( anchorfile ) newancho... | %prog collinear a . b . anchors |
12,127 | def counts ( args ) : p = OptionParser ( counts . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) vcffile , = args vcf_reader = vcf . Reader ( open ( vcffile ) ) for r in vcf_reader : v = CPRA ( r ) if not v . is_valid : continue for sample in r . samples : r... | %prog counts vcffile |
12,128 | def prepare ( args ) : p = OptionParser ( prepare . __doc__ ) p . add_option ( "--accuracy" , default = .85 , help = "Sequencing per-base accuracy" ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) vcffile , bamfile = args right = "{:.2f}" . format ( opts . accuracy ) ... | %prog prepare vcffile bamfile |
12,129 | def is_valid ( self ) : return len ( self . ref ) == 1 and len ( self . alt ) == 1 and len ( self . alt [ 0 ] ) == 1 | Only retain SNPs or single indels and are bi - allelic |
12,130 | def _number_finder ( s , regex , numconv ) : s = regex . split ( s ) if len ( s ) == 1 : return tuple ( s ) s = remove_empty ( s ) for i in range ( len ( s ) ) : try : s [ i ] = numconv ( s [ i ] ) except ValueError : pass if not isinstance ( s [ 0 ] , six . string_types ) : return [ '' ] + s else : return s | Helper to split numbers |
12,131 | def index_natsorted ( seq , key = lambda x : x , number_type = float , signed = True , exp = True ) : from operator import itemgetter item1 = itemgetter ( 1 ) index_seq_pair = [ [ x , key ( y ) ] for x , y in zip ( range ( len ( seq ) ) , seq ) ] index_seq_pair . sort ( key = lambda x : natsort_key ( item1 ( x ) , numb... | \ Sorts a sequence naturally but returns a list of sorted the indeces and not the sorted list . |
12,132 | def batchseeds ( args ) : from jcvi . formats . pdf import cat xargs = args [ 1 : ] p = OptionParser ( batchseeds . __doc__ ) opts , args , iopts = add_seeds_options ( p , args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) folder , = args folder = folder . rstrip ( '/' ) outdir = folder + "-debug" outf... | %prog batchseeds folder |
12,133 | def filterbedgraph ( args ) : p = OptionParser ( filterbedgraph . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) bedgraphfile , cutoff = args c = float ( cutoff ) fp = open ( bedgraphfile ) pf = bedgraphfile . rsplit ( "." , 1 ) [ 0 ] filteredbed = pf + ".fi... | %prog filterbedgraph a . bedgraph 1 |
12,134 | def tiling ( args ) : p = OptionParser ( tiling . __doc__ ) p . add_option ( "--overlap" , default = 3000 , type = "int" , help = "Minimum amount of overlaps required" ) p . set_verbose ( ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) bedfile , = args ov = opts . ov... | %prog tiling bedfile |
12,135 | def chain ( args ) : p = OptionParser ( chain . __doc__ ) p . add_option ( "--dist" , default = 100000 , help = "Chaining distance" ) p . set_outfile ( ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) bedfile , = args cmd = "sort -k4,4 -k1,1 -k2,2n -k3,3n {0} -o {0}" ... | %prog chain bedfile |
12,136 | def density ( args ) : p = OptionParser ( density . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) bedfile , fastafile = args bed = Bed ( bedfile ) sizes = Sizes ( fastafile ) . mapping header = "seqid features size density_per_Mb" . split ( ) print ( "\t" .... | %prog density bedfile ref . fasta |
12,137 | def alignextend ( args ) : p = OptionParser ( alignextend . __doc__ ) p . add_option ( "--len" , default = 100 , type = "int" , help = "Extend to this length" ) p . add_option ( "--qv" , default = 31 , type = "int" , help = "Dummy qv score for extended bases" ) p . add_option ( "--bedonly" , default = False , action = ... | %prog alignextend bedpefile ref . fasta |
12,138 | def seqids ( args ) : p = OptionParser ( seqids . __doc__ ) p . add_option ( "--maxn" , default = 100 , type = "int" , help = "Maximum number of seqids" ) p . add_option ( "--prefix" , help = "Seqids must start with" ) p . add_option ( "--exclude" , default = "random" , help = "Seqids should not contain" ) opts , args ... | %prog seqids bedfile |
12,139 | def random ( args ) : from random import sample from jcvi . formats . base import flexible_cast p = OptionParser ( random . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) bedfile , N = args assert is_number ( N ) b = Bed ( bedfile ) NN = flexible_cast ( N ) ... | %prog random bedfile number_of_features |
12,140 | def filter ( args ) : p = OptionParser ( filter . __doc__ ) p . add_option ( "--minsize" , default = 0 , type = "int" , help = "Minimum feature length" ) p . add_option ( "--maxsize" , default = 1000000000 , type = "int" , help = "Minimum feature length" ) p . add_option ( "--minaccn" , type = "int" , help = "Minimum v... | %prog filter bedfile |
12,141 | def mergebydepth ( args ) : p = OptionParser ( mergebydepth . __doc__ ) p . add_option ( "--mindepth" , default = 3 , type = "int" , help = "Minimum depth required" ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) bedfile , fastafile = args mindepth = opts . mindepth ... | %prog mergebydepth reads . bed genome . fasta |
12,142 | def depth ( args ) : p = OptionParser ( depth . __doc__ ) p . set_outfile ( ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) readsbed , featsbed = args fp = open ( featsbed ) nargs = len ( fp . readline ( ) . split ( "\t" ) ) keepcols = "," . join ( str ( x ) for x in... | %prog depth reads . bed features . bed |
12,143 | def remove_isoforms ( ids ) : key = lambda x : x . rsplit ( "." , 1 ) [ 0 ] iso_number = lambda x : get_number ( x . split ( "." ) [ - 1 ] ) ids = sorted ( ids , key = key ) newids = [ ] for k , ii in groupby ( ids , key = key ) : min_i = min ( list ( ii ) , key = iso_number ) newids . append ( min_i ) return newids | This is more or less a hack to remove the GMAP multiple mappings . Multiple GMAP mappings can be seen given the names . mrna1 . mrna2 etc . |
12,144 | def longest ( args ) : from jcvi . formats . sizes import Sizes p = OptionParser ( longest . __doc__ ) p . add_option ( "--maxsize" , default = 20000 , type = "int" , help = "Limit max size" ) p . add_option ( "--minsize" , default = 60 , type = "int" , help = "Limit min size" ) p . add_option ( "--precedence" , defaul... | %prog longest bedfile fastafile |
12,145 | def merge ( args ) : p = OptionParser ( merge . __doc__ ) p . set_outfile ( ) opts , args = p . parse_args ( args ) if len ( args ) < 1 : sys . exit ( not p . print_help ( ) ) bedfiles = args fw = must_open ( opts . outfile , "w" ) for bedfile in bedfiles : bed = Bed ( bedfile ) pf = op . basename ( bedfile ) . split (... | %prog merge bedfiles > newbedfile |
12,146 | def fix ( args ) : p = OptionParser ( fix . __doc__ ) p . add_option ( "--minspan" , default = 0 , type = "int" , help = "Enforce minimum span [default: %default]" ) p . set_outfile ( ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) bedfile , = args minspan = opts . m... | %prog fix bedfile > newbedfile |
12,147 | def some ( args ) : from jcvi . formats . base import SetFile from jcvi . utils . cbook import gene_name p = OptionParser ( some . __doc__ ) p . add_option ( "-v" , dest = "inverse" , default = False , action = "store_true" , help = "Get the inverse, like grep -v [default: %default]" ) p . set_outfile ( ) p . set_strip... | %prog some bedfile idsfile > newbedfile |
12,148 | def uniq ( args ) : from jcvi . formats . sizes import Sizes p = OptionParser ( uniq . __doc__ ) p . add_option ( "--sizes" , help = "Use sequence length as score" ) p . add_option ( "--mode" , default = "span" , choices = ( "span" , "score" ) , help = "Pile mode" ) opts , args = p . parse_args ( args ) if len ( args )... | %prog uniq bedfile |
12,149 | def pile ( args ) : from jcvi . utils . grouper import Grouper p = OptionParser ( pile . __doc__ ) p . add_option ( "--minOverlap" , default = 0 , type = "int" , help = "Minimum overlap required [default: %default]" ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) abe... | %prog pile abedfile bbedfile > piles |
12,150 | def index ( args ) : p = OptionParser ( index . __doc__ ) p . add_option ( "--fasta" , help = "Generate bedgraph and index" ) p . add_option ( "--query" , help = "Chromosome location" ) p . set_outfile ( ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) bedfile , = arg... | %prog index bedfile |
12,151 | def evaluate ( args ) : from jcvi . formats . sizes import Sizes p = OptionParser ( evaluate . __doc__ ) p . add_option ( "--query" , help = "Chromosome location [default: %default]" ) opts , args = p . parse_args ( args ) if len ( args ) != 3 : sys . exit ( not p . print_help ( ) ) prediction , reality , fastafile = a... | %prog evaluate prediction . bed reality . bed fastafile |
12,152 | def refine ( args ) : p = OptionParser ( refine . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 3 : sys . exit ( not p . print_help ( ) ) abedfile , bbedfile , refinedbed = args fw = open ( refinedbed , "w" ) intersected = refined = 0 for a , b in intersectBed_wao ( abedfile , bbedfile ) : if b is ... | %prog refine bedfile1 bedfile2 refinedbed |
12,153 | def distance ( args ) : from jcvi . utils . iter import pairwise p = OptionParser ( distance . __doc__ ) p . add_option ( "--distmode" , default = "ss" , choices = ( "ss" , "ee" ) , help = "Distance mode between paired reads. ss is outer distance, " "ee is inner distance [default: %default]" ) opts , args = p . parse_a... | %prog distance bedfile |
12,154 | def bedpe ( args ) : from jcvi . assembly . coverage import bed_to_bedpe p = OptionParser ( bedpe . __doc__ ) p . add_option ( "--span" , default = False , action = "store_true" , help = "Write span bed file [default: %default]" ) p . add_option ( "--strand" , default = False , action = "store_true" , help = "Write the... | %prog bedpe bedfile |
12,155 | def sizes ( args ) : p = OptionParser ( sizes . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) bedfile , = args assert op . exists ( bedfile ) sizesfile = bedfile . rsplit ( "." , 1 ) [ 0 ] + ".sizes" fw = must_open ( sizesfile , "w" , checkexists = True , s... | %prog sizes bedfile |
12,156 | def analyze_dists ( dists , cutoff = 1000 , alpha = .1 ) : peak0 = [ d for d in dists if d < cutoff ] peak1 = [ d for d in dists if d >= cutoff ] c0 , c1 = len ( peak0 ) , len ( peak1 ) logging . debug ( "Component counts: {0} {1}" . format ( c0 , c1 ) ) if c0 == 0 or c1 == 0 or float ( c1 ) / len ( dists ) < alpha : l... | The dists can show bimodal distribution if they come from a mate - pair library . Assume bimodal distribution and then separate the two peaks . Based on the percentage in each peak we can decide if it is indeed one peak or two peaks and report the median respectively . |
12,157 | def summary ( args ) : p = OptionParser ( summary . __doc__ ) p . add_option ( "--sizes" , default = False , action = "store_true" , help = "Write .sizes file" ) p . add_option ( "--all" , default = False , action = "store_true" , help = "Write summary stats per seqid" ) opts , args = p . parse_args ( args ) if len ( a... | %prog summary bedfile |
12,158 | def sort ( args ) : p = OptionParser ( sort . __doc__ ) p . add_option ( "-i" , "--inplace" , dest = "inplace" , default = False , action = "store_true" , help = "Sort bed file in place [default: %default]" ) p . add_option ( "-u" , dest = "unique" , default = False , action = "store_true" , help = "Uniqify the bed fil... | %prog sort bedfile |
12,159 | def mates ( args ) : p = OptionParser ( mates . __doc__ ) p . add_option ( "--lib" , default = False , action = "store_true" , help = "Output library information along with pairs [default: %default]" ) p . add_option ( "--nointra" , default = False , action = "store_true" , help = "Remove mates that are intra-scaffold ... | %prog mates bedfile |
12,160 | def swapped ( self ) : args = [ getattr ( self , attr ) for attr in BlastLine . __slots__ [ : 12 ] ] args [ 0 : 2 ] = [ self . subject , self . query ] args [ 6 : 10 ] = [ self . sstart , self . sstop , self . qstart , self . qstop ] if self . orientation == '-' : args [ 8 ] , args [ 9 ] = args [ 9 ] , args [ 8 ] b = "... | Swap query and subject . |
12,161 | def gff ( args ) : p = OptionParser ( gff . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) gbkfile , = args MultiGenBank ( gbkfile ) | %prog gff seq . gbk |
12,162 | def tee_lookahead ( t , i ) : for value in islice ( t . __copy__ ( ) , i , None ) : return value raise IndexError ( i ) | Inspect the i - th upcomping value from a tee object while leaving the tee object at its current position . |
12,163 | def uniq ( args ) : p = OptionParser ( uniq . __doc__ ) p . set_outfile ( ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) fastqfile , = args fw = must_open ( opts . outfile , "w" ) nduplicates = nreads = 0 seen = set ( ) for rec in iter_fastq ( fastqfile ) : nreads +... | %prog uniq fastqfile |
12,164 | def suffix ( args ) : p = OptionParser ( suffix . __doc__ ) p . set_outfile ( ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) fastqfile , sf = args fw = must_open ( opts . outfile , "w" ) nreads = nselected = 0 for rec in iter_fastq ( fastqfile ) : nreads += 1 if rec... | %prog suffix fastqfile CAG |
12,165 | def readlen ( args ) : p = OptionParser ( readlen . __doc__ ) p . set_firstN ( ) p . add_option ( "--silent" , default = False , action = "store_true" , help = "Do not print read length stats" ) p . add_option ( "--nocheck" , default = False , action = "store_true" , help = "Do not check file type suffix" ) opts , args... | %prog readlen fastqfile |
12,166 | def fasta ( args ) : p = OptionParser ( fasta . __doc__ ) p . add_option ( "--seqtk" , default = False , action = "store_true" , help = "Use seqtk to convert" ) p . set_outdir ( ) p . set_outfile ( outfile = None ) opts , args = p . parse_args ( args ) if len ( args ) < 1 : sys . exit ( not p . print_help ( ) ) fastqfi... | %prog fasta fastqfiles |
12,167 | def filter ( args ) : p = OptionParser ( filter . __doc__ ) p . add_option ( "-q" , dest = "qv" , default = 20 , type = "int" , help = "Minimum quality score to keep [default: %default]" ) p . add_option ( "-p" , dest = "pct" , default = 95 , type = "int" , help = "Minimum percent of bases that have [-q] quality " "[de... | %prog filter paired . fastq |
12,168 | def shuffle ( args ) : p = OptionParser ( shuffle . __doc__ ) p . set_tag ( ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) p1 , p2 = args pairsfastq = pairspf ( ( p1 , p2 ) ) + ".fastq" tag = opts . tag p1fp = must_open ( p1 ) p2fp = must_open ( p2 ) pairsfw = must_... | %prog shuffle p1 . fastq p2 . fastq |
12,169 | def split ( args ) : from jcvi . apps . grid import Jobs p = OptionParser ( split . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) pairsfastq , = args gz = pairsfastq . endswith ( ".gz" ) pf = pairsfastq . replace ( ".gz" , "" ) . rsplit ( "." , 1 ) [ 0 ] p1... | %prog split pairs . fastq |
12,170 | def guessoffset ( args ) : p = OptionParser ( guessoffset . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) fastqfile , = args ai = iter_fastq ( fastqfile ) rec = next ( ai ) offset = 64 while rec : quality = rec . quality lowcounts = len ( [ x for x in quali... | %prog guessoffset fastqfile |
12,171 | def format ( args ) : p = OptionParser ( format . __doc__ ) p . add_option ( "--convert" , default = None , choices = [ ">=1.8" , "<1.8" , "sra" ] , help = "Convert fastq header to a different format" + " [default: %default]" ) p . set_tag ( specify_tag = True ) opts , args = p . parse_args ( args ) if len ( args ) != ... | %prog format fastqfile |
12,172 | def trim ( args ) : p = OptionParser ( trim . __doc__ ) p . add_option ( "-f" , dest = "first" , default = 0 , type = "int" , help = "First base to keep. Default is 1." ) p . add_option ( "-l" , dest = "last" , default = 0 , type = "int" , help = "Last base to keep. Default is entire read." ) opts , args = p . parse_ar... | %prog trim fastqfile |
12,173 | def catread ( args ) : p = OptionParser ( catread . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) r1 , r2 = args p1fp , p2fp = FastqPairedIterator ( r1 , r2 ) outfile = pairspf ( ( r1 , r2 ) ) + ".cat.fastq" fw = must_open ( outfile , "w" ) while True : a =... | %prog catread fastqfile1 fastqfile2 |
12,174 | def splitread ( args ) : p = OptionParser ( splitread . __doc__ ) p . add_option ( "-n" , dest = "n" , default = 76 , type = "int" , help = "Split at N-th base position [default: %default]" ) p . add_option ( "--rc" , default = False , action = "store_true" , help = "Reverse complement second read [default: %default]" ... | %prog splitread fastqfile |
12,175 | def size ( args ) : p = OptionParser ( size . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) < 1 : sys . exit ( not p . print_help ( ) ) total_size = total_numrecords = 0 for f in args : cur_size = cur_numrecords = 0 for rec in iter_fastq ( f ) : if not rec : break cur_numrecords += 1 cur_size += len (... | %prog size fastqfile |
12,176 | def convert ( args ) : p = OptionParser ( convert . __doc__ ) p . set_phred ( ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) infastq , = args phred = opts . phred or str ( guessoffset ( [ infastq ] ) ) ophred = { "64" : "33" , "33" : "64" } [ phred ] gz = infastq . ... | %prog convert in . fastq |
12,177 | def pairinplace ( args ) : from jcvi . utils . iter import pairwise p = OptionParser ( pairinplace . __doc__ ) p . set_rclip ( ) p . set_tag ( ) p . add_option ( "--base" , help = "Base name for the output files [default: %default]" ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . pri... | %prog pairinplace bulk . fastq |
12,178 | def fromsra ( args ) : p = OptionParser ( fromsra . __doc__ ) p . add_option ( "--paired" , default = False , action = "store_true" , help = "Specify if library layout is paired-end " + "[default: %default]" ) p . add_option ( "--compress" , default = None , choices = [ "gzip" , "bzip2" ] , help = "Compress output fast... | %prog fromsra srafile |
12,179 | def blast ( args ) : p = OptionParser ( blast . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) btabfile , = args btab = Btab ( btabfile ) for b in btab : print ( b . blastline ) | %prog blast btabfile |
12,180 | def bed ( args ) : from jcvi . formats . blast import BlastLine p = OptionParser ( bed . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) btabfile , = args btab = Btab ( btabfile ) for b in btab : Bline = BlastLine ( b . blastline ) print ( Bline . bedline ) | %prog bed btabfile |
12,181 | def gff ( args ) : from jcvi . utils . range import range_minmax from jcvi . formats . gff import valid_gff_parent_child , valid_gff_type p = OptionParser ( gff . __doc__ ) p . add_option ( "--source" , default = None , help = "Specify GFF source." + " By default, it picks algorithm used to generate btab file." + " [de... | %prog gff btabfile |
12,182 | def batch_taxonomy ( list_of_taxids ) : for taxid in list_of_taxids : handle = Entrez . efetch ( db = 'Taxonomy' , id = taxid , retmode = "xml" ) records = Entrez . read ( handle ) yield records [ 0 ] [ "ScientificName" ] | Convert list of taxids to Latin names |
12,183 | def batch_entrez ( list_of_terms , db = "nuccore" , retmax = 1 , rettype = "fasta" , batchsize = 1 , email = myEmail ) : for term in list_of_terms : logging . debug ( "Search term %s" % term ) success = False ids = None if not term : continue while not success : try : search_handle = Entrez . esearch ( db = db , retmax... | Retrieve multiple rather than a single record |
12,184 | def ensembl ( args ) : p = OptionParser ( ensembl . __doc__ ) p . add_option ( "--version" , default = "75" , help = "Ensembl version [default: %default]" ) opts , args = p . parse_args ( args ) version = opts . version url = "ftp://ftp.ensembl.org/pub/release-{0}/" . format ( version ) fasta_url = url + "fasta/" valid... | %prog ensembl species |
12,185 | def get_first_rec ( fastafile ) : f = list ( SeqIO . parse ( fastafile , "fasta" ) ) if len ( f ) > 1 : logging . debug ( "{0} records found in {1}, using the first one" . format ( len ( f ) , fastafile ) ) return f [ 0 ] | Returns the first record in the fastafile |
12,186 | def bisect ( args ) : p = OptionParser ( bisect . __doc__ ) p . set_email ( ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) acc , fastafile = args arec = get_first_rec ( fastafile ) valid = None for i in range ( 1 , 100 ) : term = "%s.%d" % ( acc , i ) try : query = ... | %prog bisect acc accession . fasta |
12,187 | def inspect ( item , maxchar = 80 ) : for i in dir ( item ) : try : member = str ( getattr ( item , i ) ) if maxchar and len ( member ) > maxchar : member = member [ : maxchar ] + "..." except : member = "[ERROR]" print ( "{}: {}" . format ( i , member ) , file = sys . stderr ) | Inspect the attributes of an item . |
12,188 | def depends ( func ) : from jcvi . apps . base import need_update , listify infile = "infile" outfile = "outfile" def wrapper ( * args , ** kwargs ) : assert outfile in kwargs , "You need to specify `outfile=` on function call" if infile in kwargs : infilename = listify ( kwargs [ infile ] ) for x in infilename : asser... | Decorator to perform check on infile and outfile . When infile is not present issue warning and when outfile is present skip function calls . |
12,189 | def human_size ( size , a_kilobyte_is_1024_bytes = False , precision = 1 , target = None ) : if size < 0 : raise ValueError ( 'number must be non-negative' ) multiple = 1024 if a_kilobyte_is_1024_bytes else 1000 for suffix in SUFFIXES [ multiple ] : if target : if suffix == target : break size /= float ( multiple ) els... | Convert a file size to human - readable form . |
12,190 | def gene_name ( st , exclude = ( "ev" , ) , sep = "." ) : if any ( st . startswith ( x ) for x in exclude ) : sep = None st = st . split ( '|' ) [ 0 ] if sep and sep in st : name , suffix = st . rsplit ( sep , 1 ) else : name , suffix = st , "" if len ( suffix ) != 1 : name = st return name | Helper functions in the BLAST filtering to get rid alternative splicings . This is ugly but different annotation groups are inconsistent with respect to how the alternative splicings are named . Mostly it can be done by removing the suffix except for ones in the exclude list . |
12,191 | def fixChromName ( name , orgn = "medicago" ) : import re mtr_pat1 = re . compile ( r"Mt[0-9]+\.[0-9]+[\.[0-9]+]{0,}_([a-z]+[0-9]+)" ) mtr_pat2 = re . compile ( r"([A-z0-9]+)_[A-z]+_[A-z]+" ) zmays_pat = re . compile ( r"[a-z]+:[A-z0-9]+:([A-z0-9]+):[0-9]+:[0-9]+:[0-9]+" ) zmays_sub = { 'mitochondrion' : 'Mt' , 'chloro... | Convert quirky chromosome names encountered in different release files which are very project specific into a more general format . |
12,192 | def fill ( text , delimiter = "" , width = 70 ) : texts = [ ] for i in xrange ( 0 , len ( text ) , width ) : t = delimiter . join ( text [ i : i + width ] ) texts . append ( t ) return "\n" . join ( texts ) | Wrap text with width per line |
12,193 | def tile ( lt , width = 70 , gap = 1 ) : from jcvi . utils . iter import grouper max_len = max ( len ( x ) for x in lt ) + gap items_per_line = max ( width // max_len , 1 ) lt = [ x . rjust ( max_len ) for x in lt ] g = list ( grouper ( lt , items_per_line , fillvalue = "" ) ) return "\n" . join ( "" . join ( x ) for x... | Pretty print list of items . |
12,194 | def normalize_lms_axis ( ax , xlim = None , ylim = None , xfactor = 1e-6 , yfactor = 1 , xlabel = None , ylabel = "Map (cM)" ) : if xlim : ax . set_xlim ( 0 , xlim ) if ylim : ax . set_ylim ( 0 , ylim ) if xlabel : xticklabels = [ int ( round ( x * xfactor ) ) for x in ax . get_xticks ( ) ] ax . set_xticklabels ( xtick... | Normalize the axis limits and labels to beautify axis . |
12,195 | def fake ( args ) : from math import ceil from random import choice from Bio import SeqIO from Bio . Seq import Seq from Bio . SeqRecord import SeqRecord p = OptionParser ( fake . __doc__ ) p . set_outfile ( ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) inputbed , ... | %prog fake input . bed |
12,196 | def compute_score ( markers , bonus , penalty ) : nmarkers = len ( markers ) s = [ bonus ] * nmarkers f = [ - 1 ] * nmarkers for i in xrange ( 1 , nmarkers ) : for j in xrange ( i ) : mi , mj = markers [ i ] , markers [ j ] t = bonus if mi . mlg == mj . mlg else penalty + bonus if s [ i ] < s [ j ] + t : s [ i ] = s [ ... | Compute chain score using dynamic programming . If a marker is the same linkage group as a previous one we add bonus ; otherwise we penalize the chain switching . |
12,197 | def split ( args ) : p = OptionParser ( split . __doc__ ) p . add_option ( "--chunk" , default = 4 , type = "int" , help = "Split chunks of at least N markers" ) p . add_option ( "--splitsingle" , default = False , action = "store_true" , help = "Split breakpoint range right in the middle" ) opts , args = p . parse_arg... | %prog split input . bed |
12,198 | def movie ( args ) : p = OptionParser ( movie . __doc__ ) p . add_option ( "--gapsize" , default = 100 , type = "int" , help = "Insert gaps of size between scaffolds" ) add_allmaps_plot_options ( p ) opts , args = p . parse_args ( args ) if len ( args ) != 3 : sys . exit ( not p . print_help ( ) ) inputbed , scaffoldsf... | %prog movie input . bed scaffolds . fasta chr1 |
12,199 | def make_movie ( workdir , pf , dpi = 120 , fps = 1 , format = "pdf" , engine = "ffmpeg" ) : os . chdir ( workdir ) if format != "png" : cmd = "parallel convert -density {}" . format ( dpi ) cmd += " {} {.}.png ::: " + "*.{}" . format ( format ) sh ( cmd ) assert engine in ( "ffmpeg" , "gifsicle" ) , "Only ffmpeg or gi... | Make the movie using either ffmpeg or gifsicle . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.