Skip to content

Commit 0438a3e

Browse files
author
Phillip Weller
committed
R1.5 Master
2 parents 1b06439 + 6fb5ce4 commit 0438a3e

172 files changed

Lines changed: 221195 additions & 146488 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/Actionability.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,15 +238,15 @@ public function assertions()
238238
{
239239
if ($assertion->attributed_to->label == "Adult Actionability Working Group")
240240
{
241-
$new->adult_report_date = Carbon::parse($assertion->report_date)->format('Y-m-d H:i:s.0000');
241+
$new->adult_report_date = (empty($assertion->report_date) ? null : Carbon::parse($assertion->report_date)->format('Y-m-d H:i:s.0000'));
242242
$new->adult_source = $assertion->source;
243243
$new->adult_attributed_to = $assertion->attributed_to->label;
244244
$new->adult_classification = $assertion->classification->label;
245245

246246
}
247247
if ($assertion->attributed_to->label == "Pediatric Actionability Working Group")
248248
{
249-
$new->pediatric_report_date = Carbon::parse($assertion->report_date)->format('Y-m-d H:i:s.0000');
249+
$new->pediatric_report_date = (empty($assertion->report_date) ? null : Carbon::parse($assertion->report_date)->format('Y-m-d H:i:s.0000'));
250250
$new->pediatric_source = $assertion->source;
251251
$new->pediatric_attributed_to = $assertion->attributed_to->label;
252252
$new->pediatric_classification = $assertion->classification->label;
@@ -304,15 +304,15 @@ public function assertions()
304304
}
305305
if ($assertion->attributed_to->label == "Adult Actionability Working Group")
306306
{
307-
$new->adult_report_date = Carbon::parse($assertion->report_date)->format('Y-m-d H:i:s.0000');
307+
$new->adult_report_date = (empty($assertion->report_date) ? null : Carbon::parse($assertion->report_date)->format('Y-m-d H:i:s.0000'));
308308
$new->adult_source = $assertion->source;
309309
$new->adult_attributed_to = $assertion->attributed_to->label;
310310
$new->adult_classification = $assertion->classification->label;
311311

312312
}
313313
if ($assertion->attributed_to->label == "Pediatric Actionability Working Group")
314314
{
315-
$new->pediatric_report_date = Carbon::parse($assertion->report_date)->format('Y-m-d H:i:s.0000');
315+
$new->pediatric_report_date = (empty($assertion->report_date) ? null : Carbon::parse($assertion->report_date)->format('Y-m-d H:i:s.0000'));
316316
$new->pediatric_source = $assertion->source;
317317
$new->pediatric_attributed_to = $assertion->attributed_to->label;
318318
$new->pediatric_classification = $assertion->classification->label;

app/Change.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,29 @@ public function scopeFilters($query, $filters)
306306
});
307307
}
308308

309+
// panels
310+
$groups = preg_grep('/^\!.*/', $genes);
311+
foreach ($groups as $group)
312+
{
313+
// get list genes
314+
$panel = Panel::ident(substr($group, 1))->first();
315+
316+
// if this is a non-recurrent report, build a psuedo region
317+
if ($panel === null)
318+
{
319+
continue;
320+
}
321+
322+
323+
$genes = $panel->genes();
324+
325+
$items = $genes->collection->pluck('name');
326+
327+
$query = $query->orWhereHas('element', function ($query) use ($items) {
328+
$query->whereIn('name', $items);
329+
});
330+
}
331+
309332
}
310333

