The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [python]

python is a programming language, widely used in bioinformatics

Filter by
Sorted by
Tagged with
14
votes
1answer
553 views

Biopython Phylogenetic Tree replace branch tip labels by sequence logos

Having recently constructed a lot of phylogenetic trees with the module TreeConstruction from Phylo package from Biopython, I've been asked to replace the branch tip labels by the corresponding ...
13
votes
7answers
3k views

What is the fastest way to get the reverse complement of a DNA sequence in python?

I am writing a python script that requires a reverse complement function to be called on DNA strings of length 1 through around length 30. Line profiling programs indicate that my functions spend a ...
12
votes
3answers
751 views

How can I do an overlapping sequence count in Biopython?

Biopython's .count() methods, like Python's str.count(), perform a non-overlapping count, how can I do an overlapping one? For ...
12
votes
3answers
2k views

How do you write a .gz fastq file with Biopython?

How do you write a .gz (or .bgz) fastq file using ...
10
votes
3answers
3k views

Converting a VCF into a FASTA given a reference with Python, R

I am interested in converting a VCF file into a FASTA file given a reference sequence with Python or R. Samtools/BCFtools (Heng Li) provides a Perl script ...
9
votes
5answers
2k views

How do I find identical sequences in a FASTA file?

I want to create a database for a proteomics study. Therefore, the mapping from a given sequence to a protein ID has to be unique. I am wondering whether there is already a built-in function in ...
9
votes
2answers
1k views

How do you generate read-length vs read-quality plot for long-read sequencing data (e.g., MinION)?

How do you generate read-length vs read-quality plot (heat map with histograms in the margin) for long-read sequencing data from the Oxford Nanopore Technologies (ONT) MinION? The MinKNOW software ...
8
votes
3answers
754 views

Running Snakemake in one single conda env

I have been experimenting a lot lately with Snakemake, I love it. Recently I also switched to using conda (--use-conda) in the way that is advertised. However, I have some issues with it, mostly ...
8
votes
2answers
1k views

Subset FASTA file by species name

I have a problem: I've managed to download a massive fasta file of 1500 sequences, but now I want to split them into seperate fasta files based on the genus. EDIT The fasta file looks like this: <...
8
votes
1answer
494 views

How GFF3 attributes (9th column) varies from one gene prediction algorithm to another

GFF3 files are in tabular format with 9 fields per line, separated by tabs. The first 8 fields share almost same data structure, but the 9th field varies a lot depending on feature type and gene ...
8
votes
1answer
248 views

How to get the count of each kmer past 255 using khmer

I have a Fastq file and I want to get the exact count of each possible kmer from this file. On a previous post called How to use khmer to count k-mers? Daniel Standage proposed a custom script based ...
8
votes
1answer
344 views

Getting protein FASTA sequence based on keyword with python

I would like to gather proteins FASTA sequence from Entrez with python 2.7. I am looking for any proteins that have the keywords: "terminase" and "large" in their name. So far I got this code: ...
7
votes
2answers
335 views

How to write a hash function for canonical kmers?

This question is a follow up from How do kmer counters determine which kmer is 'canonical'?. In that question we learned that kmer counting programs use a 2-bit hash function to internally represent ...
7
votes
1answer
534 views

Convert R RNA-seq data object to a Python object

I have done some work in R and would like to try a Python tool. What is a good way to import the data (and its annotations etc) as a Python object? I am particularly interested in converting a ...
7
votes
2answers
285 views

How to get all PDB homologs from Uniprot (mapping + BLAST)?

I'd like to create a dataset consisting of all sequences which are either present in the PDB, or whose homolog is present in the PDB. In other words, any sequence in the PDB or any sequence related to ...
7
votes
1answer
409 views

Filtering bases based on phred qualities with pysam

Is there a way to filter bases in BAM files based on phred quallities through python's pysam ? I have a code here that Takes the nucleobases per position from a BAM file using pysam's pileup ...
7
votes
1answer
1k views

