<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>
<font style="font-size: 12pt;" face="Arial" size="3">Nossa, aqui virou uma arena de ideias, da para aprender muita coisa so lendo.</font><font style="font-size: 12pt;" face="Arial" size="3"><br></font><font style="font-size: 12pt;" face="Arial" size="3"><br></font><font style="font-size: 12pt;" face="Arial" size="3">O problema é o seguinte, eu tenho uma lista nesse formato:</font><font style="font-size: 12pt;" face="Arial" size="3"><br></font><font style="font-size: 12pt;" face="Arial" size="3"><br></font><font style="font-size: 8pt;" size="1">target: 01010101</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">length: 581</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">miRNA : hsa-miR-15a</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">length: 22</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">mfe: -24.4 kcal/mol</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">p-value: 0.334111</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">position  244</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">target 5' C    UCUCCUGUGGUCUCU     G           U 3'</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">           CACA               GACCA    GUGCUGUU    </font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">           GUGU               UUGGU    CACGACGA    </font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">miRNA  3'                          AAUA        U 5'</font><font style="font-size: 12pt;" face="Arial" size="3"><br></font><font style="font-size: 12pt;" face="Arial" size="3"><br></font><font style="font-size: 12pt;" face="Arial" size="3"><br></font><font style="font-size: 12pt;" face="Arial" size="3">Conforme este arquivo http://pastebin.com/9v6WFUT7</font><font style="font-size: 12pt;" face="Arial" size="3"><br></font><font style="font-size: 12pt;" face="Arial" size="3"><br></font><font style="font-size: 12pt;" face="Arial" size="3">Eu quero filtrar essa lista de acordo com o valor de mfe.</font><font style="font-size: 12pt;" face="Arial" size="3"><br></font><font style="font-size: 12pt;" face="Arial" size="3"><br></font><font style="font-size: 12pt;" face="Arial" size="3">Exemplo, se mfe for menor que -30 e maior que -20 esta dentro.</font><font style="font-size: 12pt;" face="Arial" size="3"><br></font><font style="font-size: 12pt;" face="Arial" size="3"><br></font><font style="font-size: 12pt;" face="Arial" size="3">Logo fiz da seguinte forma: http://pastebin.com/Dnhv0Zya</font><font style="font-size: 12pt;" face="Arial" size="3"><br></font><font style="font-size: 12pt;" face="Arial" size="3"><br></font><font style="font-size: 12pt;" face="Arial" size="3">Funcionou, o problema era sono. Não percebi que a regex estava pegando um espaço.</font><font style="font-size: 12pt;" face="Arial" size="3"><br></font><font style="font-size: 12pt;" face="Arial" size="3"><br></font><font style="font-size: 12pt;" face="Arial" size="3">Quanto a usar reais como chave de hash, se eu tiver dois reais iguais poderá ser um problema para acessar os valores,</font><font style="font-size: 12pt;" face="Arial" size="3"><br></font><font style="font-size: 12pt;" face="Arial" size="3">mas em toda regra existe sua ex<font style="font-size: 12pt;" size="3">c</font>eção.</font><font style="font-size: 12pt;" face="Arial" size="3"><br></font><font style="font-size: 12pt;" face="Arial" size="3"><br></font><font style="font-size: 12pt;" face="Arial" size="3">No meu caso, o que me importa é que mfe esteja no intervalo determinado.</font><font style="font-size: 12pt;" face="Arial" size="3"><br></font><font style="font-size: 12pt;" face="Arial" size="3"><br></font><font style="font-size: 12pt;" face="Arial" size="3">Caso descordem seria uma honra ler a explicação de qualquer um de vocês.</font><br><br><div><div id="SkyDrivePlaceholder"></div>> Date: Thu, 29 Nov 2012 16:44:50 -0200<br>> From: thiagoglauco@ticursos.net<br>> To: rio-pm@pm.org<br>> Subject: Re: [Rio-pm] Chaves de hash<br>> <br>> Um exemplo mais preciso:<br>> <br>> $ uname -a<br>> SunOS cg01spo 5.10 Generic_138888-03 sun4v sparc <br>> SUNW,SPARC-Enterprise-T5120<br>> <br>> $ perl -E '<br>> if (0.2 > 0.19999999999999997){<br>> say "0.2 is greater than 0.19999999999999997";}<br>> else {<br>> say "Floating Point is not true real"};'<br>> 0.2 is greater than 0.19999999999999997<br>> $<br>> <br>> $ perl -E '<br>> if (0.2 > 0.19999999999999998){<br>> say "0.2 is greater than 0.19999999999999998";}<br>> else {<br>> say "Floating Point is not true real"};'<br>> Floating Point is not true real<br>> $<br>> <br>> Por que é importante saber essas coisas?<br>> http://ta.twi.tudelft.nl/users/vuik/wi211/disasters.html<br>> <br>> <br>> <br>> <br>> <br>> <br>> Em 2012-11-29 15:13, thiagoglauco@ticursos.net escreveu:<br>> >> Não se compara reais por igualdade.<br>> > Se você tem erro na igualdade, terá nas outras comparações se a<br>> > diferença entre os números for menor que o maior acréscimo suportado<br>> > pela plataforma:<br>> ><br>> > $ perl -E '<br>> > if (0.2 > 0.19999999999999999999999999999999999999999999){<br>> >> say "0.2 is greater than 0.19999999999999999999999999999999999999";}<br>> >> else {<br>> >> say "Floating Point is not true real"};'<br>> > Floating Point is not true real<br>> > $<br>> ><br>> > $ perl -E '<br>> > if (0.2 > 0.199999){<br>> > say "0.2 is greater than 0.199999";}<br>> > else {<br>> > say "Floating Point is not true real"};'<br>> > 0.2 is greater than 0.199999<br>> > $<br>> ><br>> > Então, comparar pontos flutuantes não é seguro. Nem igualdade, nem<br>> > maio, nem menor.<br>> ><br>> > E mais: garanto que se você quer usar um número real como chave de<br>> > Hash você tem um problema na análise da lógica do problema que está<br>> > enfrentando e como solucioná-lo.<br>> ><br>> ><br>> > Em 2012-11-29 10:36, Blabos de Blebe escreveu:<br>> >> Na verdade é o contrário, não?<br>> >><br>> >> Não se compara reais por igualdade.<br>> >><br>> >> Se você usa reais como chaves de hash, você tem algum problema...<br>> >><br>> >> Ao não controlar a representação interna em ponto flutuante, você <br>> >> pode<br>> >> nunca mais alcançar o valor relacionado à chave, se usar um número<br>> >> real como chave, pois qualquer bit diferente, mesmo que arredondando<br>> >> no mesmo número vai resultar num cálculo diferente na tabela hash.<br>> >><br>> >> Igualdade entre númros reais constuma ser definida como algo assim:<br>> >><br>> >> sub float_equal {<br>> >>     my ($first, $second) = @_;<br>> >>     my $threshold = 0.00000001 # arbitrário<br>> >>     return abs( $first - $second ) < $threshold;<br>> >> }<br>> >><br>> >> Converter para string antes de usar como chave de hash também não me<br>> >> parece saudável, pois, embora a string vá funcionar bem no hash, <br>> >> você<br>> >> não garante que a conversão vai resultar sempre na mesma string, e <br>> >> aí<br>> >> vc se ferra do mesmo jeito.<br>> >><br>> >> Por outro lado, se você nunca vai acessar o elemento do hash através<br>> >> da chave, um foreach por keys() ou values() vai te retornar os<br>> >> valores...<br>> >><br>> >> Mas aí eu te perguntaria por que rails você está usando hash pra <br>> >> isso...<br>> >><br>> >><br>> >><br>> >> On Thu, Nov 29, 2012 at 6:47 AM,  <thiagoglauco@ticursos.net> wrote:<br>> >>> Existe um problema aqui, diferente da comparação.<br>> >>> A comparação de reais é problemática devido a estrutura interna do <br>> >>> ponto<br>> >>> flutuante. NÃO SE COMPARA REAIS POR MAIOR OU MENOR.Isso não é do <br>> >>> Perl, mas<br>> >>> das regras de aproximação usada pelos processadores.<br>> >>><br>> >>> Rounding rules<br>> >>><br>> >>> The standard defines five rounding rules. The first two round to a <br>> >>> nearest<br>> >>> value; the others are called directed roundings:<br>> >>> Roundings to nearest<br>> >>><br>> >>>     Round to nearest, ties to even – rounds to the nearest value; <br>> >>> if the<br>> >>> number falls midway it is rounded to the nearest value with an even <br>> >>> (zero)<br>> >>> least significant bit, which occurs 50% of the time; this is the <br>> >>> default for<br>> >>> binary floating-point and the recommended default for decimal.<br>> >>>     Round to nearest, ties away from zero – rounds to the nearest <br>> >>> value; if<br>> >>> the number falls midway it is rounded to the nearest value above <br>> >>> (for<br>> >>> positive numbers) or below (for negative numbers); this is intended <br>> >>> as an<br>> >>> option for decimal floating point.<br>> >>><br>> >>> Directed roundings<br>> >>><br>> >>>     Round toward 0 – directed rounding towards zero (also known as<br>> >>> truncation).<br>> >>>     Round toward +∞ – directed rounding towards positive infinity <br>> >>> (also<br>> >>> known as rounding up or ceiling).<br>> >>>     Round toward −∞ – directed rounding towards negative infinity <br>> >>> (also<br>> >>> known as rounding down or floor).<br>> >>><br>> >>> Se a comparação for inevitável, converta o seu número para string e <br>> >>> compare<br>> >>> ou determine um nível de precisão aceitável e faça bit a bit.<br>> >>><br>> >>> Em 2012-11-28 21:42, Aureliano Guedes escreveu:<br>> >>>><br>> >>>> Ola Monges.<br>> >>>><br>> >>>> Estou com um problema simples mas que não acho a solução.<br>> >>>><br>> >>>> Eu tenho um hash onde as chaves são valores numericos reais (a<br>> >>>> maioria negativo e quase nenhum inteiro).<br>> >>>> Estou limitando esses valores por um maximo e um minimo.<br>> >>>><br>> >>>>  foreach my $keys (keys %d) {<br>> >>>>  if ($keys <= $min and $keys >= $max) {<br>> >>>>  print "$d{$keys}";<br>> >>>>  }<br>> >>>>  }<br>> >>>><br>> >>>> Problema que não da certo.<br>> >>>> Ha algo de errado aqui??<br>> >>>><br>> >>>> _______________________________________________<br>> >>>> Rio-pm mailing list<br>> >>>> Rio-pm@pm.org<br>> >>>> http://mail.pm.org/mailman/listinfo/rio-pm<br>> >>><br>> >>><br>> >>> _______________________________________________<br>> >>> Rio-pm mailing list<br>> >>> Rio-pm@pm.org<br>> >>> http://mail.pm.org/mailman/listinfo/rio-pm<br>> >> _______________________________________________<br>> >> Rio-pm mailing list<br>> >> Rio-pm@pm.org<br>> >> http://mail.pm.org/mailman/listinfo/rio-pm<br>> ><br>> > _______________________________________________<br>> > Rio-pm mailing list<br>> > Rio-pm@pm.org<br>> > http://mail.pm.org/mailman/listinfo/rio-pm<br>> <br>> _______________________________________________<br>> Rio-pm mailing list<br>> Rio-pm@pm.org<br>> http://mail.pm.org/mailman/listinfo/rio-pm<br></div>                                       </div></body>
</html>