arecuk

Experience

570

0 Best Reply Awards

  • Member Since 4 Months Ago
  • 0 Lessons Completed
  • 0 Favorites

19th March, 2018

arecuk left a reply on Check For Whitespace Fails • 1 month ago

so the space is actually: U+00A0 - no break space http://www.fontspace.com/unicode/analyzer/

arecuk left a reply on Check For Whitespace Fails • 1 month ago

@m-rk great, that helps somehow!

following code identify the rsID with a space:

if (preg_replace('/[^a-zA-Z0-9]/','', $snp->rs_id) !== $snp->rs_id):
                dd ($snp->rs_id);
              endif;    

now the question is:

  • what is the space actually? it could be some fancy utf-8 character, as mentioned by @m-rk ...
  • how to remove it?

thanks a lot, I feel we are getting there!

arecuk left a reply on Check For Whitespace Fails • 1 month ago

thank you for all your comments ... I think it could something else than a space, although I can not figure it what else could it be?

in the database there is only space, not   ... var_dump does not help either

here is a screenshot from phpmyadmin: https://drive.google.com/open?id=1qTcQ_2_mKUekBpz-S7wJyeiHh_JiIYVq

and here dump of my table with the a few entries with spaces as shown on the picture above: https://drive.google.com/open?id=1uZIjod-Yqu9t0Bewj5Mw_d34LrCKHunl

16th March, 2018

arecuk left a reply on Check For Whitespace Fails • 1 month ago

@m-rk - well the query returns 0 raws affected, although there are rsID with spaces

@ismailm - good point but I use this code:

if (strlen($rsID) != strlen(trim($rsID))): dd ($rsID); endif;

arecuk left a reply on Check For Whitespace Fails • 1 month ago

yes this code works but it does not when I retrieve the variable as a result of database query

arecuk left a reply on Check For Whitespace Fails • 1 month ago

thank you but I need to check the value of $rsID indeed

check the screenshot here: https://drive.google.com/open?id=1DKpA5j6Y8IOYzAnTlxcX6T4xfHW5xjGm

arecuk started a new conversation Check For Whitespace Fails • 1 month ago

Hey guys,

I have external database that I connect to from laravel. This external table has a field: rsID varchar40 utf8_general_ci

The right format of rsID is 'rs123'. However, in some case based of user-error when entering new raws the ID contains a space: ' rs123' - the space at the beginning 'rs123 ' - the space at the end

The space is stored in the table and I can see it using phpmyadmin.

Then, in my laravel app I query the table and indeed I get the rsID rendered with a space.

I want to identify those rsIDs that contain space but Im having hard time with it.

when I hardcode the variable all works just fine!
$x = ' xx';
if (strlen($x) != strlen(trim($x)))
 there is space in the string!

but when I get the variable as a result of database query it fails:
foreach ($data as $rsID => $alleles):
if (strlen($rsID ) != strlen(trim($rsID )))
 although rsID contains space the condition is evaluated as false

Does any one has some idea? I've been playing with it for hours but somehow cant figure it out.

Thanks a lot, Tomas

12th January, 2018

arecuk left a reply on WhereNotNull OR WhereNotNull Problem • 3 months ago

thanks!

anyway, I made it this way:

        $getSNPs = $ghcCore->table('snps')->select('*')
                                          ->where(function ($query) use ($cond,$id,$status) {
                                              $query->where($cond,$id)
                                                    ->where('status',$status)
                                                    ->whereNotNull('odds_ratio');
                                              })
                                          ->orwhere(function ($query) use ($cond,$id,$status) {
                                              $query->where($cond,$id)
                                                    ->where('status',$status)
                                                    ->whereNotNull('beta');
                                              })
                                          ->get();

arecuk started a new conversation WhereNotNull OR WhereNotNull Problem • 3 months ago

Hey Guys!

I need help with following statement:

        $getSNPs = $ghcCore->table('snps')->select('*')
                                          ->where($cond,$id)
                                          ->where('status',$status)
                                          ->where(function ($query) {
                                              $query->whereNotNull('odds_ratio');
                                              })
                                          ->orwhere(function ($query) {
                                              $query->whereNotNull('beta');
                                              })
                                          ->get();

It returns wrong entries. What I need is following:

  1. where cond = 1 AND
  2. where status = statusX AND
  3. where field1 OR field2 is not empty (meaning one field must havea value)

Thanks a lot! Tomas

3rd January, 2018

arecuk started a new conversation String Comparison Question • 3 months ago

Hey Guys,

I have following array:

    [0] => Array
        (
            [genotype] => CC
            [or] => 1.1
        )

    [1] => Array
        (
            [genotype] => CG
            [or] => 1.1
        )

    [2] => Array
        (
            [genotype] => GC
            [or] => 1.1
        )

    [3] => Array
        (
            [genotype] => GG
            [or] => 1.1
        )

