idx int64 0 63k | question stringlengths 61 4.03k | target stringlengths 6 1.23k |
|---|---|---|
11,900 | def image_to_string ( image , lang = None , boxes = False ) : input_file_name = '%s.bmp' % tempnam ( ) output_file_name_base = tempnam ( ) if not boxes : output_file_name = '%s.txt' % output_file_name_base else : output_file_name = '%s.box' % output_file_name_base try : image . save ( input_file_name ) status , error_s... | Runs tesseract on the specified image . First the image is written to disk and then the tesseract command is run on the image . Resseract s result is read and the temporary files are erased . |
11,901 | def mitosomatic ( args ) : import pandas as pd p = OptionParser ( mitosomatic . __doc__ ) p . add_option ( "--minaf" , default = .005 , type = "float" , help = "Minimum allele fraction" ) p . add_option ( "--maxaf" , default = .1 , type = "float" , help = "Maximum allele fraction" ) opts , args = p . parse_args ( args ... | %prog mitosomatic t . piledriver |
11,902 | def bed ( args ) : p = OptionParser ( bed . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) delt , = args dt = Delly ( delt ) dt . write_bed ( "del.bed" ) | %prog bed del . txt |
11,903 | def mito ( args ) : p = OptionParser ( mito . __doc__ ) p . set_aws_opts ( store = "hli-mv-data-science/htang/mito-deletions" ) p . add_option ( "--realignonly" , default = False , action = "store_true" , help = "Realign only" ) p . add_option ( "--svonly" , default = False , action = "store_true" , help = "Run Realign... | %prog mito chrM . fa input . bam |
11,904 | def fcs ( args ) : p = OptionParser ( fcs . __doc__ ) p . add_option ( "--cutoff" , default = 200 , help = "Skip small components less than [default: %default]" ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) fcsfile , = args cutoff = opts . cutoff fp = open ( fcsfil... | %prog fcs fcsfile |
11,905 | def asn ( args ) : from jcvi . formats . base import must_open p = OptionParser ( asn . __doc__ ) p . set_outfile ( ) opts , args = p . parse_args ( args ) if len ( args ) < 1 : sys . exit ( not p . print_help ( ) ) fw = must_open ( opts . outfile , "w" ) for asnfile in args : fp = open ( asnfile ) ingeneralblock = Fal... | %prog asn asnfiles |
11,906 | def htgnew ( args ) : from jcvi . formats . fasta import sequin p = OptionParser ( htgnew . __doc__ ) p . add_option ( "--comment" , default = "" , help = "Comments for this submission [default: %default]" ) opts , args = p . parse_args ( args ) if len ( args ) != 3 : sys . exit ( not p . print_help ( ) ) fastafile , p... | %prog htgnew fastafile phasefile template . sbt |
11,907 | def convert_96_to_384 ( c96 , quad , nrows = Nrows , ncols = Ncols ) : rows , cols = get_rows_cols ( ) plate , splate = get_plate ( ) n96 = rows . index ( c96 [ 0 ] ) * ncols / 2 + int ( c96 [ 1 : ] ) q = "{0:02d}{1}" . format ( n96 , "ABCD" [ quad - 1 ] ) return splate [ q ] | Convert the 96 - well number and quad number to 384 - well number |
11,908 | def parse_description ( s ) : s = "" . join ( s . split ( ) [ 1 : ] ) . replace ( "/" , ";" ) a = parse_qs ( s ) return a | Returns a dictionary based on the FASTA header assuming JCVI data |
11,909 | def scaffold ( args ) : from jcvi . formats . base import FileMerger from jcvi . formats . bed import mates from jcvi . formats . contig import frombed from jcvi . formats . fasta import join from jcvi . utils . iter import grouper p = OptionParser ( scaffold . __doc__ ) p . set_rclip ( rclip = 1 ) p . add_option ( "--... | %prog scaffold ctgfasta reads1 . fasta mapping1 . bed reads2 . fasta mapping2 . bed ... |
11,910 | def diginorm ( args ) : from jcvi . formats . fastq import shuffle , pairinplace , split from jcvi . apps . base import getfilesize p = OptionParser ( diginorm . __doc__ ) p . add_option ( "--single" , default = False , action = "store_true" , help = "Single end reads" ) p . add_option ( "--tablesize" , help = "Memory ... | %prog diginorm fastqfile |
11,911 | def contamination ( args ) : from jcvi . apps . bowtie import BowtieLogFile , align p = OptionParser ( contamination . __doc__ ) p . set_firstN ( ) opts , args = p . parse_args ( args ) if len ( args ) != 3 : sys . exit ( not p . print_help ( ) ) ecoli , genome , fq = args firstN_opt = "--firstN={0}" . format ( opts . ... | %prog contamination Ecoli . fasta genome . fasta read . fastq |
11,912 | def alignextend ( args ) : choices = "prepare,align,filter,rmdup,genreads" . split ( "," ) p = OptionParser ( alignextend . __doc__ ) p . add_option ( "--nosuffix" , default = False , action = "store_true" , help = "Do not add /1/2 suffix to the read [default: %default]" ) p . add_option ( "--rc" , default = False , ac... | %prog alignextend ref . fasta read . 1 . fastq read . 2 . fastq |
11,913 | def hetsmooth ( args ) : p = OptionParser ( hetsmooth . __doc__ ) p . add_option ( "-K" , default = 23 , type = "int" , help = "K-mer size [default: %default]" ) p . add_option ( "-L" , type = "int" , help = "Bottom threshold, first min [default: %default]" ) p . add_option ( "-U" , type = "int" , help = "Top threshold... | %prog hetsmooth reads_1 . fq reads_2 . fq jf - 23_0 |
11,914 | def range_intersect ( a , b , extend = 0 ) : a_min , a_max = a if a_min > a_max : a_min , a_max = a_max , a_min b_min , b_max = b if b_min > b_max : b_min , b_max = b_max , b_min if a_max + extend < b_min or b_max + extend < a_min : return None i_min = max ( a_min , b_min ) i_max = min ( a_max , b_max ) if i_min > i_ma... | Returns the intersection between two reanges . |
11,915 | def range_overlap ( a , b , ratio = False ) : a_chr , a_min , a_max = a b_chr , b_min , b_max = b a_min , a_max = sorted ( ( a_min , a_max ) ) b_min , b_max = sorted ( ( b_min , b_max ) ) shorter = min ( ( a_max - a_min ) , ( b_max - b_min ) ) + 1 if a_chr != b_chr : ov = 0 else : ov = min ( shorter , ( a_max - b_min +... | Returns whether two ranges overlap . Set percentage = True returns overlap ratio over the shorter range of the two . |
11,916 | def range_distance ( a , b , distmode = 'ss' ) : assert distmode in ( 'ss' , 'ee' ) a_chr , a_min , a_max , a_strand = a b_chr , b_min , b_max , b_strand = b if a_chr != b_chr : dist = - 1 else : if a_min > b_min : a_min , b_min = b_min , a_min a_max , b_max = b_max , a_max a_strand , b_strand = b_strand , a_strand if ... | Returns the distance between two ranges . |
11,917 | def range_minmax ( ranges ) : rmin = min ( ranges ) [ 0 ] rmax = max ( ranges , key = lambda x : x [ 1 ] ) [ 1 ] return rmin , rmax | Returns the span of a collection of ranges where start is the smallest of all starts and end is the largest of all ends . |
11,918 | def range_interleave ( ranges , sizes = { } , empty = False ) : from jcvi . utils . iter import pairwise ranges = range_merge ( ranges ) interleaved_ranges = [ ] for ch , cranges in groupby ( ranges , key = lambda x : x [ 0 ] ) : cranges = list ( cranges ) size = sizes . get ( ch , None ) if size : ch , astart , aend =... | Returns the ranges in between the given ranges . |
11,919 | def range_merge ( ranges , dist = 0 ) : if not ranges : return [ ] ranges . sort ( ) cur_range = list ( ranges [ 0 ] ) merged_ranges = [ ] for r in ranges [ 1 : ] : if r [ 1 ] - cur_range [ 2 ] > dist or r [ 0 ] != cur_range [ 0 ] : merged_ranges . append ( tuple ( cur_range ) ) cur_range = list ( r ) else : cur_range ... | Returns merged range . Similar to range_union except this returns new ranges . |
11,920 | def range_span ( ranges ) : if not ranges : return 0 ranges . sort ( ) ans = 0 for seq , lt in groupby ( ranges , key = lambda x : x [ 0 ] ) : lt = list ( lt ) ans += max ( max ( lt ) [ 1 : ] ) - min ( min ( lt ) [ 1 : ] ) + 1 return ans | Returns the total span between the left most range to the right most range . |
11,921 | def range_piles ( ranges ) : endpoints = _make_endpoints ( ranges ) for seqid , ends in groupby ( endpoints , lambda x : x [ 0 ] ) : active = [ ] depth = 0 for seqid , pos , leftright , i , score in ends : if leftright == LEFT : active . append ( i ) depth += 1 else : depth -= 1 if depth == 0 and active : yield active ... | Return piles of intervals that overlap . The piles are only interrupted by regions of zero coverage . |
11,922 | def range_conflict ( ranges , depth = 1 ) : overlap = set ( ) active = set ( ) endpoints = _make_endpoints ( ranges ) for seqid , ends in groupby ( endpoints , lambda x : x [ 0 ] ) : active . clear ( ) for seqid , pos , leftright , i , score in ends : if leftright == LEFT : active . add ( i ) else : active . remove ( i... | Find intervals that are overlapping in 1 - dimension . Return groups of block IDs that are in conflict . |
11,923 | def loadtable ( header , rows , major = '=' , minor = '-' , thousands = True ) : formatted = load_csv ( header , rows , sep = " " , thousands = thousands ) header , rows = formatted [ 0 ] , formatted [ 1 : ] return banner ( header , rows ) | Print a tabular output with horizontal separators |
11,924 | def write_csv ( header , contents , sep = "," , filename = "stdout" , thousands = False , tee = False , align = True , comment = False ) : from jcvi . formats . base import must_open formatted = load_csv ( header , contents , sep = sep , thousands = thousands , align = align ) if comment : formatted [ 0 ] = '#' + forma... | Write csv that are aligned with the column headers . |
11,925 | def blat ( args ) : from jcvi . formats . base import is_number from jcvi . formats . blast import best as blast_best , bed as blast_bed from jcvi . apps . align import blat as blat_align p = OptionParser ( blat . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( )... | %prog blat map1 . txt ref . fasta |
11,926 | def header ( args ) : from jcvi . formats . base import DictFile p = OptionParser ( header . __doc__ ) p . add_option ( "--prefix" , default = "" , help = "Prepend text to line number [default: %default]" ) p . add_option ( "--ids" , help = "Write ids to file [default: %default]" ) opts , args = p . parse_args ( args )... | %prog header map conversion_table |
11,927 | def rename ( args ) : p = OptionParser ( rename . __doc__ ) p . set_outfile ( ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) mstmap , bedfile = args markersbed = Bed ( bedfile ) markers = markersbed . order data = MSTMap ( mstmap ) header = data . header header = [ ... | %prog rename map markers . bed > renamed . map |
11,928 | def anchor ( args ) : from jcvi . formats . blast import bed p = OptionParser ( anchor . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) mapbed , blastfile = args bedfile = bed ( [ blastfile ] ) markersbed = Bed ( bedfile ) markers = markersbed . order mapbed... | %prog anchor map . bed markers . blast > anchored . bed |
11,929 | def bed ( args ) : p = OptionParser ( bed . __doc__ ) p . add_option ( "--switch" , default = False , action = "store_true" , help = "Switch reference and aligned map elements [default: %default]" ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) mapout , = args pf = m... | %prog fasta map . out |
11,930 | def fasta ( args ) : from jcvi . formats . sizes import Sizes p = OptionParser ( fasta . __doc__ ) p . add_option ( "--extend" , default = 1000 , type = "int" , help = "Extend seq flanking the gaps [default: %default]" ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) ... | %prog fasta map . out scaffolds . fasta |
11,931 | def breakpoint ( args ) : from jcvi . utils . iter import pairwise p = OptionParser ( breakpoint . __doc__ ) p . add_option ( "--diff" , default = .1 , type = "float" , help = "Maximum ratio of differences allowed [default: %default]" ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . p... | %prog breakpoint mstmap . input > breakpoints . bed |
11,932 | def trimNs ( seq , line , newagp ) : start , end = line . component_beg , line . component_end size = end - start + 1 leftNs , rightNs = 0 , 0 lid , lo = line . component_id , line . orientation for s in seq : if s in 'nN' : leftNs += 1 else : break for s in seq [ : : - 1 ] : if s in 'nN' : rightNs += 1 else : break if... | Test if the sequences contain dangling N s on both sides . This component needs to be adjusted to the actual sequence range . |
11,933 | def fromcsv ( args ) : import csv from jcvi . formats . sizes import Sizes p = OptionParser ( fromcsv . __doc__ ) p . add_option ( "--evidence" , default = "map" , help = "Linkage evidence to add in AGP" ) opts , args = p . parse_args ( args ) if len ( args ) != 3 : sys . exit ( not p . print_help ( ) ) contigsfasta , ... | %prog fromcsv contigs . fasta map . csv map . agp |
11,934 | def compress ( args ) : p = OptionParser ( compress . __doc__ ) p . set_outfile ( ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) aagpfile , bagpfile = args store = { } agp = AGP ( aagpfile ) for a in agp : if a . is_gap : continue if a . sign == 0 : a . sign = 1 sto... | %prog compress a . agp b . agp |
11,935 | def infer ( args ) : from jcvi . apps . grid import WriteJobs from jcvi . formats . bed import sort p = OptionParser ( infer . __doc__ ) p . set_cpus ( ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) scaffoldsf , genomef = args inferbed = "infer-components.bed" if ne... | %prog infer scaffolds . fasta genome . fasta |
11,936 | def format ( args ) : from jcvi . formats . base import DictFile p = OptionParser ( format . __doc__ ) p . add_option ( "--switchcomponent" , help = "Switch component id based on" ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) oldagpfile , newagpfile = args switchco... | %prog format oldagpfile newagpfile |
11,937 | def frombed ( args ) : p = OptionParser ( frombed . __doc__ ) p . add_option ( "--gapsize" , default = 100 , type = "int" , help = "Insert gaps of size [default: %default]" ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) bedfile , = args gapsize = opts . gapsize agpf... | %prog frombed bedfile |
11,938 | def swap ( args ) : from jcvi . utils . range import range_interleave p = OptionParser ( swap . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) agpfile , = args agp = AGP ( agpfile , nogaps = True , validate = False ) agp . sort ( key = lambda x : ( x . compo... | %prog swap agpfile |
11,939 | def stats ( args ) : from jcvi . utils . table import tabulate p = OptionParser ( stats . __doc__ ) p . add_option ( "--warn" , default = False , action = "store_true" , help = "Warnings on small component spans [default: %default]" ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( p . print_h... | %prog stats agpfile |
11,940 | def cut ( args ) : p = OptionParser ( cut . __doc__ ) p . add_option ( "--sep" , default = "." , help = "Separator for splits" ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) agpfile , bedfile = args sep = opts . sep agp = AGP ( agpfile ) bed = Bed ( bedfile ) simple... | %prog cut agpfile bedfile |
11,941 | def summary ( args ) : from jcvi . utils . table import write_csv p = OptionParser ( summary . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( p . print_help ( ) ) agpfile , = args header = "Chromosome #_Distinct #_Components #_Scaffolds " "Scaff_N50 Scaff_L50 Length" . split ( ) agp... | %prog summary agpfile |
11,942 | def phase ( args ) : p = OptionParser ( phase . __doc__ ) p . set_outfile ( ) opts , args = p . parse_args ( args ) if len ( args ) < 1 : sys . exit ( not p . print_help ( ) ) fw = must_open ( opts . outfile , "w" ) for gbfile in args : for rec in SeqIO . parse ( gbfile , "gb" ) : bac_phase , keywords = get_phase ( rec... | %prog phase genbankfiles |
11,943 | def tpf ( args ) : p = OptionParser ( tpf . __doc__ ) p . add_option ( "--noversion" , default = False , action = "store_true" , help = "Remove trailing accession versions [default: %default]" ) p . add_option ( "--gaps" , default = False , action = "store_true" , help = "Include gaps in the output [default: %default]"... | %prog tpf agpfile |
11,944 | def bed ( args ) : from jcvi . formats . obo import validate_term p = OptionParser ( bed . __doc__ ) p . add_option ( "--gaps" , default = False , action = "store_true" , help = "Only print bed lines for gaps [default: %default]" ) p . add_option ( "--nogaps" , default = False , action = "store_true" , help = "Do not p... | %prog bed agpfile |
11,945 | def extendbed ( args ) : from jcvi . formats . sizes import Sizes p = OptionParser ( extendbed . __doc__ ) p . add_option ( "--nogaps" , default = False , action = "store_true" , help = "Do not print bed lines for gaps [default: %default]" ) p . add_option ( "--bed12" , default = False , action = "store_true" , help = ... | %prog extend agpfile componentfasta |
11,946 | def gaps ( args ) : from jcvi . graphics . histogram import loghistogram p = OptionParser ( gaps . __doc__ ) p . add_option ( "--merge" , dest = "merge" , default = False , action = "store_true" , help = "Merge adjacent gaps (to conform to AGP specification)" ) p . add_option ( "--header" , default = False , action = "... | %prog gaps agpfile |
11,947 | def tidy ( args ) : p = OptionParser ( tidy . __doc__ ) p . add_option ( "--nogaps" , default = False , action = "store_true" , help = "Remove all gap lines [default: %default]" ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( p . print_help ( ) ) agpfile , componentfasta = args originalagpfi... | %prog tidy agpfile componentfasta |
11,948 | def build ( args ) : p = OptionParser ( build . __doc__ ) p . add_option ( "--newagp" , dest = "newagp" , default = False , action = "store_true" , help = "Check components to trim dangling N's [default: %default]" ) p . add_option ( "--novalidate" , dest = "novalidate" , default = False , action = "store_true" , help ... | %prog build agpfile componentfasta targetfasta |
11,949 | def validate ( args ) : p = OptionParser ( validate . __doc__ ) opts , args = p . parse_args ( args ) try : agpfile , componentfasta , targetfasta = args except Exception as e : sys . exit ( p . print_help ( ) ) agp = AGP ( agpfile ) build = Fasta ( targetfasta ) bacs = Fasta ( componentfasta , index = False ) for alin... | %prog validate agpfile componentfasta targetfasta |
11,950 | def getNorthSouthClone ( self , i ) : north = self . getAdjacentClone ( i , south = False ) south = self . getAdjacentClone ( i ) return north , south | Returns the adjacent clone name from both sides . |
11,951 | def build_one ( self , object , lines , fasta , fw , newagp = None ) : components = [ ] total_bp = 0 for line in lines : if line . is_gap : seq = 'N' * line . gap_length if newagp : print ( line , file = newagp ) else : seq = fasta . sequence ( dict ( chr = line . component_id , start = line . component_beg , stop = li... | Construct molecule using component fasta sequence |
11,952 | def getAdjacentClone ( self , i , south = True ) : rr = xrange ( i + 1 , len ( self ) ) if south else xrange ( i - 1 , - 1 , - 1 ) a = self [ i ] for ix in rr : x = self [ ix ] if x . object != a . object : break return x return None | Returns adjacent clone name either the line before or after the current line . |
11,953 | def genemark ( args ) : p = OptionParser ( genemark . __doc__ ) p . add_option ( "--junctions" , help = "Path to `junctions.bed` from Tophat2" ) p . set_home ( "gmes" ) p . set_cpus ( cpus = 32 ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) species , fastafile = arg... | %prog genemark species fastafile |
11,954 | def snap ( args ) : p = OptionParser ( snap . __doc__ ) p . set_home ( "maker" ) opts , args = p . parse_args ( args ) if len ( args ) != 3 : sys . exit ( not p . print_help ( ) ) species , gffile , fastafile = args mhome = opts . maker_home snapdir = "snap" mkdir ( snapdir ) cwd = os . getcwd ( ) os . chdir ( snapdir ... | %prog snap species gffile fastafile |
11,955 | def augustus ( args ) : p = OptionParser ( augustus . __doc__ ) p . add_option ( "--autotrain" , default = False , action = "store_true" , help = "Run autoAugTrain.pl to iteratively train AUGUSTUS" ) p . set_home ( "augustus" ) opts , args = p . parse_args ( args ) if len ( args ) != 3 : sys . exit ( not p . print_help... | %prog augustus species gffile fastafile |
11,956 | def merger ( args ) : p = OptionParser ( merger . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 3 : sys . exit ( not p . print_help ( ) ) layout , gkpstore , contigs = args fp = open ( layout ) pf = "0" iidfile = pf + ".iids" for i , row in enumerate ( fp ) : logging . debug ( "Read unitig {0}" . f... | %prog merger layout gkpStore contigs . fasta |
11,957 | def unitigs ( args ) : p = OptionParser ( unitigs . __doc__ ) p . add_option ( "--maxerr" , default = 2 , type = "int" , help = "Maximum error rate" ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) bestedges , = args G = read_graph ( bestedges , maxerr = opts . maxerr... | %prog unitigs best . edges |
11,958 | def astat ( args ) : p = OptionParser ( astat . __doc__ ) p . add_option ( "--cutoff" , default = 1000 , type = "int" , help = "Length cutoff [default: %default]" ) p . add_option ( "--genome" , default = "" , help = "Genome name [default: %default]" ) p . add_option ( "--arrDist" , default = False , action = "store_tr... | %prog astat coverage . log |
11,959 | def emitFragment ( fw , fragID , libID , shredded_seq , clr = None , qvchar = 'l' , fasta = False ) : if fasta : s = SeqRecord ( shredded_seq , id = fragID , description = "" ) SeqIO . write ( [ s ] , fw , "fasta" ) return seq = str ( shredded_seq ) slen = len ( seq ) qvs = qvchar * slen if clr is None : clr_beg , clr_... | Print out the shredded sequence . |
11,960 | def make_matepairs ( fastafile ) : assert op . exists ( fastafile ) matefile = fastafile . rsplit ( "." , 1 ) [ 0 ] + ".mates" if op . exists ( matefile ) : logging . debug ( "matepairs file `{0}` found" . format ( matefile ) ) else : logging . debug ( "parsing matepairs from `{0}`" . format ( fastafile ) ) matefw = op... | Assumes the mates are adjacent sequence records |
11,961 | def sff ( args ) : p = OptionParser ( sff . __doc__ ) p . add_option ( "--prefix" , dest = "prefix" , default = None , help = "Output frg filename prefix" ) p . add_option ( "--nodedup" , default = False , action = "store_true" , help = "Do not remove duplicates [default: %default]" ) p . set_size ( ) opts , args = p .... | %prog sff sffiles |
11,962 | def fastq ( args ) : from jcvi . formats . fastq import guessoffset p = OptionParser ( fastq . __doc__ ) p . add_option ( "--outtie" , dest = "outtie" , default = False , action = "store_true" , help = "Are these outie reads? [default: %default]" ) p . set_phred ( ) p . set_size ( ) opts , args = p . parse_args ( args ... | %prog fastq fastqfile |
11,963 | def clr ( args ) : p = OptionParser ( clr . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) < 2 : sys . exit ( not p . print_help ( ) ) blastfile = args [ 0 ] fastafiles = args [ 1 : ] sizes = { } for fa in fastafiles : f = Fasta ( fa ) sizes . update ( f . itersizes ( ) ) b = Blast ( blastfile ) for qu... | %prog blastfile fastafiles |
11,964 | def truncate_name ( name , rule = None ) : import re if rule is None : return name k = re . search ( "(?<=^head)[0-9]{1,2}$" , rule ) if k : k = k . group ( 0 ) tname = name [ int ( k ) : ] else : k = re . search ( "(?<=^ohead)[0-9]{1,2}$" , rule ) if k : k = k . group ( 0 ) tname = name [ : int ( k ) ] else : k = re .... | shorten taxa names for tree display |
11,965 | def run_treefix ( input , stree_file , smap_file , a_ext = ".fasta" , o_ext = ".dnd" , n_ext = ".treefix.dnd" , ** kwargs ) : cl = TreeFixCommandline ( input = input , stree_file = stree_file , smap_file = smap_file , a_ext = a_ext , o = o_ext , n = n_ext , ** kwargs ) outtreefile = input . rsplit ( o_ext , 1 ) [ 0 ] +... | get the ML tree closest to the species tree |
11,966 | def run_gblocks ( align_fasta_file , ** kwargs ) : cl = GblocksCommandline ( aln_file = align_fasta_file , ** kwargs ) r , e = cl . run ( ) print ( "Gblocks:" , cl , file = sys . stderr ) if e : print ( "***Gblocks could not run" , file = sys . stderr ) return None else : print ( r , file = sys . stderr ) alignp = re .... | remove poorly aligned positions and divergent regions with Gblocks |
11,967 | def run_ffitch ( distfile , outtreefile , intreefile = None , ** kwargs ) : cl = FfitchCommandline ( datafile = distfile , outtreefile = outtreefile , intreefile = intreefile , ** kwargs ) r , e = cl . run ( ) if e : print ( "***ffitch could not run" , file = sys . stderr ) return None else : print ( "ffitch:" , cl , f... | Infer tree branch lengths using ffitch in EMBOSS PHYLIP |
11,968 | def smart_reroot ( treefile , outgroupfile , outfile , format = 0 ) : tree = Tree ( treefile , format = format ) leaves = [ t . name for t in tree . get_leaves ( ) ] [ : : - 1 ] outgroup = [ ] for o in must_open ( outgroupfile ) : o = o . strip ( ) for leaf in leaves : if leaf [ : len ( o ) ] == o : outgroup . append (... | simple function to reroot Newick format tree using ete2 |
11,969 | def build_ml_phyml ( alignment , outfile , work_dir = "." , ** kwargs ) : phy_file = op . join ( work_dir , "work" , "aln.phy" ) AlignIO . write ( alignment , file ( phy_file , "w" ) , "phylip-relaxed" ) phyml_cl = PhymlCommandline ( cmd = PHYML_BIN ( "phyml" ) , input = phy_file , ** kwargs ) logging . debug ( "Buildi... | build maximum likelihood tree of DNA seqs with PhyML |
11,970 | def build_ml_raxml ( alignment , outfile , work_dir = "." , ** kwargs ) : work_dir = op . join ( work_dir , "work" ) mkdir ( work_dir ) phy_file = op . join ( work_dir , "aln.phy" ) AlignIO . write ( alignment , file ( phy_file , "w" ) , "phylip-relaxed" ) raxml_work = op . abspath ( op . join ( op . dirname ( phy_file... | build maximum likelihood tree of DNA seqs with RAxML |
11,971 | def SH_raxml ( reftree , querytree , phy_file , shout = "SH_out.txt" ) : assert op . isfile ( reftree ) shout = must_open ( shout , "a" ) raxml_work = op . abspath ( op . join ( op . dirname ( phy_file ) , "raxml_work" ) ) mkdir ( raxml_work ) raxml_cl = RaxmlCommandline ( cmd = RAXML_BIN ( "raxmlHPC" ) , sequences = p... | SH test using RAxML |
11,972 | def subalignment ( alnfle , subtype , alntype = "fasta" ) : aln = AlignIO . read ( alnfle , alntype ) alnlen = aln . get_alignment_length ( ) nseq = len ( aln ) subaln = None subalnfile = alnfle . rsplit ( "." , 1 ) [ 0 ] + "_{0}.{1}" . format ( subtype , alntype ) if subtype == "synonymous" : for j in range ( 0 , alnl... | Subset synonymous or fourfold degenerate sites from an alignment |
11,973 | def merge_rows_local ( filename , ignore = "." , colsep = "\t" , local = 10 , fieldcheck = True , fsep = "," ) : fw = must_open ( filename + ".merged" , "w" ) rows = file ( filename ) . readlines ( ) rows = [ row . strip ( ) . split ( colsep ) for row in rows ] l = len ( rows [ 0 ] ) for rowi , row in enumerate ( rows ... | merge overlapping rows within given row count distance |
11,974 | def add_tandems ( mcscanfile , tandemfile ) : tandems = [ f . strip ( ) . split ( "," ) for f in file ( tandemfile ) ] fw = must_open ( mcscanfile + ".withtandems" , "w" ) fp = must_open ( mcscanfile ) seen = set ( ) for i , row in enumerate ( fp ) : if row [ 0 ] == '#' : continue anchorslist = row . strip ( ) . split ... | add tandem genes to anchor genes in mcscan file |
11,975 | def _draw_trees ( trees , nrow = 1 , ncol = 1 , rmargin = .3 , iopts = None , outdir = "." , shfile = None , ** kwargs ) : from jcvi . graphics . tree import draw_tree if shfile : SHs = DictFile ( shfile , delimiter = "\t" ) ntrees = len ( trees ) n = nrow * ncol for x in xrange ( int ( ceil ( float ( ntrees ) / n ) ) ... | Draw one or multiple trees on one plot . |
11,976 | def sort_layout ( thread , listfile , column = 0 ) : from jcvi . formats . base import DictFile outfile = listfile . rsplit ( "." , 1 ) [ 0 ] + ".sorted.list" threadorder = thread . order fw = open ( outfile , "w" ) lt = DictFile ( listfile , keypos = column , valuepos = None ) threaded = [ ] imported = set ( ) for t i... | Sort the syntelog table according to chromomomal positions . First orient the contents against threadbed then for contents not in threadbed insert to the nearest neighbor . |
11,977 | def layout ( args ) : p = OptionParser ( layout . __doc__ ) p . add_option ( "--sort" , help = "Sort layout file based on bedfile [default: %default]" ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) omgfile , taxa = args listfile = omgfile . rsplit ( "." , 1 ) [ 0 ] ... | %prog layout omgfile taxa |
11,978 | def omgparse ( args ) : p = OptionParser ( omgparse . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) work , = args omgfiles = glob ( op . join ( work , "gf*.out" ) ) for omgfile in omgfiles : omg = OMGFile ( omgfile ) best = omg . best ( ) for bb in best : g... | %prog omgparse work |
11,979 | def group ( args ) : p = OptionParser ( group . __doc__ ) p . set_outfile ( ) opts , args = p . parse_args ( args ) if len ( args ) < 1 : sys . exit ( not p . print_help ( ) ) anchorfiles = args groups = Grouper ( ) for anchorfile in anchorfiles : ac = AnchorFile ( anchorfile ) for a , b , idx in ac . iter_pairs ( ) : ... | %prog group anchorfiles |
11,980 | def omg ( args ) : p = OptionParser ( omg . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) < 1 : sys . exit ( not p . print_help ( ) ) weightsfiles = args groupfile = group ( weightsfiles + [ "--outfile=groups" ] ) weights = get_weights ( weightsfiles ) info = get_info ( ) fp = open ( groupfile ) work ... | %prog omg weightsfile |
11,981 | def omgprepare ( args ) : from jcvi . formats . blast import cscore from jcvi . formats . base import DictFile p = OptionParser ( omgprepare . __doc__ ) p . add_option ( "--norbh" , action = "store_true" , help = "Disable RBH hits [default: %default]" ) p . add_option ( "--pctid" , default = 0 , type = "int" , help = "... | %prog omgprepare ploidy anchorsfile blastfile |
11,982 | def parse_qs ( qs , keep_blank_values = 0 , strict_parsing = 0 , keep_attr_order = True ) : od = DefaultOrderedDict ( list ) if keep_attr_order else defaultdict ( list ) for name , value in parse_qsl ( qs , keep_blank_values , strict_parsing ) : od [ name ] . append ( value ) return od | Kind of like urlparse . parse_qs except returns an ordered dict . Also avoids replicating that function s bad habit of overriding the built - in dict type . |
11,983 | def index ( self , item ) : 'Find the position of an item. Raise ValueError if not found.' k = self . _key ( item ) i = bisect_left ( self . _keys , k ) j = bisect_right ( self . _keys , k ) return self . _items [ i : j ] . index ( item ) + i | Find the position of an item . Raise ValueError if not found . |
11,984 | def insert ( self , item ) : 'Insert a new item. If equal keys are found, add to the left' k = self . _key ( item ) i = bisect_left ( self . _keys , k ) self . _keys . insert ( i , k ) self . _items . insert ( i , item ) | Insert a new item . If equal keys are found add to the left |
11,985 | def insert_right ( self , item ) : 'Insert a new item. If equal keys are found, add to the right' k = self . _key ( item ) i = bisect_right ( self . _keys , k ) self . _keys . insert ( i , k ) self . _items . insert ( i , item ) | Insert a new item . If equal keys are found add to the right |
11,986 | def remove ( self , item ) : 'Remove first occurence of item. Raise ValueError if not found' i = self . index ( item ) del self . _keys [ i ] del self . _items [ i ] | Remove first occurence of item . Raise ValueError if not found |
11,987 | def find_ge ( self , item ) : 'Return first item with a key >= equal to item. Raise ValueError if not found' k = self . _key ( item ) i = bisect_left ( self . _keys , k ) if i != len ( self ) : return self . _items [ i ] raise ValueError ( 'No item found with key at or above: %r' % ( k , ) ) | Return first item with a key > = equal to item . Raise ValueError if not found |
11,988 | def find_gt ( self , item ) : 'Return first item with a key > item. Raise ValueError if not found' k = self . _key ( item ) i = bisect_right ( self . _keys , k ) if i != len ( self ) : return self . _items [ i ] raise ValueError ( 'No item found with key above: %r' % ( k , ) ) | Return first item with a key > item . Raise ValueError if not found |
11,989 | def multireport ( args ) : p = OptionParser ( multireport . __doc__ ) p . set_outfile ( outfile = "Ks_plot.pdf" ) add_plot_options ( p ) opts , args , iopts = p . set_image_options ( args , figsize = "5x5" ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) layoutfile , = args ks_min = opts . vmin ks_max = o... | %prog multireport layoutfile |
11,990 | def fromgroups ( args ) : from jcvi . formats . bed import Bed p = OptionParser ( fromgroups . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) < 2 : sys . exit ( not p . print_help ( ) ) groupsfile = args [ 0 ] bedfiles = args [ 1 : ] beds = [ Bed ( x ) for x in bedfiles ] fp = open ( groupsfile ) group... | %prog fromgroups groupsfile a . bed b . bed ... |
11,991 | def find_synonymous ( input_file , work_dir ) : cwd = os . getcwd ( ) os . chdir ( work_dir ) ctl_file = "yn-input.ctl" output_file = "nuc-subs.yn" ctl_h = open ( ctl_file , "w" ) ctl_h . write ( "seqfile = %s\noutfile = %s\nverbose = 0\n" % ( op . basename ( input_file ) , output_file ) ) ctl_h . write ( "icode = 0\nw... | Run yn00 to find the synonymous subsitution rate for the alignment . |
11,992 | def run_mrtrans ( align_fasta , recs , work_dir , outfmt = "paml" ) : align_file = op . join ( work_dir , "prot-align.fasta" ) nuc_file = op . join ( work_dir , "nuc.fasta" ) output_file = op . join ( work_dir , "nuc-align.mrtrans" ) align_h0 = open ( align_file + "0" , "w" ) align_h0 . write ( str ( align_fasta ) ) al... | Align nucleotide sequences with mrtrans and the protein alignment . |
11,993 | def clustal_align_protein ( recs , work_dir , outfmt = "fasta" ) : fasta_file = op . join ( work_dir , "prot-start.fasta" ) align_file = op . join ( work_dir , "prot.aln" ) SeqIO . write ( recs , file ( fasta_file , "w" ) , "fasta" ) clustal_cl = ClustalwCommandline ( cmd = CLUSTALW_BIN ( "clustalw2" ) , infile = fasta... | Align given proteins with clustalw . recs are iterable of Biopython SeqIO objects |
11,994 | def muscle_align_protein ( recs , work_dir , outfmt = "fasta" , inputorder = True ) : fasta_file = op . join ( work_dir , "prot-start.fasta" ) align_file = op . join ( work_dir , "prot.aln" ) SeqIO . write ( recs , file ( fasta_file , "w" ) , "fasta" ) muscle_cl = MuscleCommandline ( cmd = MUSCLE_BIN ( "muscle" ) , inp... | Align given proteins with muscle . recs are iterable of Biopython SeqIO objects |
11,995 | def subset ( args ) : p = OptionParser ( subset . __doc__ ) p . add_option ( "--noheader" , action = "store_true" , help = "don't write ksfile header line [default: %default]" ) p . add_option ( "--block" , action = "store_true" , help = "preserve block structure in input [default: %default]" ) p . set_stripnames ( ) p... | %prog subset pairsfile ksfile1 ksfile2 ... - o pairs . ks |
11,996 | def report ( args ) : from jcvi . utils . cbook import SummaryStats from jcvi . graphics . histogram import stem_leaf_plot p = OptionParser ( report . __doc__ ) p . add_option ( "--pdf" , default = False , action = "store_true" , help = "Generate graphic output for the histogram [default: %default]" ) p . add_option ( ... | %prog report ksfile |
11,997 | def passthrough ( args ) : p = OptionParser ( passthrough . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) vcffile , newvcffile = args fp = open ( vcffile ) fw = open ( newvcffile , "w" ) gg = [ "0/0" , "0/1" , "1/1" ] for row in fp : if row [ 0 ] == "#" : p... | %prog passthrough chrY . vcf chrY . new . vcf |
11,998 | def validate ( args ) : p = OptionParser ( validate . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) imputed , withheld = args register = { } fp = open ( withheld ) for row in fp : if row [ 0 ] == "#" : continue v = VcfLine ( row ) register [ ( v . seqid , v... | %prog validate imputed . vcf withheld . vcf |
11,999 | def minimac ( args ) : p = OptionParser ( minimac . __doc__ ) p . set_home ( "shapeit" ) p . set_home ( "minimac" ) p . set_outfile ( ) p . set_chr ( ) p . set_ref ( ) p . set_cpus ( ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) txtfile , = args ref = opts . ref mm... | %prog batchminimac input . txt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.