Linux ‘sed’ command in Perl programming
When it comes to handling large data files to process, it becomes very difficult to write programs for the beginners, especially when you have to execute another script within one. For this purpose, the Linux operating system offers several advantages for bioinformatics programming such as ‘awk’ and ‘sed’ one-liners, they prove to be of great help!
The sed command is a stream editor that parses and performs basic text transformations on a file or an input stream from a pipeline. sed allows restricting the command to certain lines or characters. It reads text line-by-line, removes trailing newline, and stores them into an empty data buffer known as pattern space, on which the specified commands are executed. It is an amazing utility but the documentation is a bit difficult.
sed OPTIONS... [SCRIPT] [INPUTFILE]
In bioinformatics, sometimes we need to edit large fasta files, which is quite difficult and tedious when done manually. The replacement and deletion commands of sed are most widely used, which can edit more than five thousands of sequences in a few seconds.
sed substitution command:
sed 's/regexp/replacement/g' input > output
or to modify the input file without getting output in another file,
-i option is used:
sed -i input 's/regexp/replacement/g'
It has a vast range of applications in bioinformatics programming such as:
- one can easily edit or modify the fasta headers in a file consisting of a large number of sequences,
- can search for a particular expression present within the sequences,
- can delete text in between the lines, or in terms of bioinformatics, it can easily delete a specific number of residues from specific lines,
- can handle large data files, and so on.
In Perl, sed command can be easily executed using
exec(), system(), qx//, or backticks (``) depending on the need of the program. The similarity between the sed and Perl is that they use similar identifiers and/ characters. For example,
[table id=2 /]
If you want to insert five blank spaces at the beginning of each line, then the following can be used:
$ sed 's/^/ /'
Again, here ‘^’ is used for recognizing the first character in a line in Perl and sed.
How to create a pie chart using Python?
In this article. we are creating a pie chart of the docking score of five different compounds docked with the same protein. (more…)
How to make swarm boxplot?
With the new year, we are going to start with a very simple yet complicated topic (for beginners) in bioinformatics. In this tutorial, we provide a simple code to plot swarm boxplot using matplotlib and seaborn. (more…)
How to obtain ligand structures in PDB format from PDB ligand IDs?
Previously, we provided a similar script to download ligand SMILES from PDB ligand IDs. In this article, we are downloading PDB ligand structures from their corresponding IDs. (more…)
How to obtain SMILES of ligands using PDB ligand IDs?
Fetching SMILE strings for a given number of SDF files of chemical compounds is not such a trivial task. We can quickly obtain them using RDKit or OpenBabel. But what if you don’t have SDF files of ligands in the first place? All you have is Ligand IDs from PDB. If they are a few then you can think of downloading SDF files manually but still, it seems time-consuming, especially when you have multiple compounds to work with. Therefore, we provide a Python script that will read all Ligand IDs and fetch their SDF files, and will finally convert them into SMILE strings. (more…)
How to get secondary structure of multiple PDB files using DSSP in Python?
In this article, we will obtain the secondary structure of multiple PDB files present in a directory using DSSP . You need to have DSSP installed on your system. (more…)
vs_analysis_compound.py: Python script to search for binding affinities based on compound names.
Previously, we have provided the vs_analysis.py script to analyze virtual screening (VS) results obtained from Autodock Vina. In this article, we have provided another script to search for binding affinity associated with a compound. (more…)
How to download files from an FTP server using Python?
In this article, we provide a simple Python script to download files from an FTP server using Python. (more…)
How to convert the PDB file to PSF format?
VMD allows converting PDB to PSF format but sometimes it gives multiple errors. Therefore, in this article, we are going to convert PDB into PSF format using a different method. (more…)
smitostr.py: Python script to convert SMILES to structures.
As mentioned in some of our previous articles, RDKit provides a wide range of functions. In this article, we are using RDKit  to draw a molecular structure using SMILES. (more…)
How to preprocess data for clustering in MATLAB?
Data preprocessing is a foremost and essential step in clustering based on machine learning methods. It removes noise and provides better results. In this article, we are going to discuss the steps involved in data preprocessing using MATLAB . (more…)
How to calculate drug-likeness using RDKit?
RDKit  allows performing multiple functions on chemical compounds. One is the quantitative estimation of drug-likeness also known as QED properties. These properties include molecular weight (MW), octanol-water partition coefficient (ALOGP), number of hydrogen bond donors (HBD), number of hydrogen bond acceptors (HBA), polar surface area (PSA), number of rotatable bonds (ROTB), number of aromatic rings (AROM), structural alerts (ALERTS). (more…)
sdftosmi.py: Convert multiple ligands/compounds in SDF format to SMILES.
You can obtain SMILES of multiple compounds or ligands in an SDF file in one go. Here, we provide a simple Python script to do that. (more…)
tanimoto_similarities_one_vs_all.py – Python script to calculate Tanimoto Similarities of multiple compounds
We previously provided a Python script to calculate the Tanimoto similarities of multiple compounds against each other. In this article, we are providing another Python script to calculate the Tanimoto similarities of one compound with multiple compounds. (more…)
tanimoto_similarities.py: A Python script to calculate Tanimoto similarities of multiple compounds using RDKit.
RDKit  is a very nice cheminformatics software. It allows us to perform a wide range of operations on chemical compounds/ ligands. We have provided a Python script to perform fingerprinting using Tanimoto similarity on multiple compounds using RDKit. (more…)
How to commit changes to GitHub repository using vs code?
In this article, we are providing a few commands that are used to commit changes to GitHub repositories using VS code terminal.
Extracting first and last residue from helix file in DSSP format.
Previously, we have provided a tutorial on using dssp_parser to extract all helices including long and short separately. Now, we have provided a new python script to find the first and last residue in each helix file. (more…)
How to extract x,y,z coordinates of atoms from PDB file?
The x, y, and z coordinates of atoms are provided in the PDB file. One way to extract them is by using the Biopython package . In this article, we will extract coordinates of C-alpha atoms for each residue from the PDB file using Biopython. (more…)
dssp_parser: A new Python package to extract helices from DSSP files.
A new Python package named ‘dssp_parser‘ is developed to parse DSSP files. This package fetches all helices including long and short ones from DSSP files. (more…)
How to calculate center of mass of a protein structure using Python script?
Here is a Python script that helps you calculate the center of mass of a protein using the Pymol . (more…)
How to sort binding affinities based on a cutoff using vs_analysis.py script?
Previously, we have provided a Python script (vs_analysis.py) to analyze the virtual screening (VS) results of Autodock Vina. Now, we have updated this script to sort binding affinities based on user inputted cutoff value. (more…)
You must be logged in to post a comment Login