I need to process the array in a way that CG and GC are considered the same. I mean I need an algorithm/function where the position of character does not count.

I would need to get something like this:

    [0] => Array
        (
            [genotype] => CC
            [or] => 1.1
        )

    [1] => Array
        (
            [genotype] => CG
            [or] => 1.1
        )

    [2] => Array
        (
            [genotype] => GG
            [or] => 1.1
        )

Thanks a lot for any tip!

2nd January, 2018

arecuk left a reply on Problem With Navigation URLs • 3 months ago

great, that helped and now it works! thanks a lot

now Im having problem with form rendering, I get: Route [report/save] not defined.

this is my view file:

Form::open(array('route' => 'report/save'));

this is my web.php:

Route::post('/report/save', [
    'as' => 'save.report',
    'uses' => '[email protected]'
  ]);

this is my controller

  public function reportSave(Request $request) {

    echo 'xxx';
   die;

  }

So I dont understand why Im getting this error ...

arecuk left a reply on Problem With Navigation URLs • 3 months ago

yes I use the same template for sidebar:

    <!-- sidebar nav -->          
    
    <div class="panel-heading"><b>CHOOSE AN ACTION:</b></div>
    <nav id="sidebar-nav">
        <ul class="nav nav-pills nav-stacked">
            <li><a href="./report">Manage Reports</a></li>
            <li><a href="./release">GHC Core Releases</a></li>
            <li><a href="./playground">Playground</a></li>
            <li><a href="./ethnicalgroups">Ethnical Groups</a></li>
            <li><a href="./populations">Populations</a></li>
            <li><a href="./tree">Panel Tree</a></li>
            <li><a href="./contentful">Contentful API</a></li>
            <li><a href="./varsome">VarSome API</a></li>
        </ul>
    </nav>
    <br />

arecuk started a new conversation Problem With Navigation URLs • 3 months ago

Hey guys!

Im struggling with navigation links. Im using pretty much default laravel configuration and all my code is executed in the user area after logging-in.

For example, my navigation link in the sidebar is: http://localhost2/magic.box/public/report

  • this works just fine

In the report page I have a list with reports with links for actions available for given link, such as: http://localhost2/magic.box/public/report/view/2

  • this is report detail page, works just fine

However, when Im in the report detail page the navigation link fore report link in the sidebar changes: http://localhost2/magic.box/public/report/view/report

So, for some reason '/view/report' is attached to all links in the sidebar when Im in a subpage, such as report detail page.

Any idea what may be wrong?

Thanks a lot, Tomas

15th December, 2017

arecuk started a new conversation Html Table Generator? • 4 months ago

hey guys! Im learnig laravel and need an easy way how to render a html table based on a request on the database

Im trying https://github.com/gbrock/laravel-table but it does not render any table, perhaps its not compatible with laravel 5.5

here is snip from the object:

$releases->render(); nothing renders

