Connect with us

Bioinformatics Programming

How to search for a specific character in a file using Python?

Published

on

python programming

In this article, a simple python script is provided that can be used to search for a specific character in a file.

If you have a file consisting of some information including name, address, email, post, and so on. You want to extract only email addresses present in that file, then use the following script/block of code. Here, this input file is named “employee_info.txt”.

#!/usr/bin/env python


value = ''
str = 'Email ID:'

file = open('employee_info.txt')

result = ''
for line in file:
			if '@' in line:				#looking for specific character
				value = line.splitlines()
				print ("Email ID:", value)
file.close()				

Save this script with .py extension. Suppose, save it as ‘script.py’. Open a terminal on Ubuntu or command prompt on Windows and type:

$ python script.py

If you want to redirect the output to a file, then type:

$ python script.py > output.txt

Dr. Muniba is a Bioinformatician based in New Delhi, India. She has completed her PhD in Bioinformatics from South China University of Technology, Guangzhou, China. She has cutting edge knowledge of bioinformatics tools, algorithms, and drug designing. When she is not reading she is found enjoying with the family. Know more about Muniba

Bioinformatics Programming

How to obtain ligand structures in PDB format from PDB ligand IDs?

Published

on

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…)

Continue Reading

Bioinformatics Programming

How to obtain SMILES of ligands using PDB ligand IDs?

Published

on

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…)

Continue Reading

Bioinformatics Programming

How to get secondary structure of multiple PDB files using DSSP in Python?

Published

on

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 [1]. You need to have DSSP installed on your system. (more…)

Continue Reading

LATEST ISSUE

ADVERT