idx int64 0 63k | question stringlengths 61 4.03k | target stringlengths 6 1.23k |
|---|---|---|
11,600 | def score_evaluate ( tour , tour_sizes = None , tour_M = None ) : sizes_oo = np . array ( [ tour_sizes [ x ] for x in tour ] ) sizes_cum = np . cumsum ( sizes_oo ) - sizes_oo / 2 s = 0 size = len ( tour ) for ia in xrange ( size ) : a = tour [ ia ] for ib in xrange ( ia + 1 , size ) : b = tour [ ib ] links = tour_M [ a... | SLOW python version of the evaluation function . For benchmarking purposes only . Do not use in production . |
11,601 | def movieframe ( args ) : p = OptionParser ( movieframe . __doc__ ) p . add_option ( "--label" , help = "Figure title" ) p . set_beds ( ) p . set_outfile ( outfile = None ) opts , args , iopts = p . set_image_options ( args , figsize = "16x8" , style = "white" , cmap = "coolwarm" , format = "png" , dpi = 120 ) if len (... | %prog movieframe tour test . clm contigs . ref . anchors |
11,602 | def write_agp ( self , obj , sizes , fw = sys . stdout , gapsize = 100 , gaptype = "contig" , evidence = "map" ) : contigorder = [ ( x . contig_name , x . strand ) for x in self ] order_to_agp ( obj , contigorder , sizes , fw , gapsize = gapsize , gaptype = gaptype , evidence = evidence ) | Converts the ContigOrdering file into AGP format |
11,603 | def parse_ids ( self , skiprecover ) : idsfile = self . idsfile logging . debug ( "Parse idsfile `{}`" . format ( idsfile ) ) fp = open ( idsfile ) tigs = [ ] for row in fp : if row [ 0 ] == '#' : continue atoms = row . split ( ) tig , size = atoms [ : 2 ] size = int ( size ) if skiprecover and len ( atoms ) == 3 and a... | IDS file has a list of contigs that need to be ordered . recover keyword if available in the third column is less confident . |
11,604 | def calculate_densities ( self ) : active = self . active densities = defaultdict ( int ) for ( at , bt ) , links in self . contacts . items ( ) : if not ( at in active and bt in active ) : continue densities [ at ] += links densities [ bt ] += links logdensities = { } for x , d in densities . items ( ) : s = self . ti... | Calculate the density of inter - contig links per base . Strong contigs considered to have high level of inter - contig links in the current partition . |
11,605 | def evaluate_tour_M ( self , tour ) : from . chic import score_evaluate_M return score_evaluate_M ( tour , self . active_sizes , self . M ) | Use Cythonized version to evaluate the score of a current tour |
11,606 | def evaluate_tour_P ( self , tour ) : from . chic import score_evaluate_P return score_evaluate_P ( tour , self . active_sizes , self . P ) | Use Cythonized version to evaluate the score of a current tour with better precision on the distance of the contigs . |
11,607 | def evaluate_tour_Q ( self , tour ) : from . chic import score_evaluate_Q return score_evaluate_Q ( tour , self . active_sizes , self . Q ) | Use Cythonized version to evaluate the score of a current tour taking orientation into consideration . This may be the most accurate evaluation under the right condition . |
11,608 | def flip_all ( self , tour ) : if self . signs is None : score = 0 else : old_signs = self . signs [ : self . N ] score , = self . evaluate_tour_Q ( tour ) self . signs = get_signs ( self . O , validate = False , ambiguous = False ) score_flipped , = self . evaluate_tour_Q ( tour ) if score_flipped >= score : tag = ACC... | Initialize the orientations based on pairwise O matrix . |
11,609 | def flip_whole ( self , tour ) : score , = self . evaluate_tour_Q ( tour ) self . signs = - self . signs score_flipped , = self . evaluate_tour_Q ( tour ) if score_flipped > score : tag = ACCEPT else : self . signs = - self . signs tag = REJECT self . flip_log ( "FLIPWHOLE" , score , score_flipped , tag ) return tag | Test flipping all contigs at the same time to see if score improves . |
11,610 | def flip_one ( self , tour ) : n_accepts = n_rejects = 0 any_tag_ACCEPT = False for i , t in enumerate ( tour ) : if i == 0 : score , = self . evaluate_tour_Q ( tour ) self . signs [ t ] = - self . signs [ t ] score_flipped , = self . evaluate_tour_Q ( tour ) if score_flipped > score : n_accepts += 1 tag = ACCEPT else ... | Test flipping every single contig sequentially to see if score improves . |
11,611 | def prune_tour ( self , tour , cpus ) : while True : tour_score , = self . evaluate_tour_M ( tour ) logging . debug ( "Starting score: {}" . format ( tour_score ) ) active_sizes = self . active_sizes M = self . M args = [ ] for i , t in enumerate ( tour ) : stour = tour [ : i ] + tour [ i + 1 : ] args . append ( ( t , ... | Test deleting each contig and check the delta_score ; tour here must be an array of ints . |
11,612 | def M ( self ) : N = self . N tig_to_idx = self . tig_to_idx M = np . zeros ( ( N , N ) , dtype = int ) for ( at , bt ) , links in self . contacts . items ( ) : if not ( at in tig_to_idx and bt in tig_to_idx ) : continue ai = tig_to_idx [ at ] bi = tig_to_idx [ bt ] M [ ai , bi ] = M [ bi , ai ] = links return M | Contact frequency matrix . Each cell contains how many inter - contig links between i - th and j - th contigs . |
11,613 | def O ( self ) : N = self . N tig_to_idx = self . tig_to_idx O = np . zeros ( ( N , N ) , dtype = int ) for ( at , bt ) , ( strandedness , md , mh ) in self . orientations . items ( ) : if not ( at in tig_to_idx and bt in tig_to_idx ) : continue ai = tig_to_idx [ at ] bi = tig_to_idx [ bt ] score = strandedness * md O ... | Pairwise strandedness matrix . Each cell contains whether i - th and j - th contig are the same orientation + 1 or opposite orientation - 1 . |
11,614 | def P ( self ) : N = self . N tig_to_idx = self . tig_to_idx P = np . zeros ( ( N , N , 2 ) , dtype = int ) for ( at , bt ) , ( strandedness , md , mh ) in self . orientations . items ( ) : if not ( at in tig_to_idx and bt in tig_to_idx ) : continue ai = tig_to_idx [ at ] bi = tig_to_idx [ bt ] P [ ai , bi , 0 ] = P [ ... | Contact frequency matrix with better precision on distance between contigs . In the matrix M the distance is assumed to be the distance between mid - points of two contigs . In matrix Q however we compute harmonic mean of the links for the orientation configuration that is shortest . This offers better precision for th... |
11,615 | def Q ( self ) : N = self . N tig_to_idx = self . tig_to_idx signs = self . signs Q = np . ones ( ( N , N , BB ) , dtype = int ) * - 1 for ( at , bt ) , k in self . contacts_oriented . items ( ) : if not ( at in tig_to_idx and bt in tig_to_idx ) : continue ai = tig_to_idx [ at ] bi = tig_to_idx [ bt ] ao = signs [ ai ]... | Contact frequency matrix when contigs are already oriented . This is s a similar matrix as M but rather than having the number of links in the cell it points to an array that has the actual distances . |
11,616 | def insertionpairs ( args ) : p = OptionParser ( insertionpairs . __doc__ ) p . add_option ( "--extend" , default = 10 , type = "int" , help = "Allow insertion sites to match up within distance" ) p . set_outfile ( ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) bedf... | %prog insertionpairs endpoints . bed |
11,617 | def insertion ( args ) : p = OptionParser ( insertion . __doc__ ) p . add_option ( "--mindepth" , default = 6 , type = "int" , help = "Minimum depth to call an insertion" ) p . set_outfile ( ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) bedfile , = args mindepth = ... | %prog insertion mic . mac . bed |
11,618 | def add_sim_options ( p ) : p . add_option ( "--distance" , default = 500 , type = "int" , help = "Outer distance between the two ends [default: %default]" ) p . add_option ( "--readlen" , default = 150 , type = "int" , help = "Length of the read" ) p . set_depth ( depth = 10 ) p . set_outfile ( outfile = None ) | Add options shared by eagle or wgsim . |
11,619 | def wgsim ( args ) : p = OptionParser ( wgsim . __doc__ ) p . add_option ( "--erate" , default = .01 , type = "float" , help = "Base error rate of the read [default: %default]" ) p . add_option ( "--noerrors" , default = False , action = "store_true" , help = "Simulate reads with no errors [default: %default]" ) p . ad... | %prog wgsim fastafile |
11,620 | def fig4 ( args ) : p = OptionParser ( fig4 . __doc__ ) p . add_option ( "--gauge_step" , default = 200000 , type = "int" , help = "Step size for the base scale" ) opts , args , iopts = p . set_image_options ( args , figsize = "9x7" ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) layout , datadir = args ... | %prog fig4 layout data |
11,621 | def ploidy ( args ) : p = OptionParser ( ploidy . __doc__ ) opts , args , iopts = p . set_image_options ( args , figsize = "8x7" ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) seqidsfile , klayout = args fig = plt . figure ( 1 , ( iopts . w , iopts . h ) ) root = fig . add_axes ( [ 0 , 0 , 1 , 1 ] ) Kar... | %prog ploidy seqids layout |
11,622 | def pasteprepare ( args ) : p = OptionParser ( pasteprepare . __doc__ ) p . add_option ( "--flank" , default = 5000 , type = "int" , help = "Get the seq of size on two ends [default: %default]" ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) goodfasta , = args flank ... | %prog pasteprepare bacs . fasta |
11,623 | def paste ( args ) : from jcvi . formats . bed import uniq p = OptionParser ( paste . __doc__ ) p . add_option ( "--maxsize" , default = 300000 , type = "int" , help = "Maximum size of patchers to be replaced [default: %default]" ) p . add_option ( "--prefix" , help = "Prefix of the new object [default: %default]" ) p ... | %prog paste flanks . bed flanks_vs_assembly . blast backbone . fasta |
11,624 | def eject ( args ) : p = OptionParser ( eject . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) candidates , chrfasta = args sizesfile = Sizes ( chrfasta ) . filename cbedfile = complementBed ( candidates , sizesfile ) cbed = Bed ( cbedfile ) for b in cbed : ... | %prog eject candidates . bed chr . fasta |
11,625 | def closest ( args ) : p = OptionParser ( closest . __doc__ ) p . add_option ( "--om" , default = False , action = "store_true" , help = "The bedfile is OM blocks [default: %default]" ) opts , args = p . parse_args ( args ) if len ( args ) != 3 : sys . exit ( not p . print_help ( ) ) candidates , gapsbed , fastafile = ... | %prog closest candidates . bed gaps . bed fastafile |
11,626 | def insert ( args ) : from jcvi . formats . agp import mask , bed from jcvi . formats . sizes import agp p = OptionParser ( insert . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 4 : sys . exit ( not p . print_help ( ) ) candidates , gapsbed , chrfasta , unplacedfasta = args refinedbed = refine ( [... | %prog insert candidates . bed gaps . bed chrs . fasta unplaced . fasta |
11,627 | def gaps ( args ) : from jcvi . formats . bed import uniq from jcvi . utils . iter import pairwise p = OptionParser ( gaps . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) ombed , fastafile = args ombed = uniq ( [ ombed ] ) bed = Bed ( ombed ) for a , b in p... | %prog gaps OM . bed fastafile |
11,628 | def tips ( args ) : p = OptionParser ( tips . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 4 : sys . exit ( not p . print_help ( ) ) pbedfile , cbedfile , sizesfile , bbfasta = args pbed = Bed ( pbedfile , sorted = False ) cbed = Bed ( cbedfile , sorted = False ) complements = dict ( ) for object ... | %prog tips patchers . bed complements . bed original . fasta backbone . fasta |
11,629 | def fill ( args ) : p = OptionParser ( fill . __doc__ ) p . add_option ( "--extend" , default = 2000 , 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 ( ) ) gapsbed , badfasta = args Ext = opts . exte... | %prog fill gaps . bed bad . fasta |
11,630 | def install ( args ) : from jcvi . apps . align import blast from jcvi . formats . fasta import SeqIO p = OptionParser ( install . __doc__ ) p . set_rclip ( rclip = 1 ) p . add_option ( "--maxsize" , default = 300000 , type = "int" , help = "Maximum size of patchers to be replaced [default: %default]" ) p . add_option ... | %prog install patchers . bed patchers . fasta backbone . fasta alt . fasta |
11,631 | def refine ( args ) : p = OptionParser ( refine . __doc__ ) p . add_option ( "--closest" , default = False , action = "store_true" , help = "In case of no gaps, use closest [default: %default]" ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) breakpointsbed , gapsbed ... | %prog refine breakpoints . bed gaps . bed |
11,632 | def patcher ( args ) : from jcvi . formats . bed import uniq p = OptionParser ( patcher . __doc__ ) p . add_option ( "--backbone" , default = "OM" , help = "Prefix of the backbone assembly [default: %default]" ) p . add_option ( "--object" , default = "object" , help = "New object name [default: %default]" ) opts , arg... | %prog patcher backbone . bed other . bed |
11,633 | def treds ( args ) : p = OptionParser ( treds . __doc__ ) p . add_option ( "--csv" , default = False , action = "store_true" , help = "Also write `meta.csv`" ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) tredresults , = args df = pd . read_csv ( tredresults , sep =... | %prog treds hli . tred . tsv |
11,634 | def stutter ( args ) : p = OptionParser ( stutter . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) vcf , = args pf = op . basename ( vcf ) . split ( "." ) [ 0 ] execid , sampleid = pf . split ( "_" ) C = "vcftools --remove-filtered-all --min-meanDP 10" C += ... | %prog stutter a . vcf . gz |
11,635 | def filtervcf ( args ) : p = OptionParser ( filtervcf . __doc__ ) p . set_home ( "lobstr" , default = "/mnt/software/lobSTR" ) p . set_aws_opts ( store = "hli-mv-data-science/htang/str" ) p . set_cpus ( ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) samples , = args... | %prog filtervcf NA12878 . hg38 . vcf . gz |
11,636 | def meta ( args ) : p = OptionParser ( meta . __doc__ ) p . add_option ( "--cutoff" , default = .5 , type = "float" , help = "Percent observed required (chrY half cutoff)" ) p . set_cpus ( ) opts , args = p . parse_args ( args ) if len ( args ) != 4 : sys . exit ( not p . print_help ( ) ) binfile , sampleids , strids ,... | %prog meta data . bin samples STR . ids STR - exons . wo . bed |
11,637 | def bin ( args ) : p = OptionParser ( bin . __doc__ ) p . add_option ( "--dtype" , choices = ( "float32" , "int32" ) , help = "dtype of the matrix" ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) tsvfile , = args dtype = opts . dtype if dtype is None : dtype = np . i... | %prog bin data . tsv |
11,638 | def data ( args ) : p = OptionParser ( data . __doc__ ) p . add_option ( "--notsv" , default = False , action = "store_true" , help = "Do not write data.tsv" ) opts , args = p . parse_args ( args ) if len ( args ) != 4 : sys . exit ( not p . print_help ( ) ) databin , sampleids , strids , metafile = args final_columns ... | %prog data data . bin samples . ids STR . ids meta . tsv |
11,639 | def mask ( args ) : p = OptionParser ( mask . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) not in ( 2 , 4 ) : sys . exit ( not p . print_help ( ) ) if len ( args ) == 4 : databin , sampleids , strids , metafile = args df , m , samples , loci = read_binfile ( databin , sampleids , strids ) mode = "STR... | %prog mask data . bin samples . ids STR . ids meta . tsv |
11,640 | def compilevcf ( args ) : p = OptionParser ( compilevcf . __doc__ ) p . add_option ( "--db" , default = "hg38" , help = "Use these lobSTR db" ) p . add_option ( "--nofilter" , default = False , action = "store_true" , help = "Do not filter the variants" ) p . set_home ( "lobstr" ) p . set_cpus ( ) p . set_aws_opts ( st... | %prog compilevcf samples . csv |
11,641 | def ystr ( args ) : from jcvi . utils . table import write_csv p = OptionParser ( ystr . __doc__ ) p . set_home ( "lobstr" ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) vcffile , = args si = STRFile ( opts . lobstr_home , db = "hg38-named" ) register = si . registe... | %prog ystr chrY . vcf |
11,642 | def liftover ( args ) : p = OptionParser ( liftover . __doc__ ) p . add_option ( "--checkvalid" , default = False , action = "store_true" , help = "Check minscore, period and length" ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) refbed , fastafile = args genome = p... | %prog liftover lobstr_v3 . 0 . 2_hg38_ref . bed hg38 . upper . fa |
11,643 | def trf ( args ) : from jcvi . apps . base import iglob cparams = "1 1 2 80 5 200 2000" p = OptionParser ( trf . __doc__ ) p . add_option ( "--mismatch" , default = 31 , type = "int" , help = "Mismatch and gap penalty" ) p . add_option ( "--minscore" , default = MINSCORE , type = "int" , help = "Minimum score to report... | %prog trf outdir |
11,644 | def batchlobstr ( args ) : p = OptionParser ( batchlobstr . __doc__ ) p . add_option ( "--sep" , default = "," , help = "Separator for building commandline" ) p . set_home ( "lobstr" , default = "s3://hli-mv-data-science/htang/str-build/lobSTR/" ) p . set_aws_opts ( store = "hli-mv-data-science/htang/str-data" ) opts ,... | %prog batchlobstr samples . csv |
11,645 | def locus ( args ) : from jcvi . formats . sam import get_minibam INCLUDE = [ "HD" , "SBMA" , "SCA1" , "SCA2" , "SCA8" , "SCA17" , "DM1" , "DM2" , "FXTAS" ] db_choices = ( "hg38" , "hg19" ) p = OptionParser ( locus . __doc__ ) p . add_option ( "--tred" , choices = INCLUDE , help = "TRED name" ) p . add_option ( "--ref"... | %prog locus bamfile |
11,646 | def lobstrindex ( args ) : p = OptionParser ( lobstrindex . __doc__ ) p . add_option ( "--notreds" , default = False , action = "store_true" , help = "Remove TREDs from the bed file" ) p . set_home ( "lobstr" ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) trfbed , f... | %prog lobstrindex hg38 . trf . bed hg38 . upper . fa |
11,647 | def agp ( args ) : p = OptionParser ( agp . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) evidencefile , contigs = args ef = EvidenceFile ( evidencefile , contigs ) agpfile = evidencefile . replace ( ".evidence" , ".agp" ) ef . write_agp ( agpfile ) | %prog agp evidencefile contigs . fasta |
11,648 | def spades ( args ) : from jcvi . formats . fastq import readlen p = OptionParser ( spades . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) == 0 : sys . exit ( not p . print_help ( ) ) folder , = args for p , pf in iter_project ( folder ) : rl = readlen ( [ p [ 0 ] , "--silent" ] ) kmers = None if rl >... | %prog spades folder |
11,649 | def contamination ( args ) : from jcvi . apps . bowtie import align p = OptionParser ( contamination . __doc__ ) p . add_option ( "--mapped" , default = False , action = "store_true" , help = "Retain contaminated reads instead [default: %default]" ) p . set_cutoff ( cutoff = 800 ) p . set_mateorientation ( mateorientat... | %prog contamination folder Ecoli . fasta |
11,650 | def pairs ( args ) : p = OptionParser ( pairs . __doc__ ) p . set_firstN ( ) p . set_mates ( ) p . set_aligner ( ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) cwd = os . getcwd ( ) aligner = opts . aligner work = "-" . join ( ( "pairs" , aligner ) ) mkdir ( work ) ... | %prog pairs folder reference . fasta |
11,651 | def allpaths ( args ) : p = OptionParser ( allpaths . __doc__ ) p . add_option ( "--ploidy" , default = "1" , choices = ( "1" , "2" ) , help = "Ploidy [default: %default]" ) opts , args = p . parse_args ( args ) if len ( args ) == 0 : sys . exit ( not p . print_help ( ) ) folders = args for pf in folders : if not op . ... | %prog allpaths folder1 folder2 ... |
11,652 | def prepare ( args ) : p = OptionParser ( prepare . __doc__ ) p . add_option ( "--first" , default = 0 , type = "int" , help = "Use only first N reads [default: %default]" ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) jfile , = args metafile = jfile + ".meta" if ne... | %prog prepare jira . txt |
11,653 | def assemble_pairs ( p , pf , tag , target = [ "final.contigs.fasta" ] ) : slink ( p , pf , tag ) assemble_dir ( pf , target ) | Take one pair of reads and assemble to contigs . fasta . |
11,654 | def soap_trios ( p , pf , tag , extra ) : from jcvi . assembly . soap import prepare logging . debug ( "Work on {0} ({1})" . format ( pf , ',' . join ( p ) ) ) asm = "{0}.closed.scafSeq" . format ( pf ) if not need_update ( p , asm ) : logging . debug ( "Assembly found: {0}. Skipped." . format ( asm ) ) return slink ( ... | Take one pair of reads and widow reads after correction and run SOAP . |
11,655 | def correctX ( args ) : p = OptionParser ( correctX . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) folder , tag = args tag = tag . split ( "," ) for p , pf in iter_project ( folder ) : correct_pairs ( p , pf , tag ) | %prog correctX folder tag |
11,656 | def allpathsX ( args ) : p = OptionParser ( allpathsX . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) folder , tag = args tag = tag . split ( "," ) for p , pf in iter_project ( folder ) : assemble_pairs ( p , pf , tag ) | %prog allpathsX folder tag |
11,657 | def stats ( args ) : p = OptionParser ( stats . __doc__ ) p . set_outfile ( ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) folder , = args statsfiles = iglob ( folder , "*.stats" ) after_equal = lambda x : x . split ( "=" ) [ - 1 ] header = "Library Assembled_reads ... | %prog stats folder |
11,658 | def stack ( S ) : S , nreps = zip ( * S ) S = np . array ( [ list ( x ) for x in S ] ) rows , cols = S . shape counts = [ ] for c in xrange ( cols ) : freq = [ 0 ] * NBASES for b , nrep in zip ( S [ : , c ] , nreps ) : freq [ BASES . index ( b ) ] += nrep counts . append ( freq ) return counts | From list of bases at a site D make counts of bases |
11,659 | def get_left_right ( seq ) : cseq = seq . strip ( GAPS ) leftjust = seq . index ( cseq [ 0 ] ) rightjust = seq . rindex ( cseq [ - 1 ] ) return leftjust , rightjust | Find position of the first and last base |
11,660 | def cons ( f , mindepth ) : C = ClustFile ( f ) for data in C : names , seqs , nreps = zip ( * data ) total_nreps = sum ( nreps ) if total_nreps < mindepth : continue S = [ ] for name , seq , nrep in data : S . append ( [ seq , nrep ] ) res = stack ( S ) yield [ x [ : 4 ] for x in res if sum ( x [ : 4 ] ) >= mindepth ] | Makes a list of lists of reads at each site |
11,661 | def estimateHE ( args ) : p = OptionParser ( estimateHE . __doc__ ) add_consensus_options ( p ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) clustSfile , = args HEfile = clustSfile . rsplit ( "." , 1 ) [ 0 ] + ".HE" if not need_update ( clustSfile , HEfile ) : loggi... | %prog estimateHE clustSfile |
11,662 | def alignfast ( names , seqs ) : matfile = op . join ( datadir , "blosum80.mat" ) cmd = "poa -read_fasta - -pir stdout {0} -tolower -silent -hb -fuse_all" . format ( matfile ) p = Popen ( cmd , shell = True , stdin = PIPE , stdout = PIPE , stderr = STDOUT , close_fds = True ) s = "" for i , j in zip ( names , seqs ) : ... | Performs MUSCLE alignments on cluster and returns output as string |
11,663 | def cluster ( args ) : p = OptionParser ( cluster . __doc__ ) add_consensus_options ( p ) p . set_align ( pctid = 95 ) p . set_outdir ( ) p . set_cpus ( ) opts , args = p . parse_args ( args ) if len ( args ) < 2 : sys . exit ( not p . print_help ( ) ) prefix = args [ 0 ] fastqfiles = args [ 1 : ] cpus = opts . cpus pc... | %prog cluster prefix fastqfiles |
11,664 | def align ( args ) : p = OptionParser ( align . __doc__ ) p . set_cpus ( ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) clustfile , = args parallel_musclewrap ( clustfile , opts . cpus ) | %prog align clustfile |
11,665 | def discrete_rainbow ( N = 7 , cmap = cm . Set1 , usepreset = True , shuffle = False , plot = False ) : import random from scipy import interpolate if usepreset : if 0 < N <= 5 : cmap = cm . gist_rainbow elif N <= 20 : cmap = cm . Set1 else : sys . exit ( discrete_rainbow . __doc__ ) cdict = cmap . _segmentdata . copy ... | Return a discrete colormap and the set of colors . |
11,666 | def write_messages ( ax , messages ) : tc = "gray" axt = ax . transAxes yy = .95 for msg in messages : ax . text ( .95 , yy , msg , color = tc , transform = axt , ha = "right" ) yy -= .05 | Write text on canvas usually on the top right corner . |
11,667 | def quickplot ( data , xmin , xmax , xlabel , title , ylabel = "Counts" , figname = "plot.pdf" , counts = True , print_stats = True ) : plt . figure ( 1 , ( 6 , 6 ) ) left , height = zip ( * sorted ( data . items ( ) ) ) pad = max ( height ) * .01 if counts : for l , h in zip ( left , height ) : if xmax and l > xmax : ... | Simple plotting function - given a dictionary of data produce a bar plot with the counts shown on the plot . |
11,668 | def get_name_parts ( au ) : parts = au . split ( ) first = parts [ 0 ] middle = [ x for x in parts if x [ - 1 ] == '.' ] middle = "" . join ( middle ) last = [ x for x in parts [ 1 : ] if x [ - 1 ] != '.' ] last = " " . join ( last ) initials = "{0}.{1}" . format ( first [ 0 ] , middle ) if first [ - 1 ] == '.' : middl... | Fares Z . Najar = > last first initials |
11,669 | def names ( args ) : p = OptionParser ( names . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( p . print_help ( ) ) namelist , templatefile = args if open ( namelist ) . read ( ) [ 0 ] == '[' : out = parse_names ( namelist ) make_template ( templatefile , out ) return reader = csv .... | %prog names namelist templatefile |
11,670 | def main ( ) : p = OptionParser ( main . __doc__ ) p . add_option ( "-g" , "--graphic" , default = False , action = "store_true" , help = "Create boilerplate for a graphic script" ) opts , args = p . parse_args ( ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) script , = args imports = graphic_imports if... | %prog scriptname . py |
11,671 | def unpack_ambiguous ( s ) : sd = [ ambiguous_dna_values [ x ] for x in s ] return [ "" . join ( x ) for x in list ( product ( * sd ) ) ] | List sequences with ambiguous characters in all possibilities . |
11,672 | def split ( args ) : p = OptionParser ( split . __doc__ ) p . set_outdir ( outdir = "deconv" ) p . add_option ( "--nocheckprefix" , default = False , action = "store_true" , help = "Don't check shared prefix [default: %default]" ) p . add_option ( "--paired" , default = False , action = "store_true" , help = "Paired-en... | %prog split barcodefile fastqfile1 .. |
11,673 | def merge ( args ) : p = OptionParser ( merge . __doc__ ) p . set_outdir ( outdir = "outdir" ) opts , args = p . parse_args ( args ) if len ( args ) < 1 : sys . exit ( not p . print_help ( ) ) folders = args outdir = opts . outdir mkdir ( outdir ) files = flatten ( glob ( "{0}/*.*.fastq" . format ( x ) ) for x in folde... | %prog merge folder1 ... |
11,674 | def expand_alleles ( p , tolerance = 0 ) : _p = set ( ) for x in p : _p |= set ( range ( x - tolerance , x + tolerance + 1 ) ) return _p | Returns expanded allele set given the tolerance . |
11,675 | def get_progenies ( p1 , p2 , x_linked = False , tolerance = 0 ) : _p1 = expand_alleles ( p1 , tolerance = tolerance ) _p2 = expand_alleles ( p2 , tolerance = tolerance ) possible_progenies = set ( tuple ( sorted ( x ) ) for x in product ( _p1 , _p2 ) ) if x_linked : possible_progenies |= set ( ( x , x ) for x in ( set... | Returns possible progenies in a trio . |
11,676 | def mendelian_errors2 ( args ) : p = OptionParser ( mendelian_errors2 . __doc__ ) opts , args , iopts = p . set_image_options ( args , figsize = "7x7" , format = "png" ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) csvfile , = args fig , ax = plt . subplots ( ncols = 1 , nrows = 1 , figsize = ( iopts . ... | %prog mendelian_errors2 Trios . summary . csv |
11,677 | def mendelian_check ( tp1 , tp2 , tpp , is_xlinked = False ) : call_to_ints = lambda x : tuple ( int ( _ ) for _ in x . split ( "|" ) if _ != "." ) tp1_sex , tp1_call = tp1 [ : 2 ] tp2_sex , tp2_call = tp2 [ : 2 ] tpp_sex , tpp_call = tpp [ : 2 ] tp1_call = call_to_ints ( tp1_call ) tp2_call = call_to_ints ( tp2_call )... | Compare TRED calls for Parent1 Parent2 and Proband . |
11,678 | def in_region ( rname , rstart , target_chr , target_start , target_end ) : return ( rname == target_chr ) and ( target_start <= rstart <= target_end ) | Quick check if a point is within the target region . |
11,679 | def mendelian_errors ( args ) : p = OptionParser ( mendelian_errors . __doc__ ) opts , args , iopts = p . set_image_options ( args , figsize = "6x6" ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) csvfile , = args fig , ax = plt . subplots ( ncols = 1 , nrows = 1 , figsize = ( iopts . w , iopts . h ) ) r... | %prog mendelian_errors STR - Mendelian - errors . csv |
11,680 | def read_tred_tsv ( tsvfile ) : df = pd . read_csv ( tsvfile , sep = "\t" , index_col = 0 , dtype = { "SampleKey" : str } ) return df | Read the TRED table into a dataframe . |
11,681 | def mendelian ( args ) : p = OptionParser ( mendelian . __doc__ ) p . add_option ( "--tolerance" , default = 0 , type = "int" , help = "Tolernace for differences" ) p . set_verbose ( ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) triosjson , tredtsv = args verbose =... | %prog mendelian trios_candidate . json hli . 20170424 . tred . tsv |
11,682 | def mini ( args ) : p = OptionParser ( mini . __doc__ ) p . add_option ( "--pad" , default = 20000 , type = "int" , help = "Add padding to the STR reigons" ) p . add_option ( "--treds" , default = None , help = "Extract specific treds, use comma to separate" ) p . set_outfile ( ) opts , args = p . parse_args ( args ) i... | %prog mini bamfile minibamfile |
11,683 | def likelihood2 ( args ) : from matplotlib import gridspec p = OptionParser ( likelihood2 . __doc__ ) opts , args , iopts = p . set_image_options ( args , figsize = "10x5" , style = "white" , cmap = "coolwarm" ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) jsonfile , = args fig = plt . figure ( figsize ... | %prog likelihood2 100_20 . json |
11,684 | def likelihood3 ( args ) : from matplotlib import gridspec p = OptionParser ( likelihood3 . __doc__ ) opts , args , iopts = p . set_image_options ( args , figsize = "10x10" , style = "white" , cmap = "coolwarm" ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) jsonfile1 , jsonfile2 = args fig = plt . figur... | %prog likelihood3 140_20 . json 140_70 . json |
11,685 | def allelefreqall ( args ) : p = OptionParser ( allelefreqall . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) reportfile , = args treds , df = read_treds ( reportfile ) treds = sorted ( treds ) count = 6 pdfs = [ ] for page in xrange ( len ( treds ) / count... | %prog allelefreqall HN_Platinum_Gold . 20180525 . tsv . report . txt |
11,686 | def allelefreq ( args ) : p = OptionParser ( allelefreq . __doc__ ) p . add_option ( "--nopanels" , default = False , action = "store_true" , help = "No panel labels A, B, ..." ) p . add_option ( "--usereport" , help = "Use allele frequency in report file" ) opts , args , iopts = p . set_image_options ( args , figsize ... | %prog allelefreq HD DM1 SCA1 SCA17 FXTAS FRAXE |
11,687 | def simulate ( args ) : p = OptionParser ( simulate . __doc__ ) p . add_option ( "--method" , choices = ( "wgsim" , "eagle" ) , default = "eagle" , help = "Read simulator" ) p . add_option ( "--ref" , default = "hg38" , choices = ( "hg38" , "hg19" ) , help = "Reference genome version" ) p . add_option ( "--tred" , defa... | %prog simulate run_dir 1 300 |
11,688 | def batchlobstr ( args ) : p = OptionParser ( batchlobstr . __doc__ ) p . add_option ( "--haploid" , default = "chrY,chrM" , help = "Use haploid model for these chromosomes" ) p . set_cpus ( ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) bamlist , = args cmd = "pyth... | %prog batchlobstr bamlist |
11,689 | def compilevcf ( args ) : from jcvi . variation . str import LobSTRvcf p = OptionParser ( compilevcf . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) folder , = args vcf_files = iglob ( folder , "*.vcf,*.vcf.gz" ) for vcf_file in vcf_files : try : p = LobSTR... | %prog compilevcf dir |
11,690 | def draw_jointplot ( figname , x , y , data = None , kind = "reg" , color = None , xlim = None , ylim = None , format = "pdf" ) : import seaborn as sns sns . set_context ( 'talk' ) plt . clf ( ) register = { "MeanCoverage" : "Sample Mean Coverage" , "HD.FDP" : "Depth of full spanning reads" , "HD.PDP" : "Depth of parti... | Wraps around sns . jointplot |
11,691 | def get_lo_hi_from_CI ( s , exclude = None ) : a , b = s . split ( "|" ) ai , aj = a . split ( "-" ) bi , bj = b . split ( "-" ) los = [ int ( ai ) , int ( bi ) ] his = [ int ( aj ) , int ( bj ) ] if exclude and exclude in los : los . remove ( exclude ) if exclude and exclude in his : his . remove ( exclude ) return ma... | Parse the confidence interval from CI . |
11,692 | def compare ( args ) : p = OptionParser ( compare . __doc__ ) opts , args , iopts = p . set_image_options ( args , figsize = "10x10" ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) datafile , = args pf = datafile . rsplit ( "." , 1 ) [ 0 ] fig , ( ( ax1 , ax2 ) , ( ax3 , ax4 ) ) = plt . subplots ( ncols ... | %prog compare Evaluation . csv |
11,693 | def stem_leaf_plot ( data , vmin , vmax , bins , digit = 1 , title = None ) : assert bins > 0 range = vmax - vmin step = range * 1. / bins if isinstance ( range , int ) : step = int ( ceil ( step ) ) step = step or 1 bins = np . arange ( vmin , vmax + step , step ) hist , bin_edges = np . histogram ( data , bins = bins... | Generate stem and leaf plot given a collection of numbers |
11,694 | def prepare ( args ) : valid_enzymes = "ApeKI|ApoI|BamHI|EcoT22I|HinP1I|HpaII|MseI|MspI|" "NdeI|PasI|PstI|Sau3AI|SbfI|AsiSI-MspI|BssHII-MspI|" "FseI-MspI|PaeR7I-HhaI|PstI-ApeKI|PstI-EcoT22I|PstI-MspI" "PstI-TaqI|SalI-MspI|SbfI-MspI" . split ( "|" ) p = OptionParser ( prepare . __doc__ ) p . add_option ( "--enzyme" , de... | %prog prepare barcode_key . csv reference . fasta |
11,695 | def batch ( args ) : p = OptionParser ( batch . __doc__ ) set_align_options ( p ) p . set_sam_options ( ) opts , args = p . parse_args ( args ) if len ( args ) != 3 : sys . exit ( not p . print_help ( ) ) ref_fasta , proj_dir , outdir = args outdir = outdir . rstrip ( "/" ) s3dir = None if outdir . startswith ( "s3://"... | %proj batch database . fasta project_dir output_dir |
11,696 | def index ( args ) : p = OptionParser ( index . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) dbfile , = args check_index ( dbfile ) | %prog index database . fasta |
11,697 | def samse ( args , opts ) : dbfile , readfile = args dbfile = check_index ( dbfile ) saifile = check_aln ( dbfile , readfile , cpus = opts . cpus ) samfile , _ , unmapped = get_samfile ( readfile , dbfile , bam = opts . bam , unmapped = opts . unmapped ) if not need_update ( ( dbfile , saifile ) , samfile ) : logging .... | %prog samse database . fasta short_read . fastq |
11,698 | def sampe ( args , opts ) : dbfile , read1file , read2file = args dbfile = check_index ( dbfile ) sai1file = check_aln ( dbfile , read1file , cpus = opts . cpus ) sai2file = check_aln ( dbfile , read2file , cpus = opts . cpus ) samfile , _ , unmapped = get_samfile ( read1file , dbfile , bam = opts . bam , unmapped = op... | %prog sampe database . fasta read1 . fq read2 . fq |
11,699 | def bwasw ( args , opts ) : dbfile , readfile = args dbfile = check_index ( dbfile ) samfile , _ , unmapped = get_samfile ( readfile , dbfile , bam = opts . bam , unmapped = opts . unmapped ) if not need_update ( dbfile , samfile ) : logging . error ( "`{0}` exists. `bwa bwasw` already run." . format ( samfile ) ) retu... | %prog bwasw database . fasta long_read . fastq |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.