Pogledajte određenu poruku
Staro 21. 12. 2011.   #5
webarto
expert
Grand Master
 
Avatar webarto
 
Datum učlanjenja: 11.04.2010
Poruke: 998
Hvala: 141
959 "Hvala" u 153 poruka
webarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished road
Default

Primljeni ste

Ja sam napravio glupu grešku što nisam čitao sa pažnjom, a kasnije je bilo kasno pošto je vremenski ograničeno, i unosi idu preko STDIN itd...

MVHL
MRAMALRI

P.S. nema spacea, to je greška kako sam postovao.

PHP kôd:
<?php

$start 
'ATG';
$stop = array('TAA''TAG''TGA');
$DNA '';
$CODE = array();

$file file('codons_testcases/input00.txt');

foreach(
$file as $line)
{
    if(
preg_match('#[ACGT]#'$line)) $DNA $line;
    if(
preg_match('#^[GAVLIMFWPSTCYNQDEKRH]{3}\s#'$line))
    {
        
$line explode(' '$line);
        
$CODE[$line[0]] = $line[1];
    }
}

preg_match_all("#($start)(.*?)(".implode('|'$stop).")#"$DNA$matches);

$DNA $matches[0];

function 
replace_codons($DNA, &$CODE)
{
    
$return NULL;
    
$DNA str_split($DNA3);
    foreach(
$DNA as $value)
    {
        foreach(
$CODE as $codon => $char)
        {
            if(
$value == $codon)
            {
                if(
$char == 'X'$char '';
                
$return .= $char;
            }
        }
    }
    return 
$return;
}

foreach(
$DNA as $string)
{
    echo 
replace_codons($string$CODE);
    echo 
"\n";
}

?>
__________________
Github // LinkedIn // PHP // ZCE // Stackoverflow PHP // Site5 Web Hosting
webarto je offline   Odgovorite uz citat