Bioinformatics ReviewBioinformatics Review
Notification Show More
Font ResizerAa
  •  Home
  • Docking
  • MD Simulation
  • Tools
  • More Topics
    • Softwares
    • Sequence Analysis
    • Algorithms
    • Bioinformatics Programming
    • Bioinformatics Research Updates
    • Drug Discovery
    • Phylogenetics
    • Structural Bioinformatics
    • Editorials
    • Tips & Tricks
    • Bioinformatics News
    • Featured
    • Genomics
    • Bioinformatics Infographics
  • Community
    • BiR-Research Group
    • Community Q&A
    • Ask a question
    • Join Telegram Channel
    • Join Facebook Group
    • Join Reddit Group
    • Subscription Options
    • Become a Patron
    • Write for us
  • About Us
    • About BiR
    • BiR Scope
    • The Team
    • Guidelines for Research Collaboration
    • Feedback
    • Contact Us
    • Recent @ BiR
  • Subscription
  • Account
    • Visit Dashboard
    • Login
Font ResizerAa
Bioinformatics ReviewBioinformatics Review
Search
Have an existing account? Sign In
Follow US
AlgorithmsBioinformatics ProgrammingFasta

How to read fasta sequences from a file using PHP?

Tariq Abdullah
Last updated: October 23, 2024 7:43 pm
Tariq Abdullah
Share
0 Min Read
SHARE

Here is a simple function in PHP to read fasta sequences from a file.

Your multifasta input file is “input.fasta”.

function read_fastas($filename){ 
    $fh = fopen($filename, 'r'); 
    $i= 0 ; 
    $sequences = array(); 
    while($line = fgets($fh)){ 
        $i++; 
        if($i%2==1){ 
            $sequence['header'] = $line; 
        } 
        else{ 
            $sequence['sequence'] = $line; 
            array_push($sequences, $sequence); 
        } 
    } 
    return $sequences; 
}
Share This Article
Facebook Copy Link Print
ByTariq Abdullah
Tariq is founder of Bioinformatics Review and Lead Developer at IQL Technologies. His areas of expertise include algorithm design, phylogenetics, MicroArray, Plant Systematics, and genome data analysis. If you have questions, reach out to him via his homepage.
Leave a Comment

Leave a Reply Cancel reply

You must be logged in to post a comment.

ai tools vs traditional tools in bioinformatics
AI Tools vs Traditional Tools in Bioinformatics- Which one to select?
Algorithms Artificial Intelligence Machine Learning Software Tools
AI vs Physics in Molecular Docking
AI vs Physics in Molecular Docking: Towards Faster and More Accurate Pose Prediction
Artificial Intelligence Drug Discovery Machine Learning
10 years of Bioinformatics Review: From a Blog to a Bioinformatics Knowledge Hub!
Editorial
Starting in Bioinformatics? Do This First!
Starting in Bioinformatics? Do This First!
Tips & Tricks

You Might Also Like

operations on fasta
Bioinformatics ProgrammingFasta

Operations on FASTA files using Perl, PHP, and Bash commands

July 20, 2020
AlgorithmsDatabasesSequence AnalysisSoftwareTools

Simulated sequence alignment software: An alternative to MSA benchmarks

May 20, 2020
Clustering using MCL
Bioinformatics ProgrammingSoftwareTools

How to perform graph-based clustering of peptide/protein sequences using MCL?

June 22, 2020
How to copy & rename files in same directory in Ubuntu (Linux)?
Bioinformatics Programming

How to copy and rename files simultaneously in same directory in Ubuntu (Linux)?

March 13, 2025
Copyright 2024 IQL Technologies
  • Journal
  • Customer Support
  • Contact Us
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Cookie Policy
  • Sitemap
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?

Not a member? Sign Up