mardi 5 mai 2015

How to add a header to a file thats created by user input

So for my program to run it needs a certain type of file. This file is called a .fasta file. This type of file has a specific type of heading. It looks like this.

>gi|129295|sp|P01013|OVAX_CHICK GENE X PROTEIN (OVALBUMIN-RELATED)

My program gets text input from a user and puts it into a file. The problem that I have is that the file just contains the string from the user. My program can't read in just a string, the file needs to have that header on the first line and the string on the second line. Is there anyway to format a file so that the user input goes onto the second line?

Here is the html and php of when the user's input is changed into a file. So the text in the text box is created into a file but I need that header on the first line! Thanks in advance.

 <input id="BlastSearch" type="text" name="BlastSearch" value='' />

php

<?php
$sequence = $_POST['BlastSearch'];
$file = 'uploads/new.fasta';
$current = $sequence;
file_put_contents($file, $current);
?>

This creates a file with the text on the first line

So basically I need the header on the first line of the file and then the user input on the second line of the file. Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire