idx
int64
0
63k
question
stringlengths
61
4.03k
target
stringlengths
6
1.23k
11,700
def link ( args ) : from jcvi . apps . base import mkdir p = OptionParser ( link . __doc__ ) p . add_option ( "--dir" , help = "Place links in a subdirectory [default: %default]" ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) meta , = args d = opts . dir if d : mkdi...
%prog link metafile
11,701
def touch ( args ) : p = OptionParser ( touch . __doc__ ) opts , args = p . parse_args ( args ) fp = sys . stdin for link_name in fp : link_name = link_name . strip ( ) if not op . islink ( link_name ) : continue if not op . exists ( link_name ) : continue source = get_abs_path ( link_name ) lnsf ( source , link_name )
find . - type l | %prog touch
11,702
def cp ( args ) : p = OptionParser ( cp . __doc__ ) fp = sys . stdin for link_name in fp : link_name = link_name . strip ( ) if not op . exists ( link_name ) : continue source = get_abs_path ( link_name ) link_name = op . basename ( link_name ) if not op . exists ( link_name ) : os . symlink ( source , link_name ) logg...
find folder - type l | %prog cp
11,703
def size ( args ) : from jcvi . utils . cbook import human_size p = OptionParser ( size . __doc__ ) fp = sys . stdin results = [ ] for link_name in fp : link_name = link_name . strip ( ) if not op . islink ( link_name ) : continue source = get_abs_path ( link_name ) link_name = op . basename ( link_name ) filesize = op...
find folder - type l | %prog size
11,704
def nucmer ( args ) : p = OptionParser ( nucmer . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 5 : sys . exit ( not p . print_help ( ) ) mapbed , mtrfasta , asmfasta , chr , idx = args idx = int ( idx ) m1 = 1000000 bedfile = "sample.bed" bed = Bed ( ) bed . add ( "\t" . join ( str ( x ) for x in ...
%prog nucmer mappings . bed MTR . fasta assembly . fasta chr1 3
11,705
def validate_term ( term , so = None , method = "verify" ) : if so is None : so = load_GODag ( ) oterm = term if term not in so . valid_names : if "resolve" in method : if "_" in term : tparts = deque ( term . split ( "_" ) ) tparts . pop ( ) if "prefix" in method else tparts . popleft ( ) nterm = "_" . join ( tparts )...
Validate an SO term against so . obo
11,706
def agp ( args ) : p = OptionParser ( agp . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) tablefile , = args fp = open ( tablefile ) for row in fp : atoms = row . split ( ) hr = atoms [ 0 ] scaf = atoms [ 1 ] scaf_start = int ( atoms [ 2 ] ) + 1 scaf_end = ...
%prog agp Siirt_Female_pistachio_23May2017_table . txt
11,707
def traits ( args ) : p = OptionParser ( traits . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) < 1 : sys . exit ( not p . print_help ( ) ) samples = [ ] for folder in args : targets = iglob ( folder , "*-traits.json" ) if not targets : continue filename = targets [ 0 ] js = json . load ( open ( filen...
%prog traits directory
11,708
def regression ( args ) : p = OptionParser ( regression . __doc__ ) opts , args , iopts = p . set_image_options ( args , figsize = "8x8" ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) tsvfile , = args df = pd . read_csv ( tsvfile , sep = "\t" ) chrono = "Chronological age (yr)" pred = "Predicted age (yr...
%prog regression postgenomic - s . tsv
11,709
def composite_correlation ( df , size = ( 12 , 8 ) ) : fig = plt . figure ( 1 , size ) ax1 = plt . subplot2grid ( ( 2 , 2 ) , ( 0 , 0 ) ) ax2 = plt . subplot2grid ( ( 2 , 2 ) , ( 0 , 1 ) ) ax3 = plt . subplot2grid ( ( 2 , 2 ) , ( 1 , 0 ) ) ax4 = plt . subplot2grid ( ( 2 , 2 ) , ( 1 , 1 ) ) chemistry = [ "V1" , "V2" , "...
Plot composite correlation figure
11,710
def correlation ( args ) : p = OptionParser ( correlation . __doc__ ) opts , args , iopts = p . set_image_options ( args , figsize = "12x8" ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) tsvfile , = args df = pd . read_csv ( tsvfile , sep = "\t" ) composite_correlation ( df , size = ( iopts . w , iopts ...
%prog correlation postgenomic - s . tsv
11,711
def extract_twin_values ( triples , traits , gender = None ) : traitValuesAbsent = 0 nanValues = 0 genderSkipped = 0 twinValues = [ ] for a , b , t in triples : if gender is not None and t != gender : genderSkipped += 1 continue if not ( a in traits and b in traits ) : traitValuesAbsent += 1 continue if np . isnan ( tr...
Calculate the heritability of certain traits in triplets .
11,712
def heritability ( args ) : p = OptionParser ( heritability . __doc__ ) opts , args , iopts = p . set_image_options ( args , figsize = "12x18" ) if len ( args ) != 3 : sys . exit ( not p . print_help ( ) ) combined , mz , dz = args def get_pairs ( filename ) : with open ( filename ) as fp : for row in fp : yield row . ...
%prog pg . tsv MZ - twins . csv DZ - twins . csv
11,713
def compile ( args ) : p = OptionParser ( compile . __doc__ ) p . set_outfile ( outfile = "age.tsv" ) opts , args = p . parse_args ( args ) if len ( args ) < 1 : sys . exit ( not p . print_help ( ) ) dfs = [ ] for folder in args : ofolder = os . listdir ( folder ) subdir = [ x for x in ofolder if x . startswith ( "telo...
%prog compile directory
11,714
def simulate_one ( fw , name , size ) : from random import choice seq = Seq ( '' . join ( choice ( 'ACGT' ) for _ in xrange ( size ) ) ) s = SeqRecord ( seq , id = name , description = "Fake sequence" ) SeqIO . write ( [ s ] , fw , "fasta" )
Simulate a random sequence with name and size
11,715
def simulate ( args ) : p = OptionParser ( simulate . __doc__ ) p . set_outfile ( ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) idsfile , = args fp = open ( idsfile ) fw = must_open ( opts . outfile , "w" ) for row in fp : name , size = row . split ( ) size = int (...
%prog simulate idsfile
11,716
def gc ( args ) : p = OptionParser ( gc . __doc__ ) p . add_option ( "--binsize" , default = 500 , type = "int" , help = "Bin size to use" ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) fastafile , = args binsize = opts . binsize allbins = [ ] for name , seq in pars...
%prog gc fastafile
11,717
def trimsplit ( args ) : from jcvi . utils . cbook import SummaryStats p = OptionParser ( trimsplit . __doc__ ) p . add_option ( "--minlength" , default = 1000 , type = "int" , help = "Min length of contigs to keep" ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) fas...
%prog trimsplit fastafile
11,718
def qual ( args ) : from jcvi . formats . sizes import Sizes p = OptionParser ( qual . __doc__ ) p . add_option ( "--qv" , default = 31 , type = "int" , help = "Dummy qv score for extended bases" ) p . set_outfile ( ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) fas...
%prog qual fastafile
11,719
def fromtab ( args ) : p = OptionParser ( fromtab . __doc__ ) p . set_sep ( sep = None ) p . add_option ( "--noheader" , default = False , action = "store_true" , help = "Ignore first line" ) p . add_option ( "--replace" , help = "Replace spaces in name to char [default: %default]" ) opts , args = p . parse_args ( args...
%prog fromtab tabfile fastafile
11,720
def longestorf ( args ) : p = OptionParser ( longestorf . __doc__ ) p . add_option ( "--ids" , action = "store_true" , help = "Generate table with ORF info [default: %default]" ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) fastafile , = args pf = fastafile . rsplit...
%prog longestorf fastafile
11,721
def ispcr ( args ) : from jcvi . utils . iter import grouper p = OptionParser ( ispcr . __doc__ ) p . add_option ( "-r" , dest = "rclip" , default = 1 , type = "int" , help = "pair ID is derived from rstrip N chars [default: %default]" ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . ...
%prog ispcr fastafile
11,722
def parse_fasta ( infile , upper = False ) : try : fp = must_open ( infile ) except : fp = infile fa_iter = ( x [ 1 ] for x in groupby ( fp , lambda row : row [ 0 ] == '>' ) ) for header in fa_iter : header = next ( header ) if header [ 0 ] != '>' : continue header = header . strip ( ) [ 1 : ] seq = "" . join ( s . str...
parse a fasta - formatted file and returns header can be a fasta file that contains multiple records .
11,723
def clean ( args ) : p = OptionParser ( clean . __doc__ ) p . add_option ( "--fancy" , default = False , action = "store_true" , help = "Pretty print the sequence [default: %default]" ) p . add_option ( "--canonical" , default = False , action = "store_true" , help = "Use only acgtnACGTN [default: %default]" ) p . set_...
%prog clean fastafile
11,724
def filter ( args ) : p = OptionParser ( filter . __doc__ ) p . add_option ( "--less" , default = False , action = "store_true" , help = "filter the sizes < certain cutoff [default: >=]" ) p . set_outfile ( ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) fastafile , ...
%prog filter fastafile 100
11,725
def pool ( args ) : from jcvi . formats . base import longest_unique_prefix p = OptionParser ( pool . __doc__ ) p . add_option ( "--sep" , default = "." , help = "Separator between prefix and name" ) p . add_option ( "--sequential" , default = False , action = "store_true" , help = "Add sequential IDs" ) opts , args = ...
%prog pool fastafiles > pool . fasta
11,726
def ids ( args ) : p = OptionParser ( ids . __doc__ ) p . add_option ( "--until" , default = None , help = "Truncate the name and description at words [default: %default]" ) p . add_option ( "--description" , default = False , action = "store_true" , help = "Generate a second column with description [default: %default]...
%prog ids fastafiles
11,727
def sort ( args ) : p = OptionParser ( sort . __doc__ ) p . add_option ( "--sizes" , default = False , action = "store_true" , help = "Sort by decreasing size [default: %default]" ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( p . print_help ( ) ) fastafile , = args sortedfastafile = fastaf...
%prog sort fastafile
11,728
def print_first_difference ( arec , brec , ignore_case = False , ignore_N = False , rc = False , report_match = True ) : plus_match = _print_first_difference ( arec , brec , ignore_case = ignore_case , ignore_N = ignore_N , report_match = report_match ) if rc and not plus_match : logging . debug ( "trying reverse compl...
Returns the first different nucleotide in two sequence comparisons runs both Plus and Minus strand
11,729
def _print_first_difference ( arec , brec , ignore_case = False , ignore_N = False , report_match = True ) : aseq , bseq = arec . seq , brec . seq asize , bsize = len ( aseq ) , len ( bseq ) matched = True for i , ( a , b ) in enumerate ( zip_longest ( aseq , bseq ) ) : if ignore_case and None not in ( a , b ) : a , b ...
Returns the first different nucleotide in two sequence comparisons
11,730
def hash_fasta ( seq , ignore_case = False , ignore_N = False , ignore_stop = False , checksum = "MD5" ) : if ignore_stop : seq = seq . rstrip ( "*" ) if ignore_case : seq = seq . upper ( ) if ignore_N : if not all ( c . upper ( ) in 'ATGCN' for c in seq ) : seq = re . sub ( 'X' , '' , seq ) else : seq = re . sub ( 'N'...
Generates checksum of input sequence element
11,731
def get_qual ( fastafile , suffix = QUALSUFFIX , check = True ) : qualfile1 = fastafile . rsplit ( "." , 1 ) [ 0 ] + suffix qualfile2 = fastafile + suffix if check : if op . exists ( qualfile1 ) : logging . debug ( "qual file `{0}` found" . format ( qualfile1 ) ) return qualfile1 elif op . exists ( qualfile2 ) : loggin...
Check if current folder contains a qual file associated with the fastafile
11,732
def some ( args ) : p = OptionParser ( some . __doc__ ) p . add_option ( "--exclude" , default = False , action = "store_true" , help = "Output sequences not in the list file [default: %default]" ) p . add_option ( "--uniprot" , default = False , action = "store_true" , help = "Header is from uniprot [default: %default...
%prog some fastafile listfile outfastafile
11,733
def fastq ( args ) : from jcvi . formats . fastq import FastqLite p = OptionParser ( fastq . __doc__ ) p . add_option ( "--qv" , type = "int" , help = "Use generic qv value [dafault: %default]" ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) fastafile , = args fastqf...
%prog fastq fastafile
11,734
def pair ( args ) : p = OptionParser ( pair . __doc__ ) p . set_sep ( sep = None , help = "Separator in name to reduce to clone id" + "e.g. GFNQ33242/1 use /, BOT01-2453H.b1 use ." ) p . add_option ( "-m" , dest = "matepairs" , default = False , action = "store_true" , help = "generate .matepairs file [often used for C...
%prog pair fastafile
11,735
def pairinplace ( args ) : from jcvi . utils . iter import pairwise p = OptionParser ( pairinplace . __doc__ ) p . add_option ( "-r" , dest = "rclip" , default = 1 , type = "int" , help = "pair ID is derived from rstrip N chars [default: %default]" ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . ex...
%prog pairinplace bulk . fasta
11,736
def _uniq_rec ( fastafile , seq = False ) : seen = set ( ) for rec in SeqIO . parse ( fastafile , "fasta" ) : name = str ( rec . seq ) if seq else rec . id if name in seen : logging . debug ( "ignore {0}" . format ( rec . id ) ) continue seen . add ( name ) yield rec
Returns unique records
11,737
def uniq ( args ) : p = OptionParser ( uniq . __doc__ ) p . add_option ( "--seq" , default = False , action = "store_true" , help = "Uniqify the sequences [default: %default]" ) p . add_option ( "-t" , "--trimname" , dest = "trimname" , action = "store_true" , default = False , help = "turn on the defline trim to first...
%prog uniq fasta uniq . fasta
11,738
def random ( args ) : from random import sample p = OptionParser ( random . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) fastafile , N = args N = int ( N ) assert N > 0 f = Fasta ( fastafile ) fw = must_open ( "stdout" , "w" ) for key in sample ( f . keys ...
%prog random fasta 100 > random100 . fasta
11,739
def iter_fasta_qual ( fastafile , qualfile , defaultqual = OKQUAL , modify = False ) : from Bio . SeqIO . QualityIO import PairedFastaQualIterator if not qualfile : qualfile = make_qual ( fastafile , score = defaultqual ) rec_iter = PairedFastaQualIterator ( open ( fastafile ) , open ( qualfile ) ) for rec in rec_iter ...
used by trim emits one SeqRecord with quality values in it
11,740
def trim ( args ) : from jcvi . algorithms . maxsum import max_sum p = OptionParser ( trim . __doc__ ) p . add_option ( "-c" , dest = "min_length" , type = "int" , default = 64 , help = "minimum sequence length after trimming" ) p . add_option ( "-s" , dest = "score" , default = QUAL , help = "quality trimming cutoff [...
%prog trim fasta . screen newfasta
11,741
def sequin ( args ) : p = OptionParser ( sequin . __doc__ ) p . add_option ( "--unk" , default = 100 , type = "int" , help = "The size for unknown gaps [default: %default]" ) p . add_option ( "--newid" , default = None , help = "Use this identifier instead [default: %default]" ) p . add_option ( "--chromosome" , defaul...
%prog sequin inputfasta
11,742
def tidy ( args ) : p = OptionParser ( tidy . __doc__ ) p . add_option ( "--gapsize" , dest = "gapsize" , default = 0 , type = "int" , help = "Set all gaps to the same size [default: %default]" ) p . add_option ( "--minlen" , dest = "minlen" , default = 100 , type = "int" , help = "Minimum component size [default: %def...
%prog tidy fastafile
11,743
def gaps ( args ) : from jcvi . formats . sizes import agp from jcvi . formats . agp import mask , build p = OptionParser ( gaps . __doc__ ) p . add_option ( "--split" , default = False , action = "store_true" , help = "Generate .split.fasta [default: %default]" ) p . set_mingap ( default = 100 ) p . set_cpus ( ) opts ...
%prog gaps fastafile
11,744
def scan_sequence ( self , frame , direction ) : orf_start = None for c , index in self . codons ( frame ) : if ( c not in self . stop and ( c in self . start or not self . start ) and orf_start is None ) : orf_start = index elif c in self . stop and orf_start is not None : self . _update_longest ( orf_start , index + ...
Search in one reading frame
11,745
def bed_to_bedpe ( bedfile , bedpefile , pairsbedfile = None , matesfile = None , ca = False , strand = False ) : fp = must_open ( bedfile ) fw = must_open ( bedpefile , "w" ) if pairsbedfile : fwpairs = must_open ( pairsbedfile , "w" ) clones = defaultdict ( list ) for row in fp : b = BedLine ( row ) name = b . accn c...
This converts the bedfile to bedpefile assuming the reads are from CA .
11,746
def posmap ( args ) : p = OptionParser ( posmap . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 3 : sys . exit ( p . print_help ( ) ) frgscffile , fastafile , scf = args cmd = "faOneRecord {0} {1}" . format ( fastafile , scf ) scffastafile = scf + ".fasta" if not op . exists ( scffastafile ) : sh (...
%prog posmap frgscf . sorted scf . fasta scfID
11,747
def update ( self , pbar ) : if pbar . finished : return self . markers [ 0 ] self . curmark = ( self . curmark + 1 ) % len ( self . markers ) return self . markers [ self . curmark ]
Updates the widget to show the next marker or the first marker when finished
11,748
def _format_line ( self ) : 'Joins the widgets and justifies the line' widgets = '' . join ( self . _format_widgets ( ) ) if self . left_justify : return widgets . ljust ( self . term_width ) else : return widgets . rjust ( self . term_width )
Joins the widgets and justifies the line
11,749
def _update_widgets ( self ) : 'Checks all widgets for the time sensitive bit' self . _time_sensitive = any ( getattr ( w , 'TIME_SENSITIVE' , False ) for w in self . widgets )
Checks all widgets for the time sensitive bit
11,750
def prepare ( bedfile ) : pf = bedfile . rsplit ( "." , 1 ) [ 0 ] abedfile = pf + ".a.bed" bbedfile = pf + ".b.bed" fwa = open ( abedfile , "w" ) fwb = open ( bbedfile , "w" ) bed = Bed ( bedfile ) seen = set ( ) for b in bed : accns = b . accn . split ( ";" ) new_accns = [ ] for accn in accns : if ":" in accn : method...
Remove prepended tags in gene names .
11,751
def renumber ( args ) : from jcvi . algorithms . lis import longest_increasing_subsequence from jcvi . utils . grouper import Grouper p = OptionParser ( renumber . __doc__ ) p . set_annot_reformat_opts ( ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) bedfile , = arg...
%prog renumber Mt35 . consolidated . bed > tagged . bed
11,752
def publocus ( args ) : p = OptionParser ( publocus . __doc__ ) p . add_option ( "--locus_tag" , default = "MTR_" , help = "GenBank locus tag [default: %default]" ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) locus_tag = opts . locus_tag index = AutoVivification ( ...
%prog publocus idsfile > idsfiles . publocus
11,753
def augustus ( args ) : from jcvi . formats . gff import Gff p = OptionParser ( augustus . __doc__ ) p . set_outfile ( ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) ingff3 , = args gff = Gff ( ingff3 ) fw = must_open ( opts . outfile , "w" ) seen = defaultdict ( in...
%prog augustus augustus . gff3 > reformatted . gff3
11,754
def tRNAscan ( args ) : from jcvi . formats . gff import sort p = OptionParser ( tRNAscan . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) trnaout , = args gffout = trnaout + ".gff3" fp = open ( trnaout ) fw = open ( gffout , "w" ) next ( fp ) next ( fp ) ro...
%prog tRNAscan all . trna > all . trna . gff3
11,755
def summary ( args ) : p = OptionParser ( summary . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) fastafile , = args f = Fasta ( fastafile , index = False ) halfmaskedseqs = set ( ) allmasked = 0 allbases = 0 cutoff = 50 for key , seq in f . iteritems ( ) :...
%prog summary fastafile
11,756
def find_synteny_region ( query , sbed , data , window , cutoff , colinear = False ) : regions = [ ] ysorted = sorted ( data , key = lambda x : x [ 1 ] ) g = Grouper ( ) a , b = tee ( ysorted ) next ( b , None ) for ia , ib in izip ( a , b ) : pos1 , pos2 = ia [ 1 ] , ib [ 1 ] if pos2 - pos1 < window and sbed [ pos1 ] ...
Get all synteny blocks for a query algorithm is single linkage anchors are a window centered on query
11,757
def get_segments ( ranges , extra , minsegment = 40 ) : from jcvi . utils . range import range_chain , LEFT , RIGHT NUL = 2 selected , score = range_chain ( ranges ) endpoints = [ ( x . start , NUL ) for x in selected ] endpoints += [ ( x [ 0 ] , LEFT ) for x in extra ] endpoints += [ ( x [ 1 ] , RIGHT ) for x in extra...
Given a list of Range perform chaining on the ranges and select a highest scoring subset and cut based on their boundaries . Let s say the projection of the synteny blocks onto one axis look like the following .
11,758
def entropy ( args ) : p = OptionParser ( entropy . __doc__ ) p . add_option ( "--threshold" , default = 0 , type = "int" , help = "Complexity needs to be above" ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) kmc_out , = args fp = open ( kmc_out ) for row in fp : km...
%prog entropy kmc_dump . out
11,759
def bed ( args ) : from jcvi . formats . fasta import rc , parse_fasta p = OptionParser ( bed . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) fastafile , dumpfile = args fp = open ( dumpfile ) KMERS = set ( ) for row in fp : kmer = row . split ( ) [ 0 ] kme...
%prog bed fastafile kmer . dump . txt
11,760
def kmc ( args ) : p = OptionParser ( kmc . __doc__ ) p . add_option ( "-k" , default = 21 , type = "int" , help = "Kmer size" ) p . add_option ( "--ci" , default = 2 , type = "int" , help = "Exclude kmers with less than ci counts" ) p . add_option ( "--cs" , default = 2 , type = "int" , help = "Maximal value of a coun...
%prog kmc folder
11,761
def meryl ( args ) : p = OptionParser ( meryl . __doc__ ) p . add_option ( "-k" , default = 19 , type = "int" , help = "Kmer size" ) p . set_cpus ( ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) folder , = args K = opts . k cpus = opts . cpus mm = MakeManager ( ) fo...
%prog meryl folder
11,762
def model ( args ) : from scipy . stats import binom , poisson p = OptionParser ( model . __doc__ ) p . add_option ( "-k" , default = 23 , type = "int" , help = "Kmer size" ) p . add_option ( "--cov" , default = 50 , type = "int" , help = "Expected coverage" ) opts , args = p . parse_args ( args ) if len ( args ) != 1 ...
%prog model erate
11,763
def logodds ( args ) : from math import log from jcvi . formats . base import DictFile p = OptionParser ( logodds . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) cnt1 , cnt2 = args d = DictFile ( cnt2 ) fp = open ( cnt1 ) for row in fp : scf , c1 = row . sp...
%prog logodds cnt1 cnt2
11,764
def count ( args ) : from bitarray import bitarray p = OptionParser ( count . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) fastafile , jfdb = args K = get_K ( jfdb ) cmd = "jellyfish query {0} -C | cut -d' ' -f 2" . format ( jfdb ) t = must_open ( "tmp" , ...
%prog count fastafile jf . db
11,765
def bincount ( args ) : from bitarray import bitarray from jcvi . formats . sizes import Sizes p = OptionParser ( bincount . __doc__ ) p . add_option ( "-K" , default = 23 , type = "int" , help = "K-mer size [default: %default]" ) p . set_outfile ( ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . ex...
%prog bincount fastafile binfile
11,766
def bin ( args ) : from bitarray import bitarray p = OptionParser ( bin . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) inp , outp = args fp = must_open ( inp ) fw = must_open ( outp , "w" ) a = bitarray ( ) for row in fp : c = row . split ( ) [ - 1 ] a . a...
%prog bin filename filename . bin
11,767
def dump ( args ) : p = OptionParser ( dump . __doc__ ) p . add_option ( "-K" , default = 23 , type = "int" , help = "K-mer size [default: %default]" ) p . set_outfile ( ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) fastafile , = args K = opts . K fw = must_open ( ...
%prog dump fastafile
11,768
def nucmer ( args ) : from itertools import product from jcvi . apps . grid import MakeManager from jcvi . formats . base import split p = OptionParser ( nucmer . __doc__ ) p . add_option ( "--chunks" , type = "int" , help = "Split both query and subject into chunks" ) p . set_params ( prog = "nucmer" , params = "-l 10...
%prog nucmer ref . fasta query . fasta
11,769
def blasr ( args ) : from jcvi . apps . grid import MakeManager from jcvi . utils . iter import grouper p = OptionParser ( blasr . __doc__ ) p . set_cpus ( cpus = 8 ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) reffasta , fofn = args flist = sorted ( [ x . strip ( ...
%prog blasr ref . fasta fofn
11,770
def blat ( args ) : p = OptionParser ( blat . __doc__ ) p . set_align ( pctid = 95 , hitlen = 30 ) p . set_cpus ( ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) reffasta , queryfasta = args blastfile = get_outfile ( reffasta , queryfasta , suffix = "blat" ) run_blat...
%prog blat ref . fasta query . fasta
11,771
def blast ( args ) : task_choices = ( "blastn" , "blastn-short" , "dc-megablast" , "megablast" , "vecscreen" ) p = OptionParser ( blast . __doc__ ) p . set_align ( pctid = 0 , evalue = .01 ) p . add_option ( "--wordsize" , type = "int" , help = "Word size [default: %default]" ) p . add_option ( "--best" , default = 1 ,...
%prog blast ref . fasta query . fasta
11,772
def lastgenome ( args ) : from jcvi . apps . grid import MakeManager p = OptionParser ( lastgenome . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) gA , gB = args mm = MakeManager ( ) bb = lambda x : op . basename ( x ) . rsplit ( "." , 1 ) [ 0 ] gA_pf , gB_...
%prog genome_A . fasta genome_B . fasta
11,773
def last ( args , dbtype = None ) : p = OptionParser ( last . __doc__ ) p . add_option ( "--dbtype" , default = "nucl" , choices = ( "nucl" , "prot" ) , help = "Molecule type of subject database" ) p . add_option ( "--path" , help = "Specify LAST path" ) p . add_option ( "--mask" , default = False , action = "store_tru...
%prog database . fasta query . fasta
11,774
def fillstats ( args ) : from jcvi . utils . cbook import SummaryStats , percentage , thousands p = OptionParser ( fillstats . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) fillfile , = args fp = open ( fillfile ) scaffolds = 0 gaps = [ ] for row in fp : if...
%prog fillstats genome . fill
11,775
def bed ( args ) : p = OptionParser ( bed . __doc__ ) p . set_outfile ( ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) pslfile , = args fw = must_open ( opts . outfile , "w" ) psl = Psl ( pslfile ) for p in psl : print ( p . bed12line , file = fw )
%prog bed pslfile
11,776
def gff ( args ) : p = OptionParser ( gff . __doc__ ) p . add_option ( "--source" , default = "GMAP" , help = "specify GFF source [default: %default]" ) p . add_option ( "--type" , default = "EST_match" , help = "specify GFF feature type [default: %default]" ) p . add_option ( "--suffix" , default = ".match" , help = "...
%prog gff pslfile
11,777
def _isProtein ( self ) : last = self . blockCount - 1 return ( ( self . tEnd == self . tStarts [ last ] + 3 * self . blockSizes [ last ] ) and self . strand == "+" ) or ( ( self . tStart == self . tSize - ( self . tStarts [ last ] + 3 * self . blockSizes [ last ] ) and self . strand == "-" ) )
check if blockSizes and scores are in the protein space or not
11,778
def _milliBad ( self , ismRNA = False ) : sizeMult = self . _sizeMult qAlnSize , tAlnSize = self . qspan * sizeMult , self . tspan alnSize = min ( qAlnSize , tAlnSize ) if alnSize <= 0 : return 0 sizeDiff = qAlnSize - tAlnSize if sizeDiff < 0 : sizeDiff = 0 if ismRNA else - sizeDiff insertFactor = self . qNumInsert if ...
calculate badness in parts per thousand i . e . number of non - identical matches
11,779
def get_prefix ( dir = "../" ) : prefix = glob ( dir + "*.gkpStore" ) [ 0 ] prefix = op . basename ( prefix ) . rsplit ( "." , 1 ) [ 0 ] return prefix
Look for prefix . gkpStore in the upper directory .
11,780
def cnsfix ( args ) : from jcvi . formats . base import read_block p = OptionParser ( cnsfix . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) cnsfixout , = args fp = open ( cnsfixout ) utgs = [ ] saves = [ ] for header , contents in read_block ( fp , "Evalua...
%prog cnsfix consensus - fix . out . FAILED > blacklist . ids
11,781
def error ( args ) : p = OptionParser ( error . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) version , backup_folder = args mkdir ( backup_folder ) fw = open ( "errors.log" , "w" ) seen = set ( ) for g in glob ( "../5-consensus/*.err" ) : if "partitioned" ...
%prog error version backup_folder
11,782
def cut ( args ) : from jcvi . formats . base import SetFile p = OptionParser ( cut . __doc__ ) p . add_option ( "-s" , dest = "shredafter" , default = False , action = "store_true" , help = "Shred fragments after the given fragID [default: %default]" ) p . add_option ( "--notest" , default = False , action = "store_tr...
%prog cut unitigfile fragID
11,783
def shred ( args ) : p = OptionParser ( shred . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) s , = args u = UnitigLayout ( s ) u . shred ( ) u . print_to_file ( inplace = True )
%prog shred unitigfile
11,784
def pull ( args ) : p = OptionParser ( pull . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 3 : sys . exit ( not p . print_help ( ) ) prefix = get_prefix ( ) version , partID , unitigID = args s = "." . join ( args ) cmd = "tigStore" cmd += " -g ../{0}.gkpStore -t ../{0}.tigStore" . format ( prefix...
%prog pull version partID unitigID
11,785
def mtdotplots ( args ) : from jcvi . graphics . dotplot import check_beds , dotplot p = OptionParser ( mtdotplots . __doc__ ) p . set_beds ( ) opts , args , iopts = p . set_image_options ( args , figsize = "16x8" , dpi = 90 ) if len ( args ) != 3 : sys . exit ( not p . print_help ( ) ) a , b , ac = args fig = plt . fi...
%prog mtdotplots Mt3 . 5 Mt4 . 0 medicago . medicago . lifted . 1x1 . anchors
11,786
def oropetium ( args ) : p = OptionParser ( oropetium . __doc__ ) p . add_option ( "--extra" , help = "Extra features in BED format" ) opts , args , iopts = p . set_image_options ( args , figsize = "9x6" ) if len ( args ) != 4 : sys . exit ( not p . print_help ( ) ) datafile , bedfile , slayout , switch = args fig = pl...
%prog oropetium mcscan . out all . bed layout switch . ids
11,787
def amborella ( args ) : p = OptionParser ( amborella . __doc__ ) p . add_option ( "--tree" , help = "Display trees on the bottom of the figure [default: %default]" ) p . add_option ( "--switch" , help = "Rename the seqid with two-column file [default: %default]" ) opts , args , iopts = p . set_image_options ( args , f...
%prog amborella seqids karyotype . layout mcscan . out all . bed synteny . layout
11,788
def annotate ( args ) : from jcvi . formats . agp import AGP , bed , tidy p = OptionParser ( annotate . __doc__ ) p . add_option ( "--minsize" , default = 200 , help = "Smallest component size [default: %default]" ) opts , args = p . parse_args ( args ) if len ( args ) != 3 : sys . exit ( not p . print_help ( ) ) agpfi...
%prog annotate agpfile gaps . linkage . bed assembly . fasta
11,789
def estimate ( args ) : from collections import defaultdict from jcvi . formats . bed import intersectBed_wao from jcvi . formats . posmap import MatesFile p = OptionParser ( estimate . __doc__ ) p . add_option ( "--minlinks" , default = 3 , type = "int" , help = "Minimum number of links to place [default: %default]" )...
%prog estimate gaps . bed all . spans . bed all . mates
11,790
def sizes ( args ) : from jcvi . formats . base import DictFile from jcvi . apps . align import blast p = OptionParser ( sizes . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 3 : sys . exit ( not p . print_help ( ) ) gapsbed , afasta , bfasta = args pf = gapsbed . rsplit ( "." , 1 ) [ 0 ] extbed = ...
%prog sizes gaps . bed a . fasta b . fasta
11,791
def flanks ( args ) : p = OptionParser ( flanks . __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 , fastafile = args Ext = opts ....
%prog flanks gaps . bed fastafile
11,792
def index ( args ) : p = OptionParser ( index . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( p . print_help ( ) ) frgscffile , = args gzfile = frgscffile + ".gz" cmd = "bgzip -c {0}" . format ( frgscffile ) if not op . exists ( gzfile ) : sh ( cmd , outfile = gzfile ) tbifile = gz...
%prog index frgscf . sorted
11,793
def reads ( args ) : p = OptionParser ( reads . __doc__ ) p . add_option ( "-p" , dest = "prefix_length" , default = 4 , type = "int" , help = "group the reads based on the first N chars [default: %default]" ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( p . print_help ( ) ) frgscffile , = ...
%prog reads frgscffile
11,794
def bed ( args ) : p = OptionParser ( bed . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) frgscffile , = args bedfile = frgscffile . rsplit ( "." , 1 ) [ 0 ] + ".bed" fw = open ( bedfile , "w" ) fp = open ( frgscffile ) for row in fp : f = FrgScfLine ( row ...
%prog bed frgscffile
11,795
def dup ( args ) : p = OptionParser ( dup . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( p . print_help ( ) ) frgscffile , = args fp = open ( frgscffile ) data = [ FrgScfLine ( row ) for row in fp ] forward_data = [ x for x in data if x . orientation == '+' ] reverse_data = [ x fo...
%prog dup frgscffile
11,796
def _score ( cluster ) : x , y = zip ( * cluster ) [ : 2 ] return min ( len ( set ( x ) ) , len ( set ( y ) ) )
score of the cluster in this case is the number of non - repetitive matches
11,797
def read_blast ( blast_file , qorder , sorder , is_self = False , ostrip = True ) : filtered_blast = [ ] seen = set ( ) bl = Blast ( blast_file ) for b in bl : query , subject = b . query , b . subject if query == subject : continue if ostrip : query , subject = gene_name ( query ) , gene_name ( subject ) if query not ...
Read the blast and convert name into coordinates
11,798
def add_options ( p , args , dist = 10 ) : p . set_beds ( ) p . add_option ( "--dist" , default = dist , type = "int" , help = "Extent of flanking regions to search [default: %default]" ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) blast_file , anchor_file = args r...
scan and liftover has similar interfaces so share common options returns opts files
11,799
def layout ( args ) : from jcvi . algorithms . ec import GA_setup , GA_run p = OptionParser ( layout . __doc__ ) p . set_beds ( ) p . set_cpus ( cpus = 32 ) opts , args = p . parse_args ( args ) if len ( args ) != 3 : sys . exit ( not p . print_help ( ) ) simplefile , qseqids , sseqids = args qbed , sbed , qorder , sor...
%prog layout query . subject . simple query . seqids subject . seqids