Questions tagged [biopython]
Biopython is a set of freely available tools for biological computation written in Python. Please only use this tag for issues relating to the Biopython suite of tools.
1,251
questions
0
votes
0
answers
5
views
Error "StreamModeError: Fasta files must be opened in text mode" in BioPython on a Streamlit App
Please Assist, How can I resolve this Error?
I am building a streamlit app that take uploaded FASTA Files as input and read them.
I am getting the error below when I try to read an uploaded fasta file ...
0
votes
0
answers
4
views
How do I extract neighboring proteins from a .faa file?
I am new to biopython and want to search a protein fasta file and extract the neighborhood of 5 upstream and downstream proteins from an input accession number. Then store the 10 protein sequences in ...
0
votes
0
answers
46
views
How to parse xml file with many xml BLAST outputs pasted into one file one by one Python
How to parse xml file with many xml BLAST outputs pasted into one file one by one Python.
I pasted each blast output into one xml file.
They are seperated with:
<?xml version="1.0"?>
&...
0
votes
0
answers
38
views
Biopython parsing over gff features to extract CDS
Hello I'm trying to extract the coding sequences from a fasta file using a gff file with the help of biopython (https://biopython.org/wiki/GFF_Parsing)
I have tried doing what this tutorial describes ...
0
votes
0
answers
18
views
I can't donwload complete genome of Culex pipiens pallens of the ncbi by API (Entrez): HTTP Error 400: Bad Request
I am trying to download the genbank if possible of the complete genome of Culex pipiens pallens from the ncbi but I get this error.
The URL of de ncbi.
In the db variable that I sent in the fetch I ...
-2
votes
1
answer
18
views
Calculate the mean of amino acids sequences biopython
I have this code for calculating the length of sequences in fasta format using BioPython. I got the lenghts.
NP_418305.1
349
NP_418306.1
469
NP_418308.1
236
However, now I'd like to calcule the mean ...
1
vote
1
answer
26
views
Can Biopython Entrez pull full Pubmed articles from a list of PMIDs?
I've been reading documentation and testing Entrez functions for the last 2 days, and I have it working so that it pulls Abstracts just fine from PMIDs.
But I can't find a clear yes/no answer on if ...
-1
votes
0
answers
58
views
Extract ID from multiple fasta file and save in seperate text file with existing name using python
I am having multiple fasta file with extension .fna, I want to extract Id only and save in multiple text file respectively, how it can be done using python, File look like this, image is attached ...
1
vote
1
answer
28
views
NotXMLError: Failed to parse the XML data
I'm trying to use the Entrez module from Biopython to retrive full text articles from PubMed Central. This is my code to do the same.
import urllib3
import json
import requests
from Bio import Entrez
...
-1
votes
1
answer
22
views
Get modification time of a uniprot sequence using biopython?
Can I access the last modification date of protein sequence using biopython?
Thanks.
Petro.
1
vote
1
answer
23
views
How are paths meant to be denoted on for Biopython on mac?
I am trying to run a basic biopython script to rename sequences within a fasta file. I have only ever ran this on a server; i am trying to do it on my macbook but I can't work out what the correct ...
0
votes
1
answer
22
views
Read uploaded fasta file in django using Bio library
in index.html I used
<input type="file" name="upload_file">
in views.py
from Bio import SeqIO
def index(request):
if request.method == "POST":
try:
...
0
votes
1
answer
56
views
Get ID from a FASTA file with Biopython
I am using Biopython to get some information from FASTA file with nucleotide sequences.
However, I'd like to get only the ID and the sequence from this file.
I have this code:
from Bio import SeqIO
...
1
vote
1
answer
17
views
BioPython ValueError: alphabet is None; cannot interpret sequence
So I'm getting this error message when trying to align two SeqRecord objects.
Why is this error happening?
Here is the code (reference_genome is defined earlier in the code)
from Bio import SeqIO
from ...
2
votes
1
answer
36
views
finding CDRs in NGS data
I have millions of sequences in fasta format and want to extract CDRs (CDR1, CDR2 and CDR3).I chose only one sequence as an example and tried to extract CDR1 but not able to extract CDR1.
sequence:-'...
0
votes
1
answer
42
views
Creating a phylogenetic tree with domain annotations using BioPython
I want to create a figure like so:
Example of figure I would like to create
Here is some dummy data and attempt so far to go about this:
import io
import matplotlib.pyplot as plt
from Bio import Phylo
...
0
votes
0
answers
24
views
Biopython SASA looks wrong and disagrees with and Pymol SASA
I'm trying to calculate solvent accessible surface area using Biopython.
However, the values from biopython do not make sense when looking at the crystal model visually in Pymol. Furthermore, when I ...
0
votes
1
answer
21
views
How can I write only a specific elements of the sequences, that I downloaded using Entrez.efetch, to the file (id and sequence itself)
I'm still a beginner at this. I downloaded 20 sequences from NCBI and my task is to align them with themselves, but I need to separate the data, that I got using Entrez.efetch, so I could use it for ...
0
votes
1
answer
43
views
Get ID and protein sequences in biopython
I have this code.
from Bio import SeqIO
for seq_record in SeqIO.parse("aminoacids.txt", "fasta"):
print(seq_record.id)
print(repr(seq_record.seq))
Output:
NP_414584.1
Seq('...
0
votes
0
answers
9
views
picking up headgroups of lipids in each liflet using MDTraj
I am using MDTraj to analyze some trajectory files related to bilayer membranes.
To calculate bilayer distance I want to calculate the average z value of the headgroup atoms of all lipids on the same ...
3
votes
0
answers
56
views
Finding CDRs (sequence) by its definition
I am puzzling to find the CDRs by its definition. Definition is to be matched with the previous and next sequence pattern (known as prefix and suffix respectively) and the CDR is between them. ...
1
vote
3
answers
36
views
Reading a sequence in pairs and increase the base by +1
I want to read a sequence Amino Acid Sequence ("ACDEFGHIKL") in a pair of predefined motif length lets say 3 and print it. output will be [ACD,EFG,HIK]. but next time I want to increase its ...
0
votes
0
answers
26
views
Parsing Specific lines from a pdb file using python
is there a way to parse the BFactor of a protein from its PDB file using Biopython/python?
I am trying with biopython but i am not able to fetch the b factor of the proteins of my interest.
1
vote
4
answers
105
views
find a Pattern Match in string in Python
I am trying to find a amino acid pattern (B-C or M-D, where '-' could be any alphabet other than 'P') in a protein sequence let say 'VATLDSCBACSKVNDNVKNKVKVKNVKMLDHHHV'. Protein sequence in in a fasta ...
2
votes
2
answers
59
views
editing python script file again and again [duplicate]
Hi I want to check the score value of the Amino acid sequence, for which I wrote the following code which works absolutely fine. But the problem is every time I have to edit the file. is there any way ...
1
vote
0
answers
69
views
Phylogenetic Tree in Python
I am new to this stack overflow community. I am a biologist and work on genetics. So far I have been using MEGA software to create Phylogeny tree but MEGA can not handle millions of sequence or NGS ...
0
votes
0
answers
33
views
How I import class module in concurrent.futures ProcessPoolExecutor map?
I try to get sequence alignment score using processpoolexecutor in concurrent.futures module. But I have an error below.
from concurrent.futures import ProcessPoolExecutor
from Bio import Align
def ...
2
votes
4
answers
119
views
Writing Python output as xlsx
I want to execute same function (gives output A, B, C, D) for all the files (library) available in the given path. I am trying write the output (A,B,C,D) in four different columns of a sheet in xlsx. ...
0
votes
1
answer
54
views
Loop through every file with specific format in a directory using sys argv
I'd like to loop through every file in a directory given by the user and apply a specific transformation for every file that ends with ".fastq".
Basically this would be the pipeline:
User ...
0
votes
1
answer
25
views
Missing ',' in line when Biopython reads a nexus tree
I want to edit a tree that I got from BEAST2 treeannotator in nexus-format.
Usually I use the module Phylo from Biopython for such work but Phylo.read(r"filename.tree", "nexus") ...
0
votes
1
answer
30
views
how to replace seqIDs in a fasta file with new seqIDs using biopython
I have a fasta file that reads like so:
>00009c1cc42953fb4702f6331325c7cc
...
0
votes
1
answer
55
views
Import Bio module from Bash
I'm working on a remote server with Linux.
I created a new environment and got biopython installed with conda:
conda create --name new_bio python=3.5
conda activate new_bio
conda install -c conda-...
1
vote
2
answers
31
views
Biopython NcbiblastpCommandline not working: "No such file or directory: 'test.xml"
Trying to do a local blast using NCBIBLAST+, already downloaded in the mentioned path. I am using Win10 and Spyder.
from Bio.Blast.Applications import NcbiblastpCommandline
blastp=r"C:\NCBI\blast-...
0
votes
2
answers
42
views
How to replace characters at specific positions from a file list?
I have a file containing a sequence:
>sequence
TAGGACTGAGGGCTGGACAGGGCTGCGGGAG
and another one containing numbers refering to positions:
3
6
11
I would like to get a new file containing 'N' ...
1
vote
1
answer
107
views
How to renumber residues (start from 1 in continuation among chains) in pdb file in python?
I want to do continuous renumbering a pdb file having multiple chains(A,H,L). Some of the chains have insertion codes attached to the residue position (e.g., 190A etc.). Can anybody help me how to ...
0
votes
2
answers
145
views
I have a fasta file with millions of sequences. I want to only extract those that's names match within a .txt file, how can I go about doing this?
I have been sorting through a ~1.5m read fasta file ('V1_6D_contigs_5kbp.fa') to determine which of the reads are likely to be 'viral' in origin. The reads in this file are denoted as Vx_Cz - where x ...
1
vote
2
answers
40
views
unique clones finding using SeqIO module of biopython
I am working on Next Generation Sequencing (NGS) analysis of DNA. I am using SeqIO Biopython module to parse the DNA libraries in Fasta format. I want to filter the unique clones (unique records) only....
0
votes
1
answer
24
views
newick format: number directly after closed parenthesis?
I have a phylogenetic tree in Newick format. A sample from the full string looks like this:
"...(tet_rpg.hmm_GCA_000638155.1_seq1:0.001565531,tet_rpg.hmm_GCA_000507745.1_seq1:0.001565235)0.000:5e-...
0
votes
1
answer
21
views
Text string using Biopython
I'm using Biopython in my code and i need to extract the abstract out of articles. For searching the article I'm using the function:
def search(query):
Entrez.email = 'your.email@example.com'
handle = ...
0
votes
1
answer
81
views
Get consensus from a MSA fasta file with IUPAC ambiguities in Python
I have an almost similar question to the topic : https://www.biostars.org/p/154993/
I have a fasta file with align sequence and I want to generate a consensus by using IUPAC code.
So far I wrote :
...
0
votes
0
answers
65
views
Splitting several PDB files into chains and save as separate files
I am trying to split a large number of pdb files using Biopython and then save them as separate files called pdbid_chain.pdb . So far I did not succeed. Additionally, I am quite new to python.
Any ...
0
votes
0
answers
14
views
How can I visualize a tree object returned from Bio.Cluster.treecluster()?
How can I visualize a tree object returned from Bio.Cluster.treecluster()?
Hi, I want to visualize a tree calculated by a distance matrix. I use the method:
tree = treecluster(data=None, mask=None, ...
1
vote
1
answer
32
views
Is there a way to fix this error code with DeepVirFinder?
I will try to be as much help as I can, but this is certainly a bit out of my depth.
I am trying to run the metagenomics package 'DeepVirFinder' on my fasta file 'my_seqs.fa' within terminal on my Mac....
0
votes
0
answers
24
views
How to blastp with fasta file that contains ~50 sequences
I'm trying to blastp multiple aminoacids sequences using biopython. I just can't seem to get it right and i cant figure out the handbook for how to do this. I have come up with the following:
open(&...
1
vote
4
answers
97
views
How to optimize code for a file with 72 million entries?
I have asked a question on another platform (here) - it would be great to get your input in order to make my Python code run in a very short time. Currently, it has been taking more than 3 hours for a ...
1
vote
1
answer
52
views
Variables not being reassigned in Loop
Both degeneracy1 and protein_ls are not being reassigned in the nested while loops I am using, I can't figure out why this. This program is designed to find the best protein motif to create an oligo ...
1
vote
2
answers
71
views
translate DNA sequences to protein sequences within a pandas dataframe
I have a pandas dataframe that contains DNA sequences and gene names. I want to translate the DNA sequences into protein sequences, and store the protein sequences in a new column.
The data frame ...
0
votes
2
answers
84
views
How to insert sequence at specific position?
I would like to insert a specific sequence at a defined position in a FASTA formatted file for multiple sequences, where the modified sequences would be output in a single file.
I have tried the ...
0
votes
1
answer
31
views
Biopython(SeqIO) 'FileNotFoundError'
I am new to BioPython and am trying to use several modules.
However, as you can see, in the process of using files such as Genbank or FASTA, such an error appears in the next module.
Can I ask how to ...
0
votes
1
answer
17
views
Simply queries in pandas give different results
I am doing simply queries on a csv document about a genome. I have the following code:
locus_example = 'Rv0001'
for locus in tuberculosis_data1["Locus"].values:
if locus_example.rfind(...