Connect with us

Bioinformatics Programming

A perl script to convert multiline FASTA sequences into a single line

Dr. Muniba Faiza

Published

on

There are different software or tools which require different kinds of input, especially, when you are trying to developing a pipeline or want to process multiple large files.

If you are dealing with a big FASTA file consisting of thousands of sequences split into a particular number of residues per line, and you want each sequence into a single line, then you can use this simple Perl program.

There are two cases to input your multiline fasta file, either you define the filename in your Perl script or get it through the command line.

1. Define input file within the script

The multifasta input file is “input.fasta”.

#!/usr/bin/perl
use strict;
use warnings;
my $input_fasta = "input.fasta";
open(IN,"<", "input_fasta") || die ("Can't open $input_fasta $!");

my $line = <IN>;
print $line;

while ($line = <IN>)
{
chomp $line;
if ($line=~m/^>/gi) { 

   print "\n",$line,"\n";
}
else { 
print $line; 
}
}

print "\n";

2. As a command-line argument

#!/usr/bin/perl
use strict;
use warnings;
my $input_fasta = $ARGV[0];
open(IN,"<", "$input_fasta") || die ("Can't open $input_fasta $!");

my $line = <IN>;
print $line;

while ($line = <IN>)
{
chomp $line;
if ($line=~m/^>/gi) { 

   print "\n",$line,"\n";
}
else { 
print $line; 
}
}

print "\n";

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

sminalog_analysis.py – A new Python script to fetch top binding affinities from SMINA log file

Dr. Muniba Faiza

Published

on

sminalog_analysis.py – A new Python script to fetch top binding affinities from SMINA log file

In one of our previous posts, we provided a Python script for the virtual screening analysis of Autodock Vina. This script analyzes all log files obtained from docking of multiple ligands to a receptor and provides the binding affinities for top poses from each file. In this article, we are publishing a new Python script for the virtual screening analysis of SMINA [1]. (more…)

Continue Reading

Bioinformatics Programming

Installing Pycharm on Ubuntu (Linux)

Tariq Abdullah

Published

on

Installing pycharm on Ubuntu

Pycharm [1] is an integrated development environment (IDE) for developers. It combines Python developer tools and provides an easy graphical user interface. In this article, we are going to install Pycharm on Ubuntu. (more…)

Continue Reading

Algorithms

vs_Analysis.py: A Python Script to Analyze Virtual Screening Results of Autodock Vina

Dr. Muniba Faiza

Published

on

VS-Analysis: A Python Script to Analyze Virtual Screening Results of Autodock Vina

The output files obtained as a result of virtual screening (VS) using Autodock Vina may be large in number. It is difficult or quite impossible to analyze them manually. Therefore, we are providing a Python script to fetch top results (i.e., compounds showing low binding affinities). (more…)

Continue Reading

LATEST ISSUE

ADVERT