Extracting the CIGAR string from a BAM via Python?

Is there a standard method in Python to extract a CIGAR string from the BAM? There are great libraries which parse the CIGAR, e.g. https://pypi.python.org/pypi/cigar/0.1 ...
7
votes
2answers
423 views

Is there a standard way to clean a PDB file and re-number its residues?

Is there a pre-existing tool which will tidy up the numbering of a PDB file? Firstly, I would like to re-number the residues on inserts to make the icode an actual residue in the chain (by that I ...
7
votes
1answer
297 views

Reject reads with low quality bases from a Bam file through pysam

I have a code below: ...
6
votes
2answers
266 views

Is there any way of using biopython to write Swissprot files?

I have the following mwe for filtering a Swissprot file based on a certain feature, in this case, transmembrane regions. ...
6
votes
1answer
97 views

Generating random BED intervals given constraints

Problem is to generate a random BED interval given the following constraints: minimum start maximum end fixed length maximum ...
5
votes
2answers
305 views

What does “fetching by region is not available for SAM files” mean?

I am used to gzip/biopython solutions when dealing with sequencing data, but now I wish to switch to more elegant ...
5
votes
2answers
928 views

Way to get genomic sequences at given coordinates without downloading fasta files of whole chromosomes/genomes first?

So I have a list of start and stop positions along chromosomes in different species, and I'd like to get the corresponding DNA sequence for each set of coordinates. In the past, I've just download the ...
5
votes
3answers
270 views

Generating the reconstructed alignment from BAM

I have a (small) BAM file with CIGAR and MD fields. Question 1: What tools exists in Python and/or R to reconstruct the alignment between the reference and the read in a BAM? Given that this is a ...
5
votes
1answer
565 views

Read and write FASTA files with more information than id and sequence

I am trying to read a fasta file, manipulate is in Python (using BioPython) and then write it back. The format of my sequences is like: ...
5
votes
2answers
100 views

Counting letters in phylip alignment columns with Biopython

I have been using python 3.6 and biopython 1.72 to work with protein data files. I am using a protein sequence file (phylip format), for example: ...
5
votes
1answer
240 views

Using pysam with cython: htslib/kstring.h not found

I'm trying to learn to use cython to speed up some code based on pysam. My issue is not strictly speaking about bioinformatics, but rather about building tools using a bioinformatics library. I hope ...
5
votes
2answers
141 views

Is there a Python/R package with the ability to convert an alignment and reference into a CIGAR?

I'm writing a python function from scratch to do this, but I feel like this must exist in some standard bioinformatics library already. In principle, this is a simply regex operation which many must ...
5
votes
1answer
201 views

Why doesn't Biopython AlignIO.read() recognise the 'mauve' format?

On this Biopython tutorial, they describe how to import a multiple sequence alignment in the Mauve (XMFA: extensible multi fasta format). So I imported the AlignIO module: ...
5
votes
1answer
102 views

How to find all variable-length seqs with an exact 5' and 3' match in a FASTA file

Context I am interested in finding all of the promotors specific to a particular sigma factor. I have identified the -35 and -10 sites from the literature, bold denotes -10, -35, binding sites: <...
5
votes
2answers
106 views

How to plot character state changes from a presence-absence matrix on to a phylogeny

I am trying to assign character state changes from a presence-absence matrix to a phylogeny. Thus I want to identify the most parsimonious hypothesis for which node and branch a given "mutation" or "...
5
votes
1answer
98 views

How to convert the given mathematical computation (on biological problem) to mathematical fomula, equation?

I have crossposted this question in maths StackExchange. The problem is dominantly mathematical (this question) but the application of the problem is mainly biological. Hoping that people in this ...
5
votes
1answer
141 views

Evaluate clusters of individuals by using their sequence data

For a dataset of several hundred individuals, I applied a hierarchical clustering to generate clusters based on a functional trait that sets them apart. My task is now to evaluate if these clusters ...
4
votes
5answers
2k views

using python to write bioinformatics pipelines tutorial

I was wondering if there is a tutorial or a small code snippet to understand how to write bioinformatics pipeline using python, for example use a aligner (say hisat) get the output and process it ...
4
votes
3answers
1k views

How can I extract gene names for a metabolic pathway from KEGG?

Note: this question has also been asked on Biostars I need the get the list of gene names involved in glycolysis (to put an example). Not manually, I need to do this in a script. Ideally with Python. ...
4
votes
3answers
514 views

Range overlap python error with genomic regions

I have two files s3.txt : 1 10 20 1 5 20 2 20 30 2 25 30 1 10 50 2 20 60 1 14 17 s4.txt: 1 10 20 2 20 30 I am trying to match col0 ...
4
votes
1answer
963 views

Using Python, how to convert a pandas DataFrame into a VCF?

Let's say I have a pandas dataframe with fields CHROM, POS, ALT, ...
4
votes
1answer
62 views

Cannot install chromosomer

I am trying to install chromosomer but I fail. Can anybody help me, please? ...
4
votes
2answers
57 views

Group genes by functional categories suming expression values

Using the count of rpkm values from genes in a metagenome sample, I want to group these genes into established categories (for example KEGG or COG). For each sample, my goal is to determine which ...
4
votes
2answers
755 views

How to map PDB chains to Uniprot IDs using API services

I have a lot of PDB IDs and I need to get uniprot fasta sequences of these PDB IDs special chains by API services. For example, imagine that I need to get fasta sequence of '1kf6' 'A' chain. The ...
4
votes
1answer
908 views

How to obtain clusters of hierarchical heatmap when using Python?

Is there a good way of obtaining the labels (e.g. genes) within individual clusters that haven been clustered hierarchically in Python (preferentially, but not necessarily, by seaborn)? I found these ...
4
votes
3answers
472 views

How to compare transcriptomic profiles of two cell types (single cell RNA-seq)?

I found this interesting Single RNA-seq data set in GEO, but I am not sure how to analyze it appropriately. They have deposited transcriptomic profiles of human and mouse pancreatic islets (...
4
votes
2answers
359 views

Finding a single open reading frame with ribosomal binding site, using Biopython

I'm given a Fasta file, containing a large DNA(over 115,000 long) sequence, and I am tasked with finding a single large open reading frame contained within the DNA sequence using Biopython. I'm ...
4
votes
2answers
325 views

Is it possible to do alignment within Python? Check variants against reference?

I'm currently adding a few SNPs randomly into a FASTA within python using BioPython. In the following example from BioPython, I add an SNV at location "5" http://biopython.org/DIST/docs/api/Bio.Seq....
4
votes
2answers
3k views

RNAseq: Z score, Intensity, and Resources

I'm very new to bioinformatics in general, and I'm trying to understand some basic concepts. I have RNAseq data, and bioinformatics people tell me that intensities cannot be compared across patients. ...
4
votes
2answers
162 views

Plotting coverage of annotation over collection of region

I'm trying to plot "meta" coverage of annotation: i.e. features (eg. gene class) over certain regions. It is similar to read coverage plots over gene body, except my input is two bed files (both in ...
4
votes
1answer
87 views

python package for NNI neighbors

I am working on protein sequence data files for reconstructing phylogenetic tree and I need to generate all NNI-neighbours of the tree (two trees are NNI-neighbours if one can be transformed into ...
4
votes
1answer
170 views

Finding proteins in a sequence

I have a file with protein sequences, all on a single line, like this: ...
4
votes
1answer
50 views

Make ipyrad use cuda-enabled NVidia card on Ubuntu

I want to use ipyrad on a new Ubuntu machine that has an NVidia Quadro K2000 card with 384 cores. One can configure ipyrad to run on a linux cluster. Do I have any options to get ipyrad to access ...
4
votes
1answer
88 views

replacing SNPs with missing calls with a specific string

I have a big file containing 27 columns and nearly 6 million rows. The following is a little example of my file ...