当前位置: 首页>>代码示例>>Python>>正文


Python SearchIO.write方法代码示例

本文整理汇总了Python中Bio.SearchIO.write方法的典型用法代码示例。如果您正苦于以下问题:Python SearchIO.write方法的具体用法?Python SearchIO.write怎么用?Python SearchIO.write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Bio.SearchIO的用法示例。


在下文中一共展示了SearchIO.write方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: read_write_and_compare

# 需要导入模块: from Bio import SearchIO [as 别名]
# 或者: from Bio.SearchIO import write [as 别名]
 def read_write_and_compare(self, source_file, source_format, out_file,
         out_format, **kwargs):
     """Compares read QueryResults after it has been written to a file."""
     source_qresult = SearchIO.read(source_file, source_format, **kwargs)
     SearchIO.write(source_qresult, out_file, out_format, **kwargs)
     out_qresult = SearchIO.read(out_file, out_format, **kwargs)
     self.assertTrue(compare_search_obj(source_qresult, out_qresult))
开发者ID:AllanDaemon,项目名称:biopython,代码行数:9,代码来源:test_SearchIO_write.py

示例2: parse_write_and_compare

# 需要导入模块: from Bio import SearchIO [as 别名]
# 或者: from Bio.SearchIO import write [as 别名]
 def parse_write_and_compare(self, source_file, source_format, out_file, out_format, **kwargs):
     """Compares parsed QueryResults after they have been written to a file."""
     source_qresults = list(SearchIO.parse(source_file, source_format, **kwargs))
     SearchIO.write(source_qresults, out_file, out_format, **kwargs)
     out_qresults = list(SearchIO.parse(out_file, out_format, **kwargs))
     for source, out in zip(source_qresults, out_qresults):
         self.assertTrue(compare_search_obj(source, out))
开发者ID:janusz005,项目名称:biopython,代码行数:9,代码来源:test_SearchIO_write.py

示例3: start_queryResult_generator

# 需要导入模块: from Bio import SearchIO [as 别名]
# 或者: from Bio.SearchIO import write [as 别名]
def start_queryResult_generator(inFile, fDic, work_sheet):
    """ invoking the parse function to return a 'generator' that can allow you 
        to step though the record one QueryResult Object at a time but invoking
        nextQuery = (next)generator on it.This approach can allow you to save 
        on memory. I have found with my current task casting this generator with
        (list) works fine but it is really not called for in this current 
        task of parsing and sorting the records.
    """
    """ http://biopython.org/DIST/docs/api/Bio.SearchIO.BlastIO-module.html"""
    qGenerator = SearchIO.parse(inFile, 'blast-xml')
    max_hits = 0
    query_count = 1
    # Step through all the records in the lump xml data file and write out
    # each separate hit to file. Also write the summary information to the
    # work sheet.
    for query_result in qGenerator:
        print('Processing Query BLAST return ' + str(query_count))
        number_hits = int(len(query_result.hits))
        # Extend header out right if new MAXHITS
        if number_hits > max_hits:
            max_hits = number_hits       
        if number_hits == 0:
            # Construct path plus file name for no hit query
            filename = str(fDic['topDir'] + fDic['noHit'] + 'Query_' 
                           + str(query_count) + '_H_none.xml')
            # Write out any Queries that had to hits to a no Hit subfolder
            SearchIO.write(query_result, filename, 'blast-xml')
            write_qr_to_ws(query_count, query_result, work_sheet)
        else :
            # Now set up a counter of 'hits' in the QueryResult so hit's
            # can be sliced away into their own record cleanly.
            hit_count = 0;
            for hit in query_result.hits:
                total_hsps = len (hit.hsps)
                lowest_eval = hit.hsps[0].evalue
                best_hsp = hit.hsps[0]
                for hsp in hit.hsps:
                    if hsp.evalue < lowest_eval:
                        lowest_eval = hsp.evalue
                        best_hsp = hsp
                filename = str(fDic['topDir'] + outputFileName(query_count, hit, best_hsp))
                SearchIO.write(query_result[hit_count:(hit_count + 1)], filename , 'blast-xml')
                hit_count += 1
            # Write out query_result to worksheet           
            write_qr_to_ws(query_count, query_result, work_sheet)
        query_count += 1
        # break is debugging code
        # if query_count == 20:
        #   break
    build_ws_header(work_sheet, max_hits)
    return qGenerator
开发者ID:Lathian212,项目名称:ME_BLAST_Manipulations,代码行数:53,代码来源:make_single_records_and_Excel.py

示例4: __main__

# 需要导入模块: from Bio import SearchIO [as 别名]
# 或者: from Bio.SearchIO import write [as 别名]
def __main__():


    #Parse Command Line
    parser = argparse.ArgumentParser()


    #- a default argument for the blast file
    parser.add_argument('blast_file', type=str, help="A blast file to process")
    parser.add_argument('-o', type=str, help="A name for the output file")
    args = parser.parse_args()



    blast_data = []
    
    # check for a valid file
    if not os.path.isfile( args.blast_file ):
        sys.exit("\n%s is not a valid file!\n" % args.blast_file)

    else:

        # this sets the output file
        output_file = ""
        if args.o is None:
            output_file = "filtered_blast.txt"
        else:
            output_file = args.o
        
        #
        # Class object for what is being read in is:
        #   http://biopython.org/DIST/docs/api/Bio.SearchIO._model.query.QueryResult-class.html
        #
        num_total_qresults = 0
        num_filtered_qresults = 0
        
        for qresult in SearchIO.parse(args.blast_file, 'blast-text'):

            # if no hits we just keep going
            if len(qresult.hits) == 0:
                continue
            else:
                num_total_qresults += 1
                
                
            hits_in_qresult = sum([len(h) for h in qresult.hits])

            if hits_in_qresult == 1:

                blast_data.append(qresult)

            else:

                num_filtered_qresults += 1
            
            
            # commented out this stuff!
            # this counts the total number of hits loaded for this query
            #num_total_qresults += sum([len(h) for h in qresult.hits])

            #filtered_qresult = filter_max_bitscore(qresult)
                
            #num_filtered_qresults += sum([len(h) for h in filtered_qresult.hits])

            #blast_data.append(filtered_qresult)

            
        #pdb.set_trace()
        print "Filted out %d positions from %d total query results" % (num_filtered_qresults, num_total_qresults)

        output_handle = open(output_file, "w")
        
        count = SearchIO.write(blast_data, output_handle, 'blast-tab') # not working just yet
        print "Wrote out %s blast records to '%s'" % (count,output_file)

        output_handle.close()
开发者ID:mandorodriguez,项目名称:bioinfo,代码行数:78,代码来源:blast_filter.py

示例5:

# 需要导入模块: from Bio import SearchIO [as 别名]
# 或者: from Bio.SearchIO import write [as 别名]
from Bio.Blast.Applications import NcbiblastnCommandline
from Bio import SearchIO


humdb="/mithril/Data/Pacbio/Aligned/151019_proc/blast/humiso_blast"

blastn_cline=NcbiblastnCommandline(query="temp.fasta", db=humdb, gapopen=1, gapextend=2, word_size=9, reward=1, evalue=10, outfmt=5, out="try.xml")

stdout, stderr=blastn_cline()

bres=SearchIO.read("try.xml", 'blast-xml')
SearchIO.write(bres, 'try.tsv', 'blast-tab')

##ok - this was nice, but can't output because blast is pairwise, and I think we actually want a MAF

开发者ID:reworkman,项目名称:hummingbird,代码行数:16,代码来源:blast_pretty.py


注:本文中的Bio.SearchIO.write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。