Feature/35869/st georges importer#77
Conversation
| genotypes.append(genotype) | ||
| end | ||
| end | ||
| genotype.add_test_scope(:no_genetictestscope) |
There was a problem hiding this comment.
Unknown scope has been added here @lauramccluskey1 but not considered while processing the records ? Should you be having an else condition for these cases to be processed in fill_genotypes?
There was a problem hiding this comment.
Great spot @shilpigoeldev! I have just spoke to Fiona about this as its not clear what to do in this instance for st georges. She said that as there were no cases with no genetictestscope, this should give a big error instead. This means that if we see any cases in future new rules can be created. So I will add this as a logger message. @NImeson this applies to colorectal too
| process_variants(single_genotype, record) | ||
| @persister.integrate_and_store(single_genotype) | ||
| end | ||
| genotypes |
There was a problem hiding this comment.
I needed it to be able to test the unittests for that function
| genotype.attribute_map['organisationcode_testresult'] = '697N0' | ||
| end | ||
| # records using new importer should only have SRIs starting with V | ||
| return unless record.raw_fields['servicereportidentifier'].start_with?('V') |
There was a problem hiding this comment.
return statement should be the first one, no need to create genotype object if we are not processing file @lauramccluskey1
| genotype.add_status(1) | ||
| # variant dna is not '*Fail*', 'N' or null AND raw:gene is not null AND raw:gene (other) is null | ||
| # 2 (abnormal) for gene in raw:gene. 1 (normal) for all other genes. | ||
| elsif record.raw_fields['gene'].present? \ |
There was a problem hiding this comment.
You don't need backslashes for continuation here (and throughout the file) , it can be written as -
record.raw_fields['gene'].present? &&
record.raw_fields['gene (other)'].blank?
There was a problem hiding this comment.
If I remove the backslashes my tests fail and I get "syntax error, unexpected &&"
There was a problem hiding this comment.
@lauramccluskey1 Did you move && operator to first line ?, below will work
def interrogate_variant_dna_column(record, genotype, genes, column, gene)
# For full screen tests only- add test status when variant dna column is not empty
if record.raw_fields['variant dna'].match(/Fail/ix)
genotype.add_status(9)
elsif record.raw_fields['variant dna'] == 'N'
genotype.add_status(1)
# variant dna is not '*Fail*', 'N' or null AND raw:gene is not null AND raw:gene (other) is null
# 2 (abnormal) for gene in raw:gene. 1 (normal) for all other genes.
elsif record.raw_fields['gene'].present? && record.raw_fields['gene (other)'].blank?
update_status(2, 1, column, 'gene', genotype)
# variant dna is not '*Fail*', 'N' or null AND raw:gene is not null AND raw:gene (other) is not null
# 2 (abnormal) for gene in raw:gene.
# 9 (failed, genetic test) for any gene specified WITH 'Fail' in raw:gene (other).
# 1 (normal) for all other genes
elsif record.raw_fields['gene'].present? && record.raw_fields['gene (other)'].present?
if column == 'gene'
genotype.add_status(2)
elsif column == 'gene (other)'
match_fail(gene, record, genotype)
else
genotype.add_status(1)
end
# variant dna not '*Fail*', 'N' or null AND raw:gene is null AND raw:gene(other) not a single gene
# If gene is specified in raw:variant dna, assign 2 (abnormal) for that gene and 1 (normal) for
# all other genes.
# Else interrogate raw:gene (other).
elsif record.raw_fields['gene'].blank? && (genes['gene (other)'].blank? ||
genes['gene (other)'].length > 1) && !genes['variant dna'].nil? &&
genes['variant dna'].length >= 1
update_status(2, 1, column, 'variant dna', genotype)
# variant dna is not '*Fail*', 'N' or null AND raw:gene is null AND raw:gene (other) specifies a single gene
# 2 (abnormal) for gene in raw:gene (other). 1 (normal) for all other genes.
elsif record.raw_fields['gene'].blank? && !genes['gene (other)'].nil? && genes['gene (other)'].length == 1
update_status(2, 1, column, 'gene (other)', genotype)
end
end
There was a problem hiding this comment.
Thanks @shilpigoeldev - updated in 960d753
| def positive_exonvariant?(record) | ||
| variant = record.raw_fields['genotype'] | ||
| variant.scan(EXON_VARIANT_REGEX).size.positive? | ||
| def match_fail(gene, record, genotype) |
There was a problem hiding this comment.
this method can be refactored -
def match_fail(gene, record, genotype)
# Determines if a gene in the gene (other) column has failed
# Assigns genes that have failed a test status of 9, otherwise teststatus is 1
gene_list = record.raw_fields['gene (other)'].scan(BRCA_GENE_REGEX)
return false if gene_list.empty?
gene_list.each do |gene_value|
mapped_gene_values = BRCA_GENE_MAP[gene_value] || []
mapped_gene_values.each do |value|
if value == gene
status = /#{gene_value}\s?\(?fail\)?/i.match?(record.raw_fields['gene (other)']) ? 9 : 1
genotype.add_status(status)
end
end
end
true
end
| process_failed_gene_other(genes, genotype, genotypes, remaining_genes) | ||
| when /\?\z/i | ||
| process_status_genes(genotype, 4, genes['gene'], genotypes) | ||
| when /^c\.|^Ex.*Del\z|^Ex.*Dup\z|^Het\sDel|^Het\sDup/ix |
There was a problem hiding this comment.
As confirmed by Fiona, regex needs to account for e.g. 'Hetdel' entries as well, it's currently assigning this as test status 4 but needs to be 2.
What?
A new St Georges importer has been written to account for a new data format (see planio ticket 35869). The old St Georges importer is still needed, so it has been kept in the repository.
Why?
St Georges changed the format of the data being sent. Therefore, a new importer had to be created to be able to parse this format.
How?
The importer was written based on the rules sent by Fiona.
Testing?
Unittests have been written. A QA of the variant counts has also been completed and signed off by Fiona.