NCBI C++ ToolKit
table_data_snp.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: table_data_snp.cpp 32240 2015-01-22 21:53:03Z katargir $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Authors: Dmitry Rudnev
27  *
28  * File Description:
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
33 
34 #include <gui/objutils/label.hpp>
35 #include "table_data_snp.hpp"
36 #include <gui/objutils/utils.hpp>
37 #include <gui/utils/app_job.hpp>
39 
41 #include <objmgr/util/sequence.hpp>
42 
45 #include <objects/seq/Seq_data.hpp>
54 
55 #include <common/ncbi_source_ver.h>
56 
59 
60 
62 {
63 public:
64  CTableDataSNPJob( CScope& scope, const CSeq_loc& loc);
65  virtual ~CTableDataSNPJob() {}
66 
67  /// @name IAppJob implementation
68  /// @{
69  virtual EJobState Run();
71  virtual CRef<CObject> GetResult();
73  virtual string GetDescr() const;
74  /// @}
75 
76 private:
77  void x_FetchAll();
78 
79 private:
83 
84  size_t m_Total;
85  size_t m_Completed;
87 };
88 
89 
91 : m_Scope(&scope),
92  m_Loc(&loc),
93  m_Total(100),
94  m_Completed(0)
95 {
97 }
98 
100 {
102  p->SetNormDone( float(m_Completed) / float(m_Total) );
104 }
105 
107 {
108  return m_listSnps;
109 }
110 
111 
113 {
115 }
116 
117 
119 {
120  return "SNP table data loader job";
121 }
122 
123 
125 {
126  x_FetchAll();
127 
128  return IsCanceled() ? eCanceled : eCompleted;
129 }
130 
131 
133 {
134  SAnnotSelector sel; // annotation selector
135  size_t size; // number of features returned (not all of them will be used though)
136 
138 
139  // Prepare Annotation Selection to find the SNPs
141  sel.AddNamedAnnots("SNP")
142  .SetExcludeExternal(false)
143  .SetMaxSize(CTableDataSNP::c_MaxRows);
144 
145  // Fetch the SNPs
146  CFeat_CI feat_it(*m_Scope, *m_Loc, sel);
147 
148  // Determine the amount of features returned
149  size = feat_it.GetSize();
150 
151  // make sure there is data
152  if (size < 1)
153  return;
154  m_Total = size;
155 
156  // Prepare the list, and populate it
157  snp_list.reserve(size);
158 
159  for (; feat_it; ++feat_it) {
160  ++m_Completed;
161  const CSeq_feat& or_feat(feat_it->GetOriginalFeature());
162 
163  // Grab the database info
165  CRef<CVariation> pVariation(new CVariation());
166  if(!NSNPVariationHelper::ConvertFeat(*pVariation, or_feat))
167  continue;
168 
169  // Retrieve gene associated with SNP
170  tag.Reset(); // reuse tag reference.
171  CConstRef<CSeq_feat> gene_feat;
172  gene_feat = sequence::GetBestOverlapForSNP(or_feat,
174  *m_Scope);
175  if (gene_feat) {
176  tag = gene_feat->GetNamedDbxref("GeneID");
177  if (!tag) {
178  tag = gene_feat->GetNamedDbxref("LocusLink");
179  }
180  }
181  if (tag) {
182  pVariation->SetOther_ids().push_back(CRef<CDbtag>(const_cast<CDbtag*>(tag.GetPointer())));
183  }
184 
185  snp_list.push_back(pVariation);
186  }
187 }
188 
189 
191  ON_MESSAGE(CAppJobNotification, CAppJobNotification::eStateChanged, &CTableDataSNP::OnJobNotification)
193 
194 // maximal amount of SNP we should realistically see in a SNP table
195 const size_t CTableDataSNP::c_MaxRows(100000);
196 
198 :
199 m_DataLoadStatus(eNotReady)
200 {
201  _ASSERT( !objects.empty() );
202  m_Scope = objects.front().scope;
203  m_OrigLoc.Reset(dynamic_cast<const CSeq_loc*>(objects[0].object.GetPointer()));
204 }
205 
207 {
208  if(m_DataLoadStatus == eNotReady) {
210  disp.DeleteJob(m_hJob);
211  }
212 }
213 
214 
215 
217 {
220  try {
221  m_hJob = disp.StartJob(*job, "ObjManagerEngine", *this);
222  } catch( CAppJobException& e ){
224  LOG_POST( Error
225  << "CTableDataSNP failed to start job: "
226  << e.GetMsg()
227  );
228  LOG_POST(e.ReportAll());
229  }
230 }
231 
232 
233 void CTableDataSNP::OnJobNotification(ncbi::CEvent *evt)
234 {
235  CAppJobNotification* notif = dynamic_cast<CAppJobNotification*>( evt );
236 
237  _ASSERT(notif);
238 
239  int job_id = notif->GetJobID();
240  IAppJob::EJobState state = notif->GetState();
241 
242  if (job_id != m_hJob) return;
243 
244  switch (state) {
245  case IAppJob::eCompleted:
246  {
250 
251  // send a message to the view that data has changed (i.e. ready)
254  CIRef<ITableData> table_data;
255  table_data.Reset(this);
256  attachment->SetData(table_data);
257  evt.SetAttachment(attachment, CEvent::eRelease);
258  Send(&evt, ePool_Parent);
259  break;
260  }
261  case IAppJob::eCanceled:
262  case IAppJob::eFailed:
264  break;
265  default:
266  break;
267  }
268 }
269 
270 
271 
272 
273 // number of entries and order must correspond with CTableDataSNP::EColContents
274 static const string s_ColNames[] = {
275  "RS ID",
276  "Alleles",
277  "Sequence",
278  "Location",
279  "FXN Class",
280  "Weight",
281  // "Pop Freq", -- dropped as asked in SNP-4726
282  "Variation Class",
283  "Resource Link",
284  // "Mapping", -- dropped as asked in SNP-4726
285  "Frequency Validation",
286  // "Haplotype Set", -- dropped as asked in SNP-4726
287  "Quality Check",
288  "Phenotype",
289  "1000 Genomes"
290 };
291 
292 
293 
294 
296 {
297  if(m_DataLoadStatus != eReady) {
298  return ITableData::kString;
299  }
300  switch(col){
301  case eWeight:
302  case ePosition:
303  return ITableData::kInt;
304 
305  case eRsId:
306  return ITableData::kInt;
307 
308  case eResourceLink:
309  case ePhenotype:
310 // case ePopFreq: -- dropped as asked in SNP-4726
311  case eFXNClass:
312  return ITableData::kString;
313 
314  default:
315  return ITableData::kString;
316  }
317  return ITableData::kNone;
318 }
319 
320 
321 bool CTableDataSNP::IsHtmlColumn(size_t col) const
322 {
323  if(m_DataLoadStatus != eReady) {
324  return false;
325  }
326  switch(col){
327  case eRsId:
328  case eResourceLink:
329  case ePhenotype:
330  case eFXNClass:
331  return true;
332  default:
333  return false;
334  }
335 }
336 
337 string CTableDataSNP::GetColumnLabel(size_t col) const
338 {
339  if(m_DataLoadStatus != eReady && col == 0) {
340  return "Status";
341  }
342  if (col < CTableDataSNP::eMaxColNum)
343  return s_ColNames[col];
344 
345  return kEmptyStr;
346 }
347 
348 
350 {
351  return m_DataLoadStatus == eReady ? m_listSnps->GetData().size() : 1;
352 }
353 
354 
356 {
357  return (size_t)CTableDataSNP::eMaxColNum;
358 }
359 
360 void CTableDataSNP::GetStringValue(size_t row, size_t col, string& value) const
361 {
362  value.resize(0);
363  if(m_DataLoadStatus == eNotReady) {
364  value = (col == 0 ? "Loading..." : "");
365  return;
366  }
367  if(m_DataLoadStatus == eFailed) {
368  value = (col == 0 ? "Load failed!" : "");
369  return;
370  }
371  if(row+1 == c_MaxRows) {
372  value = "Warning: Only the first " + NStr::NumericToString(c_MaxRows) + " rows can be shown";
373  return;
374  }
375  list<string> values;
376  string sDelimiter(", ");
377  if (row < GetRowsCount()) {
378  CConstRef<CVariation> pVariation(x_GetRowData(row));
379  bool isProp(pVariation->CanGetVariant_prop());
380  CSnpBitfield bf;
381  if(pVariation->CanGetExt()) {
382  const CVariation::TExt& Ext(pVariation->GetExt());
383  ITERATE(CVariation::TExt, iExt, Ext) {
384  if((*iExt)->CanGetClass() &&
385  (*iExt)->GetClass() == SNP_VAR_EXT_CLASS &&
386  (*iExt)->GetFieldRef(SNP_VAR_EXT_BITFIELD).NotEmpty() &&
387  (*iExt)->GetFieldRef(SNP_VAR_EXT_BITFIELD)->CanGetData() &&
388  (*iExt)->GetFieldRef(SNP_VAR_EXT_BITFIELD)->GetData().IsOs()) {
389  bf = (*iExt)->GetFieldRef(SNP_VAR_EXT_BITFIELD)->GetData().GetOs();
390  }
391  }
392  }
393  bool isBitfield(bf.GetVersion() > 0);
394 
395  switch(col){
396  case ePosition:
397  case eWeight:
398  values.push_back(NStr::NumericToString(GetIntValue(row, col)));
399  break;
400 
401  case eRsId:
402  {
403  string sValue;
404  if(pVariation->GetId().CanGetTag()) {
405  CNcbiOstrstream ostr;
406  pVariation->GetId().GetTag().AsString(ostr);
407  sValue = CNcbiOstrstreamToString(ostr);
408  } else
409  pVariation->GetId().GetLabel(&sValue);
410 
411  values.push_back(sValue);
412  break;
413  }
414  case eResourceLink:
415  {
416  list<string> Texts;
417  list<string> URLs;
418  if(isProp) {
420  pVariation->GetVariant_prop(),
423  pVariation->GetVariant_prop(),
425  }
426  /* the entities that do not have a link are disabled per SNP-4726
427  //!! no representation in CVariantProperties for eHasPubmedArticle, so use bitfield
428  if(isBitfield && bf.IsTrue(CSnpBitfield::eHasPubmedArticle)) {
429  Texts.push_back("PubMed Central article");
430  }
431  //!! no representation in CVariantProperties for eHasShortReadArchive, so use bitfield
432  if(isBitfield && bf.IsTrue(CSnpBitfield::eHasShortReadArchive)) {
433  Texts.push_back("Short Read Archive");
434  }
435  //!! no representation in CVariantProperties for eHasOrganism, so use bitfield
436  if(isBitfield && bf.IsTrue(CSnpBitfield::eHasOrganism)) {
437  Texts.push_back("OrganismDBLink");
438  }
439  //!! no representation in CVariantProperties for eFromMgcClone, so use bitfield
440  if(isBitfield && bf.IsTrue(CSnpBitfield::eFromMgcClone)) {
441  Texts.push_back("From MGC clone");
442  }
443  //!! no representation in CVariantProperties for eHasTrace, so use bitfield
444  if(isBitfield && bf.IsTrue(CSnpBitfield::eHasTrace)) {
445  Texts.push_back("Trace Archive");
446  }
447  //!! no representation in CVariantProperties for eHasAssembly, so use bitfield
448  if(isBitfield && bf.IsTrue(CSnpBitfield::eHasAssembly)) {
449  Texts.push_back("Assembly Archive");
450  }
451  //!! no representation in CVariantProperties for eHasGEO, so use bitfield
452  if(isBitfield && bf.IsTrue(CSnpBitfield::eHasGEO)) {
453  Texts.push_back("Entrez GEO");
454  }
455  //!! no representation in CVariantProperties for eHasProbeDB, so use bitfield
456  if(isBitfield && bf.IsTrue(CSnpBitfield::eHasProbeDB)) {
457  Texts.push_back("ProbeDB");
458  }
459  //!! no representation in CVariantProperties for eHasEntrez, so use bitfield
460  if(isBitfield && bf.IsTrue(CSnpBitfield::eHasEntrez)) {
461  Texts.push_back("Entrez Gene");
462  }
463  //!! no representation in CVariantProperties for eHasSTS, so use bitfield
464  if(isBitfield && bf.IsTrue(CSnpBitfield::eHasSTS)) {
465  Texts.push_back("Entrez STS");
466  }
467  */
468  // scan and skip values that do not have an URL per SNP-4726
469  list<string>::const_iterator iTexts(Texts.begin());
470  ITERATE(list<string>, iURLs, URLs) {
471  if(!iURLs->empty()) {
472  values.push_back(*iTexts);
473  }
474  ++iTexts;
475  }
476  break;
477  }
478 /* case ePopFreq: -- dropped as asked in SNP-4726
479  if(isProp &&
480  pVariation->GetVariant_prop().CanGetGenotype() &&
481  pVariation->GetVariant_prop().GetGenotype() & CVariantProperties::eGenotype_has_genotypes) {
482  values.push_back("GTY");
483  }
484  break;
485 */
486  case eAlleles:
487  // for now, just extract allele strings out of the deltas and catenate them with '/'
488  // if a delta is empty, show it as "-"
489  sDelimiter = "/";
490  NSNPVariationHelper::GetDeltas<CVariation>(values, pVariation);
491  // testing the filter for GB-2588:
492  // values.push_back(">5pct");
493  break;
494 
495  case eSequence:
496  if(pVariation->CanGetPlacements()) {
497  const CVariation::TPlacements& VarPlacements(pVariation->GetPlacements());
498  if(!VarPlacements.empty()) {
499  CRef<CVariantPlacement> pPlacement(VarPlacements.front());
500  if(pPlacement->CanGetLoc()) {
501  CSeq_id_Handle idh = sequence::GetIdHandle(pPlacement->GetLoc(), const_cast<CScope*>(m_Scope.GetPointer()));
502  idh = sequence::GetId(idh, *const_cast<CScope*>(m_Scope.GetPointer()), sequence::eGetId_Best);
503  string sLabel;
504  idh.GetSeqId()->GetLabel(&sLabel, CSeq_id::eContent);
505  values.push_back(sLabel);
506  }
507  }
508  }
509  break;
510 
511  case eFXNClass:
512  if(isProp) {
513  list<string> GeneLocations;
515  pVariation->GetVariant_prop(),
517  list<string> Effects;
519  pVariation->GetVariant_prop(),
521  values.swap(GeneLocations);
522  values.insert(values.end(), Effects.begin(), Effects.end());
523  }
524  break;
525 
526  case eVariationClass:
527  //!! kludgy thing, use bitfield to recover a lot of variation classes
528  if(pVariation->CanGetData() && pVariation->GetData().IsInstance()) {
529  switch(pVariation->GetData().GetInstance().GetType()) {
531  values.push_back("SNP");
532  break;
534  values.push_back("MNP");
535  break;
537  values.push_back("INDEL");
538  break;
540  values.push_back("MSAT");
541  break;
542  default:
543  break;
544  }
545  } else {
546  //!! a catch-all for all variation classes not properly captured in CVariation
547  }
548  //!! when in doubt, try to get data from the original bitfield, while we use this kludge
549  if(isBitfield && values.empty())
550  values.push_back(bf.GetVariationClassString());
551  break;
552 
553 /* case eMapping: -- dropped as asked in SNP-4726
554  if(isProp)
555  NSNPVariationHelper::VariantPropAsStrings(values,
556  pVariation->GetVariant_prop(),
557  NSNPVariationHelper::eSNPPropName_Mapping);
558  break;
559 */
560  case eFreqValidation:
561  if(isProp)
563  pVariation->GetVariant_prop(),
565  //!! no representation in CVariantProperties for eGMAF0dot01, so use bitfield
566  if(isBitfield && bf.IsTrue(CSnpBitfield::eGMAF0dot01)) {
567  values.push_back("GMAF >= 0.01");
568  }
569  break;
570 
571 /* case eInHaplotypeSet: -- dropped as asked in SNP-4726
572  values.push_back((isProp &&
573  pVariation->GetVariant_prop().CanGetGenotype() &&
574  pVariation->GetVariant_prop().GetGenotype() & CVariantProperties::eGenotype_in_haplotype_set)
575  ?
576  "Y" : "N");
577  break;
578 */
579  case eQualityCheck:
580  if(isProp)
582  pVariation->GetVariant_prop(),
584  //!! no representation in CVariantProperties for eIsSomatic, so use bitfield
585  if(isBitfield && bf.IsTrue(CSnpBitfield::eIsSomatic)) {
586  values.push_back("Somatic, not germline");
587  }
588  //!! no representation in CVariantProperties for eIsSuspect, so use bitfield
589  if(isBitfield && bf.IsTrue(CSnpBitfield::eIsSuspect)) {
590  values.push_back("Suspect");
591  }
592  break;
593 
594  case ePhenotype:
595  //!! no representation in CVariantProperties for eHasMeSH, so use bitfield
596  if(isBitfield && bf.IsTrue(CSnpBitfield::eHasMeSH)) {
597  values.push_back("MeSH");
598  }
599  //!! no representation in CVariantProperties for eHasClinicalAssay, so use bitfield
600  if(isBitfield && bf.IsTrue(CSnpBitfield::eHasClinicalAssay)) {
601  values.push_back("Clinical diagnostic assay");
602  }
603  //!! no representation in CVariantProperties for eHasTranscriptionFactor, so use bitfield
604  if(isBitfield && bf.IsTrue(CSnpBitfield::eHasTranscriptionFactor)) {
605  values.push_back("Transcription factor");
606  }
607  //!! no representation in CVariantProperties for eHasDiseaseInfo, so use bitfield
608  if(isBitfield && bf.IsTrue(CSnpBitfield::eHasDiseaseInfo)) {
609  values.push_back("From LSDB");
610  }
611  //!! no representation in CVariantProperties for eHasLowdbGaPPValue, so use bitfield
612  if(isBitfield && bf.IsTrue(CSnpBitfield::eHasLowdbGaPPValue)) {
613  values.push_back("p-Value <= 0.001 in dbGaP");
614  }
615  //!! no representation in CVariantProperties for eHasLodScore, so use bitfield
616  if(isBitfield && bf.IsTrue(CSnpBitfield::eHasLodScore)) {
617  values.push_back("LOD score >= 2.0 in dbGaP");
618  }
619  //!! no representation in CVariantProperties for eHasMicroattribution, so use bitfield
620  if(isBitfield && bf.IsTrue(CSnpBitfield::eHasMicroattribution)) {
621  values.push_back("Microattribution");
622  }
623  //!! no representation in CVariantProperties for eHasOMIM_OMIA, so use bitfield
624  if(isBitfield && bf.IsTrue(CSnpBitfield::eHasOMIM_OMIA)) {
625  values.push_back("OMIM/OMIA");
626  }
627  break;
628 
629  case e1000Genomes:
630  //!! no representation in CVariantProperties for eTGPPhase3, so use bitfield
631  if(isBitfield && bf.IsTrue(
632 #if NCBI_DEVELOPMENT_VER >= 20141121
634 #else
636 #endif
637  )) {
638  values.push_back("1000G Phase 3");
639  }
640  //!! no representation in CVariantProperties for eTGPPhase1, so use bitfield
641  if(isBitfield && bf.IsTrue(CSnpBitfield::eTGPPhase1)) {
642  values.push_back("1000G Phase 1");
643  }
644  //!! no representation in CVariantProperties for eTGPPilot, so use bitfield
645  if(isBitfield && bf.IsTrue(CSnpBitfield::eTGPPilot)) {
646  values.push_back("1000G pilot");
647  }
648  //!! no representation in CVariantProperties for eTGPOnlyNotExclusive, so use bitfield
649  if(isBitfield && bf.IsTrue(CSnpBitfield::eTGPOnlyNotExclusive)) {
650  values.push_back("Has 1000G submission");
651  }
652  //!! no representation in CVariantProperties for eTGPNoneNotExclusive, so use bitfield
653  if(isBitfield && bf.IsTrue(CSnpBitfield::eTGPNoneNotExclusive)) {
654  values.push_back("Not present in 1000G");
655  }
656  break;
657 
658  default:
659  break;
660  }
661  }
662  value = NStr::Join(values, sDelimiter);
663 }
664 
665 
666 string CTableDataSNP::GetHtmlValue(size_t row, size_t col) const
667 {
668  list<string> values;
669  string sDelimiter(", ");
670  if (row < GetRowsCount()) {
671  CConstRef<CVariation> pVariation(x_GetRowData(row));
672  bool isProp(pVariation->CanGetVariant_prop());
673  CSnpBitfield bf;
674  if(pVariation->CanGetExt()) {
675  const CVariation::TExt& Ext(pVariation->GetExt());
676  ITERATE(CVariation::TExt, iExt, Ext) {
677  if((*iExt)->CanGetClass() &&
678  (*iExt)->GetClass() == SNP_VAR_EXT_CLASS &&
679  (*iExt)->GetFieldRef(SNP_VAR_EXT_BITFIELD).NotEmpty() &&
680  (*iExt)->GetFieldRef(SNP_VAR_EXT_BITFIELD)->CanGetData() &&
681  (*iExt)->GetFieldRef(SNP_VAR_EXT_BITFIELD)->GetData().IsOs()) {
682  bf = (*iExt)->GetFieldRef(SNP_VAR_EXT_BITFIELD)->GetData().GetOs();
683  }
684  }
685  }
686  bool isBitfield(bf.GetVersion() > 0);
687 
688  switch(col){
689  case eRsId:
690  {
691  string sValue;
692  string sURL(pVariation->GetId().GetUrl());
693  if(pVariation->GetId().CanGetTag()) {
694  CNcbiOstrstream ostr;
695  pVariation->GetId().GetTag().AsString(ostr);
696  sValue = CNcbiOstrstreamToString(ostr);
697  } else
698  pVariation->GetId().GetLabel(&sValue);
699 
700  if(sURL.empty())
701  values.push_back(sValue);
702  else
703  values.push_back("<a href=\"" + sURL + "\">" + sValue + "</a>");
704  break;
705  }
706  case eResourceLink:
707  {
708  list<string> Texts;
709  list<string> URLs;
710  sDelimiter = "<br>";
711  if(isProp) {
713  pVariation->GetVariant_prop(),
716  pVariation->GetVariant_prop(),
718  }
719  //!! no representation in CVariantProperties for eHasPubmedArticle, so use bitfield
720  if(isBitfield && bf.IsTrue(CSnpBitfield::eHasPubmedArticle)) {
721  Texts.push_back("PubMed Central article");
722  URLs.push_back("");
723  }
724  //!! no representation in CVariantProperties for eHasShortReadArchive, so use bitfield
725  if(isBitfield && bf.IsTrue(CSnpBitfield::eHasShortReadArchive)) {
726  Texts.push_back("Short Read Archive");
727  URLs.push_back("");
728  }
729  //!! no representation in CVariantProperties for eHasOrganism, so use bitfield
730  if(isBitfield && bf.IsTrue(CSnpBitfield::eHasOrganism)) {
731  Texts.push_back("OrganismDBLink");
732  URLs.push_back("");
733  }
734  //!! no representation in CVariantProperties for eFromMgcClone, so use bitfield
735  if(isBitfield && bf.IsTrue(CSnpBitfield::eFromMgcClone)) {
736  Texts.push_back("From MGC clone");
737  URLs.push_back("");
738  }
739  //!! no representation in CVariantProperties for eHasTrace, so use bitfield
740  if(isBitfield && bf.IsTrue(CSnpBitfield::eHasTrace)) {
741  Texts.push_back("Trace Archive");
742  URLs.push_back("");
743  }
744  //!! no representation in CVariantProperties for eHasAssembly, so use bitfield
745  if(isBitfield && bf.IsTrue(CSnpBitfield::eHasAssembly)) {
746  Texts.push_back("Assembly Archive");
747  URLs.push_back("");
748  }
749  //!! no representation in CVariantProperties for eHasGEO, so use bitfield
750  if(isBitfield && bf.IsTrue(CSnpBitfield::eHasGEO)) {
751  Texts.push_back("Entrez GEO");
752  URLs.push_back("");
753  }
754  //!! no representation in CVariantProperties for eHasProbeDB, so use bitfield
755  if(isBitfield && bf.IsTrue(CSnpBitfield::eHasProbeDB)) {
756  Texts.push_back("ProbeDB");
757  URLs.push_back("");
758  }
759  //!! no representation in CVariantProperties for eHasEntrez, so use bitfield
760  if(isBitfield && bf.IsTrue(CSnpBitfield::eHasEntrez)) {
761  Texts.push_back("Entrez Gene");
762  URLs.push_back("");
763  }
764  //!! no representation in CVariantProperties for eHasSTS, so use bitfield
765  if(isBitfield && bf.IsTrue(CSnpBitfield::eHasSTS)) {
766  Texts.push_back("Entrez STS");
767  URLs.push_back("");
768  }
769  // scan and replace the URL subst fields
770  // use all existing sResourceLink_ values to cover all cases
771  // from those and texts, form full URLs
772  list<string>::const_iterator iTexts(Texts.begin());
773  ITERATE(list<string>, iURLs, URLs) {
774  string sFullURL(NStr::Replace(*iURLs,
777 
778  if(sFullURL.empty()) {
779  // values.push_back(*iTexts); -- values w/o an actual URL are disabled per SNP-4726
780  } else
781  values.push_back("<a href=\"" + sFullURL + "\">" + *iTexts + "</a>");
782  ++iTexts;
783  }
784  break;
785  }
786 /* case ePopFreq: -- dropped as asked in SNP-4726
787  if(isProp &&
788  pVariation->GetVariant_prop().CanGetGenotype() &&
789  pVariation->GetVariant_prop().GetGenotype() & CVariantProperties::eGenotype_has_genotypes) {
790  values.push_back("<a href=\""
791  "http://www.ncbi.nlm.nih.gov/sites/entrez?cmd=Retrieve&db=Snp&dopt=GEN&list_uids=" +
792  NStr::LongToString(GetIntValue(row, eRsId)) +
793  "\">GTY</a>");
794  }
795  break;
796 */
797  case eFXNClass:
798  if(isProp) {
799  list<string> GeneLocations;
801  pVariation->GetVariant_prop(),
803  list<string> Effects;
805  pVariation->GetVariant_prop(),
807  string sURL(!Effects.empty()
808  ?
809  pVariation->GetId().GetUrl() + "#locus"
810  :
811  "http://www.ncbi.nlm.nih.gov/sites/entrez?"
812  "Db=gene&DbFrom=snp&Cmd=Link&LinkName=snp_gene&LinkReadableName=Gene&"
813  "IdsFromResult=" +
815  ITERATE(list<string>, iGeneLocations, GeneLocations) {
816  values.push_back("<a href=\"" + sURL + "\">" + *iGeneLocations + "</a>");
817  }
818  ITERATE(list<string>, iEffects, Effects) {
819  values.push_back("<a href=\"" + sURL + "\">" + *iEffects + "</a>");
820  }
821  }
822  break;
823 
824  case ePhenotype:
825  //!! no representation in CVariantProperties for eHasMeSH, so use bitfield
826  if(isBitfield && bf.IsTrue(CSnpBitfield::eHasMeSH)) {
827  values.push_back("MeSH");
828  }
829  //!! no representation in CVariantProperties for eHasClinicalAssay, so use bitfield
830  if(isBitfield && bf.IsTrue(CSnpBitfield::eHasClinicalAssay)) {
831  values.push_back("Clinical diagnostic assay");
832  }
833  //!! no representation in CVariantProperties for eHasTranscriptionFactor, so use bitfield
834  if(isBitfield && bf.IsTrue(CSnpBitfield::eHasTranscriptionFactor)) {
835  values.push_back("Transcription factor");
836  }
837  //!! no representation in CVariantProperties for eHasDiseaseInfo, so use bitfield
838  if(isBitfield && bf.IsTrue(CSnpBitfield::eHasDiseaseInfo)) {
839  bool isLinkFound(false);
840  if(pVariation->CanGetOther_ids()) {
841  const CVariation::TOther_ids& OtherIDs(pVariation->GetOther_ids());
842  ITERATE(CVariation::TOther_ids, iOtherIDs, OtherIDs) {
843  if((*iOtherIDs)->CanGetDb() &&
844  ((*iOtherIDs)->GetDb() == "GeneID" ||
845  (*iOtherIDs)->GetDb() == "LocusLink") &&
846  (*iOtherIDs)->CanGetTag()) {
847  values.push_back("<a href=\""
848  "http://www.ncbi.nlm.nih.gov/sites/varvu?gene=" +
849  NStr::NumericToString((*iOtherIDs)->GetTag().GetId()) +
850  "\">From LSDB</a>");
851  isLinkFound = true;
852  }
853  }
854  }
855  // even if no URL links were found, we need to signify LSDB prsence at least once
856  if(!isLinkFound)
857  values.push_back("From LSDB");
858  }
859  //!! no representation in CVariantProperties for eHasLowdbGaPPValue, so use bitfield
860  if(isBitfield && bf.IsTrue(CSnpBitfield::eHasLowdbGaPPValue)) {
861  values.push_back("p-Value <= 0.001 in dbGaP");
862  }
863  //!! no representation in CVariantProperties for eHasLodScore, so use bitfield
864  if(isBitfield && bf.IsTrue(CSnpBitfield::eHasLodScore)) {
865  values.push_back("LOD score >= 2.0 in dbGaP");
866  }
867  //!! no representation in CVariantProperties for eHasMicroattribution, so use bitfield
868  if(isBitfield && bf.IsTrue(CSnpBitfield::eHasMicroattribution)) {
869  values.push_back("Microattribution");
870  }
871  //!! no representation in CVariantProperties for eHasOMIM_OMIA, so use bitfield
872  if(isBitfield && bf.IsTrue(CSnpBitfield::eHasOMIM_OMIA)) {
873  values.push_back("<a href=\""
874  "http://www.ncbi.nlm.nih.gov/SNP/snp_redirect.cgi?snp_id=" +
876  "\">OMIM/OMIA</a>");
877  }
878  break;
879 
880  default:
881  break;
882  }
883  }
884  return NStr::Join(values, sDelimiter);
885 }
886 
887 
888 
889 
890 long CTableDataSNP::GetIntValue(size_t row, size_t col) const
891 {
892  long value(0);
893  if (row < GetRowsCount()) {
894  CConstRef<CVariation> pVariation(x_GetRowData(row));
895 
896  CSnpBitfield bf;
897  if(pVariation->CanGetExt()) {
898  const CVariation::TExt& Ext(pVariation->GetExt());
899  ITERATE(CVariation::TExt, iExt, Ext) {
900  if((*iExt)->CanGetClass() &&
901  (*iExt)->GetClass() == SNP_VAR_EXT_CLASS &&
902  (*iExt)->GetFieldRef(SNP_VAR_EXT_BITFIELD).NotEmpty() &&
903  (*iExt)->GetFieldRef(SNP_VAR_EXT_BITFIELD)->CanGetData() &&
904  (*iExt)->GetFieldRef(SNP_VAR_EXT_BITFIELD)->GetData().IsOs()) {
905  bf = (*iExt)->GetFieldRef(SNP_VAR_EXT_BITFIELD)->GetData().GetOs();
906  }
907  }
908  }
909  bool isBitfield(bf.GetVersion() > 0);
910  switch(col){
911  case eRsId:
912  {
913  string sValue;
914  if(pVariation->GetId().CanGetTag()) {
915  CNcbiOstrstream ostr;
916  pVariation->GetId().GetTag().AsString(ostr);
917  sValue = CNcbiOstrstreamToString(ostr);
918  } else
919  pVariation->GetId().GetLabel(&sValue);
920 
922  break;
923  }
924  case ePosition:
925  if(pVariation->CanGetPlacements()) {
926  const CVariation::TPlacements& VarPlacements(pVariation->GetPlacements());
927  if(!VarPlacements.empty()) {
928  CRef<CVariantPlacement> pPlacement(VarPlacements.front());
929  if(pPlacement->CanGetLoc())
930  value = pPlacement->GetLoc().GetTotalRange().GetFrom() + 1;
931  }
932  }
933  break;
934  case eWeight:
935  //!! weight conversion from bitfield to CVariantProperties has been disabled (SNP-5729),
936  //!! so use bitfield
937  if(isBitfield) {
938  value = bf.GetWeight();
939  }
940 /* if(pVariation->CanGetVariant_prop() &&
941  pVariation->GetVariant_prop().CanGetMap_weight()) {
942  value = pVariation->GetVariant_prop().GetMap_weight();
943  }
944 */ break;
945  }
946  }
947  return value;
948 }
949 
950 
951 double CTableDataSNP::GetRealValue(size_t row, size_t col) const
952 {
953  double value = 0.0;
954  return value;
955 }
956 
957 
959 {
960  return GetRowObject(row);
961 }
962 
963 
965 {
967  if(m_DataLoadStatus == eReady && row < GetRowsCount()) {
968  value.scope = m_Scope;
969  value.object = x_GetRowData(row);
970  }
971  return value;
972 }
973 
974 
976 {
977  return row < m_listSnps->GetData().size() ? m_listSnps->GetData()[row] : CConstRef<CVariation>();
978 }
979 
980 
982 
static string LongToString(long value, TNumToStringFlags flags=0, int base=10)
Convert Int to string.
Definition: ncbistr.hpp:5164
Has OrganismDBLink (Ex. Jackson Lab for mouse)
CAppJobDispatcher.
virtual long GetIntValue(size_t row, size_t col) const
bool CanGetTag(void) const
Check if it is safe to call GetTag method.
Definition: Dbtag_.hpp:245
templatized IEventAttachment wrapper
Definition: event.hpp:59
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
Definition: ncbiobj.hpp:970
const TVariant_prop & GetVariant_prop(void) const
Get the Variant_prop member data.
bool CanGetExt(void) const
Check if it is safe to call GetExt method.
virtual string GetColumnLabel(size_t col) const
CConstRef< objects::CVariation > x_GetRowData(size_t row) const
static string & Replace(const string &src, const string &search, const string &replace, string &dst, SIZE_TYPE start_pos=0, SIZE_TYPE max_replace=0)
Replace occurrences of a substring within a string.
Definition: ncbistr.cpp:3190
virtual size_t GetColsCount() const
Has EntrezGene Query Entrez to get the current links.
vector< CRef< objects::CVariation > > TSnpDataList
Do not throw an exception on error.
Definition: ncbistr.hpp:252
list< CRef< CUser_object > > TExt
TObjectType & SetData(void)
provide non-const access to the packaged data
Definition: event.hpp:65
generate URL templates, with one of sResourceLink_ substrings potentially inside
Definition: snp_utils.hpp:281
const TOther_ids & GetOther_ids(void) const
Get the Other_ids member data.
delta=[morph of length >1]
virtual bool Send(CEvent *evt, EDispatch disp_how=eDispatch_Default, int pool_name=ePool_Default)
Sends an event synchronously.
User-defined methods of the data storage class.
virtual SConstScopedObject GetObjectValue(size_t row, size_t col) const
ostream & AsString(ostream &s) const
Definition: Object_id.cpp:169
virtual EJobState Run()
Function that does all the useful work, called by the Engine.
#define END_EVENT_MAP()
Ends definition of Command Map.
virtual CConstIRef< IAppJobProgress > GetProgress()
return progress object, the function shall be synchronized internally.
void SetNormDone(float done)
CConstRef< CDbtag > GetNamedDbxref(const CTempString &db) const
Return a specified DB xref.
Definition: Seq_feat.cpp:377
virtual bool IsCanceled() const
TRange GetTotalRange(void) const
Definition: Seq_loc.hpp:895
API (CDeflineGenerator) for computing sequences' titles ("definitions").
const TLoc & GetLoc(void) const
Get the Loc member data.
SAnnotSelector –.
Base class to build jobs with cancel functionality.
CConstRef< CObject > object
Definition: objects.hpp:80
static objects::SAnnotSelector GetAnnotSelector(TAnnotFlags flags=0)
request an annotation selector for a given type
Definition: utils.cpp:154
#define kEmptyStr
Definition: ncbistr.hpp:120
TOther_ids & SetOther_ids(void)
Assign a value to Other_ids data member.
return the "best" gi (uses FindBestScore(), with CSeq_id::CalculateScore() as the score function ...
Definition: sequence.hpp:99
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:893
static long StringToLong(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to long.
Definition: ncbistr.cpp:554
TJobID StartJob(IAppJob &job, const string &engine_name, IEngineParams *params=NULL)
Starts a Job on the specified engine in "passive mode" - no notifications or progress reports will be...
! temp here for backward compatibility; remove once a jump to SC11 is done
string GetUrl(void) const
Definition: Dbtag.cpp:702
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:101
virtual void SetAttachment(IEventAttachment *att, EOwnershipPolicy policy)
attach an object to the Event
Definition: event.cpp:90
prop.frequence-based-validation
Definition: snp_utils.hpp:272
void GetLabel(string *label, ELabelType type=eDefault, TLabelFlags flags=fLabel_Default) const
Definition: Seq_id.cpp:1406
EJobState
Job states (describe FSM)
Definition: app_job.hpp:86
CAppJobNotification Notification send by CAppJobEventTranslator.
const TPlacements & GetPlacements(void) const
Get the Placements member data.
EDataLoadStatus m_DataLoadStatus
const char * tag
CFeat_CI –.
Definition: feat_ci.hpp:63
virtual string GetHtmlValue(size_t, size_t) const
#define NCBI_DEVELOPMENT_VER
delete object when ownership end
Definition: event.hpp:114
static const string s_ColNames[]
bool DeleteJob(TJobID job_id)
when a Job is deleted the listener is not notified
CConstRef< CSeq_loc > m_Loc
Has ProbeDB Query Entrez to get the current links.
bool CanGetOther_ids(void) const
Check if it is safe to call GetOther_ids method.
bool CanGetData(void) const
Check if it is safe to call GetData method.
void GetLabel(string *label) const
Definition: Dbtag.cpp:323
list< CRef< CVariantPlacement > > TPlacements
static const size_t c_MaxRows
CRef< CObjectFor< TSnpDataList > > m_listSnps
const TId & GetId(void) const
Get the Id member data.
CEventAttachmentFor< CIRef< ITableData > > TDataAttachment
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
Definition: ncbidiag.hpp:198
int size
virtual void GetStringValue(size_t row, size_t col, string &value) const
From MGC clone We have ~20K rs. This bit could be set from specific submitter handle/ batch_id...
static string Join(const list< string > &arr, const CTempString delim)
Join strings using the specified delimiter.
Definition: ncbistr.cpp:3633
CConstRef< objects::CSeq_loc > m_OrigLoc
size_t GetSize(void) const
virtual bool IsHtmlColumn(size_t col) const
CConstRef< CSeq_feat > GetBestOverlapForSNP(const CSeq_feat &snp_feat, CSeqFeatData::E_Choice type, CScope &scope, bool search_both_strands=true)
Get the best overlapping feature for a SNP (variation) feature.
Definition: sequence.cpp:1244
char value[7]
Definition: config.c:428
CRef< CScope > m_Scope
TType GetType(void) const
Get the Type member data.
Has Assembly Query Entrez to get the current links.
USING_SCOPE(objects)
const TExt & GetExt(void) const
Get the Ext member data.
CConstRef< CSeq_id > GetSeqId(void) const
position_type GetFrom(void) const
Definition: range.hpp:134
CSeq_id_Handle GetIdHandle(const CSeq_loc &loc, CScope *scope)
void Error(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1014
virtual ColumnType GetColumnType(size_t col) const
virtual CRef< CObject > GetResult()
Returns the Job Result.
CRef< CObject > m_listSnps
vector< SConstScopedObject > TConstScopedObjects
Definition: objects.hpp:103
CTableDataSNPJob(CScope &scope, const CSeq_loc &loc)
virtual string GetDescr() const
Returns a human readable description of the Job (optional)
CScope –.
Definition: scope.hpp:90
int GetVersion() const
delta=[morph of length 1] NOTE: this is snV not snP; the latter requires frequency-based validation t...
User-defined methods of the data storage class.
static const string sResourceLink_RsID
Definition: snp_utils.hpp:263
const CSeq_id & GetId(const CSeq_loc &loc, CScope *scope)
If all CSeq_ids embedded in CSeq_loc refer to the same CBioseq, returns the first CSeq_id found...
CObjectFor –.
Definition: ncbiobj.hpp:2023
User-defined methods of the data storage class.
Has GEO Query Entrez to get the current links.
delta=[del, ins.seq= repeat-unit with fuzzy multiplier] variation-location is the microsat expansion ...
static CRef< CScope > m_Scope
virtual CConstIRef< IAppJobError > GetError()
Returns IAppJobError object describing internal error that caused the Job to fail.
static void VariantPropAsStrings(list< string > &ResList, const CVariantProperties &prop, ESNPPropTypes ePropType)
get lists of strings corresponding to a given property type
Definition: snp_utils.cpp:489
#define ON_MESSAGE(type, id, handler)
#define SNP_VAR_EXT_CLASS
Definition: snp_utils.hpp:227
const CSeq_feat & GetOriginalFeature(void) const
Get original feature with unmapped location/product.
CEventHandler.
virtual SConstScopedObject GetRowObject(size_t row) const
virtual size_t GetRowsCount() const
bool CanGetPlacements(void) const
Check if it is safe to call GetPlacements method.
virtual double GetRealValue(size_t row, size_t col) const
IO_PREFIX::ostrstream CNcbiOstrstream
Portable alias for ostrstream.
Definition: ncbistre.hpp:163
#define _ASSERT
list< CRef< CDbtag > > TOther_ids
const TTag & GetTag(void) const
Get the Tag member data.
Definition: Dbtag_.hpp:251
CSnpBitfield is a facade for representing any version of the SNP bitfield.
#define SNP_VAR_EXT_BITFIELD
Definition: snp_utils.hpp:228
virtual ~CTableDataSNPJob()
namespace ncbi::objects::
Definition: Seq_feat.hpp:55
const TInstance & GetInstance(void) const
Get the variant data.
Definition: Variation_.cpp:197
CRef< CObject > GetJobResult(TJobID job_id)
User-defined methods of the data storage class.
#define const
Definition: zconf.h:217
#define BEGIN_EVENT_MAP(thisClass, baseClass)
Begins definition of Command Map for CEventHandler-derived class.
IAppJobListener Interface for components that need to be notified about changes in Jobs...
CRef< objects::CScope > m_Scope
Has Trace Query Entrez to get the current links.
TJobState GetState() const
static bool ConvertFeat(CVariation &Variation, const CSeq_feat &SrcFeat)
legacy SNP feature conversion into a variation object
Definition: snp_utils.cpp:290
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:98
const TData & GetData(void) const
Get the Data member data.
static CAppJobDispatcher & GetInstance()
T & GetData(void)
Get data as a reference.
Definition: ncbiobj.hpp:2038
void OnJobNotification(CEvent *evt)
bool CanGetVariant_prop(void) const
Check if it is safe to call GetVariant_prop method.
Has STS Query Entrez to get the current links.
static string NumericToString(TNumeric value, TNumToStringFlags flags=0, int base=10)
Convert numeric value to string.
Definition: ncbistr.hpp:4370
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:756
bool IsInstance(void) const
Check if variant Instance is selected.
CAppJobProgress Default implementation for IAppJobProgress - the class encapsulates a text message an...
CRef< CAppJobError > m_Error
int GetWeight() const
CRef< objects::CScope > scope
Definition: objects.hpp:81
Modified on Mon Aug 29 19:42:06 2016 by modify_doxy.py rev. 506947