311334
/*$a = vsprintf(str_replace('?', '%s', $query->toSql()), collect($query->getBindings())->map(function ($binding) {

app/Console/Commands/QueryJira.php

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
5+
use Illuminate\Console\Command;
6+
7+
use DB;
8+
9+
use App\Jira;
10+
11+
class QueryJira extends Command
12+
{
13+
/**
14+
* The name and signature of the console command.
15+
*
16+
* @var string
17+
*/
18+
protected $signature = 'query:jira';
19+
20+
/**
21+
* The console command description.
22+
*
23+
* @var string
24+
*/
25+
protected $description = 'Command description';
26+
27+
/**
28+
* Create a new command instance.
29+
*
30+
* @return void
31+
*/
32+
public function __construct()
33+
{
34+
parent::__construct();
35+
}
36+
37+
/**
38+
* Execute the console command.
39+
*
40+
* @return mixed
41+
*/
42+
public function handle()
43+
{
44+
45+
//$results = Jira::getIssues('project = ISCA AND issuetype = "ISCA Gene Curation" AND "HGNC ID" is EMPTY');
46+
47+
48+
$record = Jira::getIssue('ISCA-4799');
49+
$record = Jira::getHistory('ISCA-4799');
50+
51+
/*$response = Jira::getIssues('project = ISCA AND issuetype in ("ISCA Region Curation") AND Resolution = Complete');
52+
53+
if (empty($response))
54+
return $collection;
55+
;
56+
foreach ($response->issues as $issue)
57+
{
58+
dd($issue);
59+
}*/
60+
dd($record);
61+
62+
echo "Update Complete\n";
63+
}
64+
}
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
5+
use Illuminate\Console\Command;
6+
7+
use App\Stream;
8+
use App\Pmid;
9+
use App\Curation;
10+
11+
class QueryKafka extends Command
12+
{
13+
/**
14+
* The name and signature of the console command.
15+
*
16+
* @var string
17+
*/
18+
protected $signature = 'query:kafka {topic}';
19+
20+
/**
21+
* The console command description.
22+
*
23+
* @var string
24+
*/
25+
protected $description = 'Command description';
26+
27+
/**
28+
* Create a new command instance.
29+
*
30+
* @return void
31+
*/
32+
public function __construct()
33+
{
34+
parent::__construct();
35+
}
36+
37+
// gene_dosage, gene_dosage_raw, gene_dosage_sepio_in.
38+
39+
/**
40+
* Execute the console command.
41+
*
42+
* @return mixed
43+
*/
44+
public function handle()
45+
{
46+
$topic = $this->argument('topic');
47+
48+
if ($topic === null)
49+
{
50+
echo "Topic not found \n";
51+
exit;
52+
}
53+
54+
$stream = Stream::name($topic)->first();
55+
56+
if ($stream === null)
57+
{
58+
echo "Topic not found \n";
59+
exit;
60+
}
61+
62+
$offset = $stream->offset;
63+
64+
$conf = new \RdKafka\Conf();
65+
66+
// Set a rebalance callback to log partition assignments (optional)
67+
$conf->setRebalanceCb(function (\RdKafka\KafkaConsumer $kafka, $err, array $partitions = null) use ($offset) {
68+
switch ($err) {
69+
case RD_KAFKA_RESP_ERR__ASSIGN_PARTITIONS:
70+
//echo "Assign: ";
71+
//var_dump($partitions);
72+
$kafka->assign($partitions);
73+
74+
foreach ($partitions as $tp) {
75+
$tp->setOffset($offset);
76+
$kafka->commit([$tp]);
77+
}
78+
break;
79+
80+
case RD_KAFKA_RESP_ERR__REVOKE_PARTITIONS:
81+
// echo "Revoke: ";
82+
//var_dump($partitions);
83+
$kafka->assign(NULL);
84+
break;
85+
default:
86+
throw new \Exception($err);
87+
}
88+
});
89+
90+
// Configure the group.id. All consumer with the same group.id will consume
91+
// different partitions.
92+
$conf->set('group.id', 'web_prod');
93+
94+
$conf->set('security.protocol', 'sasl_ssl');
95+
$conf->set('sasl.mechanism', 'PLAIN');
96+
$conf->set('sasl.username', $stream->username);
97+
$conf->set('sasl.password', $stream->password);
98+
99+
// Initial list of Kafka brokers
100+
$conf->set('metadata.broker.list', $stream->endpoint);
101+
// Set where to start consuming messages when there is no initial offset in
102+
// offset store or the desired offset is out of range.
103+
// 'earliest': start from the beginning
104+
$conf->set('auto.offset.reset', 'earliest');
105+
//$conf->set('enable.auto.commit', 'false');
106+
107+
108+
$consumer = new \RdKafka\KafkaConsumer($conf);
109+
110+
/*$availableTopics = $consumer->getMetadata(true, null, 60e3)->getTopics()
111+
;
112+
echo "Available Topics: \n";
113+
foreach ($availableTopics as $idx => $avlTopic) {
114+
echo $idx.': '.$avlTopic->getTopic()."\n";
115+
}*/
116+
117+
//$a = $consumer->getCommittedOffsets([new \RdKafka\TopicPartition('gene_dosage', 0)], 60*1000);
118+
//$low = $high = 0;
119+
120+
//$consumer->queryWatermarkOffsets('web-group-events', 0, $low, $high, 60*1000);
121+
//dd($high);
122+
123+
// Subscribe to topic 'test'
124+
$consumer->subscribe([$stream->topic]);
125+
126+
//echo "Waiting for partition assignment... (make take some time when\n";
127+
//echo "quickly re-joining the group after leaving it.)\n";
128+
129+
echo "Reading...\n";
130+
while (true) {
131+
$message = $consumer->consume(120*1000);
132+
//echo $message->err . "\n";
133+
134+
switch ($message->err) {
135+
case 0:
136+
case RD_KAFKA_RESP_ERR_NO_ERROR:
137+
$payload = json_decode($message->payload);
138+
//dd($payload);
139+
$a = $stream->parser;
140+
$a($payload);
141+
$stream->update(['offset' => $message->offset + 1]);
142+
break;
143+
case RD_KAFKA_RESP_ERR__PARTITION_EOF:
144+
echo "No more messages; will wait for more\n";
145+
break 2;
146+
case RD_KAFKA_RESP_ERR__TIMED_OUT:
147+
echo "Timed out\n";
148+
break 2;
149+
default:
150+
throw new \Exception($message->errstr(), $message->err);
151+
break;
152+
}
153+
}
154+
155+
echo "Update Complete\n";
156+
}
157+
}

0 commit comments

Comments
 (0)