Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CramSource get_info should return single dict instead of list with only one dict in it. #23

Open
grosscol opened this issue May 11, 2023 · 1 comment
Labels
triage Landing area for issues discovered during development.

Comments

@grosscol
Copy link
Collaborator

Issue or current state

The get_info method of the legacy sequences hander returned a list with a single dictionary in it. The CramSource class mirrors this behavior to keep the API the same.

Resolved when

Change made in CramSource and subclasses:

  • return dictionary instead of list
  • return empty dict when no matching variant is found in variant_map.

Corresponding issue made in Bravue project.

Note about Bravue

The relevant code in the UI is in src/components/Reads.vue. An issue will have to be filed there and the changes to the API reflected in the data processing on the UI side.

     .get(`${this.api}/variant/api/snv/cram/summary/${this.variant.variant_id}`)
      .then( response => {
        var result = response.data;
        if (result.data.length > 0) {
          var counts = result.data[0];
          this.counts.n_homs = counts.n_homozygous;
          this.counts.n_hets = counts.n_heterozygous;
        }
@grosscol grosscol added the triage Landing area for issues discovered during development. label May 11, 2023
@grosscol
Copy link
Collaborator Author

grosscol commented Sep 26, 2023

Relevant function in api:

def het_hom_counts(tabix_file, chrom, pos, ref, alt):
result = []
for row in tabix_file.fetch(chrom, pos - 1, pos):
if int(row[1]) == pos and row[2] == ref and row[3] == alt:
result.append({
'n_homozygous': len(row[4].split(',')) if row[4] else 0,
'n_heterozygous': len(row[5].split(',')) if row[5] else 0
})
break
return result

called from:

def get_sequences_info(variant_map, chrom, pos, ref, alt):
with pysam.TabixFile(str(variant_map), parser=pysam.asTuple()) as itabix:
return FSCramSource.het_hom_counts(itabix, chrom, pos, ref, alt)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage Landing area for issues discovered during development.
Projects
None yet
Development

No branches or pull requests

1 participant