Seqanswers Leaderboard Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • queueing
    Junior Member
    • Mar 2015
    • 4

    automated remote blasting issue

    Hi everyone,

    I'm trying to remotely blast about 70 200-nt sequences using Biopython.
    I've been trying for hours to figure out why the following Python script won't work.
    I can get it to work for a read file that contains just one fasta using SeqIO.read, but when I try to switch to SeqIO.parse, I don't get anything in the .xml save file that I create.
    Any ideas?

    As a side note, if anyone knows the option syntax for excluding organisms from the results (as is possible when using the ncbi website, please let me know).

    Thanks very much for any help.

    Matt

    from Bio.Blast import NCBIWWW
    from Bio import SeqIO
    import tkinter.filedialog as tkfd
    in_file=tkfd.askopenfilename()
    record = SeqIO.parse(in_file, format="fasta")
    out_file = tkfd.asksaveasfilename()
    save_file = open(out_file, "w")
    for rec in record:
    ....print(rec)
    ....result_handle = NCBIWWW.qblast("blastn", "nt", rec.format("fasta"))
    ....save_file.write(result_handle.read())
    ....result_handle.close()
    else:
    ....save_file.close()

    This is the content of the in_file that I'm using as a test file (the line formatting of my file is set at 80 char, which might have been lost below):
    >165613
    TAACTGCAGTGTTTTGTGTCGAGCCTTTTTTGTGCCTTTTTTATAAAGGCATAACGTTATATTTAATTGAAGAGTTTGAT
    TCTGGCTCAGATTGAACGCTAGCGGCATGCTTAACACATGCAAGTCGAACGGCAGCGCGGGGAGCTTGCTCCCTGGCGGC
    GAGTGGCGGACGGGTGAGTAATGCGTAGGAATCTACCTTG
    >165875
    GGGATCTTCGGACCTCGTGCTATAAGATGAGCCTACGTCGGATTAGCTTGTTGGTGGGGTAATGGCCTACCAAGGCGACG
    ATCCGTAGCTGGTCTGAGAGGACGATCAGCCACACTGGGACTGAGACACGGCCCAGACTCCTACGGGAGGCAGCAGTGGG
    GAATATTGGACAATGGGGGAAACCCTGATCCAGCAATGCC
    Last edited by queueing; 04-29-2015, 06:12 AM. Reason: fixed indentation
  • maubp
    Peter (Biopython etc)
    • Jul 2009
    • 1544

    #2
    Species restriction can be down with qblast setting entrez_query (or BLAST+ using -remote) and an Entrez [orgn] query, e.g. http://news.open-bio.org/news/2009/0...nfo-biopython/

    As to your script, try adding a bit more debugging, e.g.

    Code:
        data = result_handle.read()
        print("Got back: %r" % data)
        save_file.write(data)

    Comment

    Latest Articles

    Collapse

    • seqadmin
      Pathogen Surveillance with Advanced Genomic Tools
      by seqadmin




      The COVID-19 pandemic highlighted the need for proactive pathogen surveillance systems. As ongoing threats like avian influenza and newly emerging infections continue to pose risks, researchers are working to improve how quickly and accurately pathogens can be identified and tracked. In a recent SEQanswers webinar, two experts discussed how next-generation sequencing (NGS) and machine learning are shaping efforts to monitor viral variation and trace the origins of infectious...
      03-24-2025, 11:48 AM
    • seqadmin
      New Genomics Tools and Methods Shared at AGBT 2025
      by seqadmin


      This year’s Advances in Genome Biology and Technology (AGBT) General Meeting commemorated the 25th anniversary of the event at its original venue on Marco Island, Florida. While this year’s event didn’t include high-profile musical performances, the industry announcements and cutting-edge research still drew the attention of leading scientists.

      The Headliner
      The biggest announcement was Roche stepping back into the sequencing platform market. In the years since...
      03-03-2025, 01:39 PM

    ad_right_rmr

    Collapse

    News

    Collapse

    Topics Statistics Last Post
    Started by seqadmin, 03-20-2025, 05:03 AM
    0 responses
    41 views
    0 reactions
    Last Post seqadmin  
    Started by seqadmin, 03-19-2025, 07:27 AM
    0 responses
    51 views
    0 reactions
    Last Post seqadmin  
    Started by seqadmin, 03-18-2025, 12:50 PM
    0 responses
    38 views
    0 reactions
    Last Post seqadmin  
    Started by seqadmin, 03-03-2025, 01:15 PM
    0 responses
    193 views
    0 reactions
    Last Post seqadmin  
    Working...