PRINT_R output
Gbrock\Table\Table Object
(
    [models:protected] => Illuminate\Database\Eloquent\Collection Object
        (
            [items:protected] => Array
                (
                    [0] => App\release Object
                        (
                            [connection:protected] => mysql
                            [table:protected] => 
                            [primaryKey:protected] => id
                            [keyType:protected] => int
                            [incrementing] => 1
                            [with:protected] => Array
                                (
                                )

                            [withCount:protected] => Array
                                (
                                )

                            [perPage:protected] => 15
                            [exists] => 1
                            [wasRecentlyCreated] => 
                            [attributes:protected] => Array
                                (
                                    [id] => 1
                                    [created_at] => 2017-12-15 18:00:00
                                    [updated_at] => 2017-12-15 18:00:00
                                    [comments] => prvni rucne vlozeny zaznam
                                    [panels] => 2
                                    [phenotypes] => 12
                                    [subphenotypes] => 23
                                    [genes] => 45
                                    [haplotypes] => 5
                                    [snps_total] => 123
                                    [snps_in_panels] => 99

dont you know about good alternative?

1st December, 2017

arecuk left a reply on Guzzle Queries • 4 months ago

$content = json_decode($data->getBody()); did the trick, thank you!

now, I have second problem, I need to rewrite curl api call (which works) using guzzle library (which does not)

specifically I dont know how to pass CURLOPT_POSTFIELDS variable to guzzle client??

$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.varsome.com/lookup/batch/hg19?add-all-data=1",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "{\"variants\": [\"rs729635\"]}",
  CURLOPT_HTTPHEADER => array(
    "accept: application/json",
    "accept-encoding: gzip,deflate",
    "authorization: Token ".$access_token,
    "content-type: application/json"
  ),
));

and here is my new code:

$batch = array ('rs729635','rs4988321');     
$batch_json = json_encode($batch);

$data = $client->request('POST', 'https://api.varsome.com/lookup/batch/hg19', [
                'headers' => [
                    'Authorization' => $token,
                    'Content-Type' => 'application/json;charset=utf8'
                ],
                'add-all-data' => '1',
                'json' => $batch
            ]
        );


arecuk started a new conversation Guzzle Queries • 4 months ago

hey guys,

Im having hard time understanding how guzzle returns data, here is my function:

    public function getSNP ($rs_id,$assembly) {

        $client = new VarsomeClient;
        $token = $this->getToken();
        $url = 'https://api.varsome.com/lookup/' . $rs_id . '/' . $assembly . '?add-all-data=1';      

        $data = $client->request('GET', $url, [
                'headers' => [
                    'Authorization' => $token,
                    'Content-Type' => 'application/json;charset=utf8',
                    'Accept' => 'application/json',
                    'accept-encoding' => 'gzip,deflate'
                ]
            ]
        );

        $content = $data->getStatusCode();

        $content .= $data->getBody();

        return $content;
    }

It seems to be working fine BUT look at the last lines of the code, the $content variable:

        $content = $data->getStatusCode();
        $content .= $data->getBody();
        return $content; // returns 200 followed by content

        $content = $data->getStatusCode();
        return $content; // returns 200 only

and now strangely:

        $content = $data->getBody();
        return $content; // returns empty string, how's that possible? what am I missing here?

arecuk left a reply on Rewriting Perl Script To Laravel • 4 months ago

regarding the access token I need to pass to the call here is what Ive found in api provider docs:

Authorization: Authorization: Token <your_token> - (in request headers). To take advantage of your account's benefits you may include your VariantAPI token as a request authorization header.

arecuk started a new conversation Rewriting Perl Script To Laravel • 4 months ago

hey guys,

Im dealing with rewriting api calls from perl to laravel's php ... in laravel Im using guzzle http client loaded via composer

here is my code in perl, provided as example:

#!/usr/bin/perl
# This script goes through variant queries in stdin (one query per line) and outputs results to stdout
# If a query ends in /hg19 or /hg38, that ref genome is used, otherwise the default is used

use strict;
use warnings;

my $securityToken = $ENV{'SAPHETOR_VARIANT_API_TOKEN'};
my $defaultRefGenome = 'hg19';

my $curlCommand = "curl -H 'Content-Type: application/json'";
$curlCommand .= " -H 'Authorization: Token $securityToken'" if (defined($securityToken) and $securityToken ne '');

my $lineno = 0;
while (my $query = <>) {
    chomp($query);
    ++$lineno;
    $query .= "/$defaultRefGenome" unless ($query =~ /\/hg19$/ or $query =~ /\/hg38$/);
    my $ql = `$curlCommand 'https://api.varsome.com/lookup/$query?add-all-data=1' 2>/dev/null `;
    if ($ql !~ /chromosome/) {
        print STDERR "line $lineno error\n";
    }
    print "$ql\n";
}

and Im experimenting with following code in laravel:

$res = $client->request('POST', 'https://url_to_the_api', [
            'form_params' => [
                'client_id' => 'test_id',
                'secret' => 'test_secret',
            ]
        ]);
        echo $res->getStatusCode();
        // "200"
        echo $res->getHeader('content-type');
        // 'application/json; charset=utf8'
        echo $res->getBody();
        // {"type":"User"...'

specifically, I dont understand how to build a $query and pass it to the request

29th November, 2017

arecuk left a reply on Need Help With Building A Sql Query • 4 months ago

that works, thanks a lot!

arecuk started a new conversation Need Help With Building A Sql Query • 4 months ago

Hi guys!

Im struggling with little bit complicated sql query:

public function isInHaplotype ('phenotype','10', $rs_ID_needle,'In Panel') {

    $getHaplotypes = $ghcCore->table('haplotypes')->select('id',
                                               'rs_id_1',
                                               'rs_id_2',
                                               'rs_id_3',
                                               'rs_id_4',
                                               'rs_id_5',
                                               'risk_allele',
                                               'odds_ratio')
                                      ->where($cond,$id)->where('status',$status)
                                      ->where(function($query){
                                              $query->where('rs_id_1',$rs_ID_needle);
                                                    //->orWhere('rs_id_2',$rs_ID_needle)
                                                    //->orWhere('rs_id_3',$rs_ID_needle)
                                                    //->orWhere('rs_id_4',$rs_ID_needle)
                                                    //->orWhere('rs_id_5',$rs_ID_needle);
                                             })
                                      ->count();

When I run this query I get: "Undefined variable: rs_ID_needle"

Meaning I can not pass the function parametr $rs_ID_needle to the query.

When I hard code the parametr the query starts to work just fine.

So basically I need to pass the variable to this part of the code: ->where(function($query){ $query->where('rs_id_1',$rs_ID_needle);

And thats what does not work and I get "Undefined variable: rs_ID_needle"

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.