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

Add metrics to alignment summary (average + std dev length of sequences) #10

Open
sillitoe opened this issue Jun 10, 2020 · 0 comments
Open
Assignees
Labels
enhancement New feature or request

Comments

@sillitoe
Copy link
Collaborator

sillitoe commented Jun 10, 2020

Overview

Want to add two new metrics to describe alignment quality:

  • average sequence length
  • stddev of sequence lengths

Detail

The cath-align-summary script provides some metrics to describe a (FunFam) sequence alignment: number of sequences, alignment length, dops score, gap positions, total positions.

This summary information for each alignment is currently stored in the cathpy.core.util.AlignmentSummary class:

cathpy/cathpy/core/util.py

Lines 527 to 536 in 9e24388

class AlignmentSummary(object):
"""Stores summary information about an alignment."""
def __init__(self, *, path, dops, aln_length, seq_count, gap_count, total_positions):
self.path = path
self.dops = float(dops) if dops is not None else None
self.aln_length = int(aln_length)
self.seq_count = int(seq_count)
self.gap_count = int(gap_count)
self.total_positions = int(total_positions)

This could be changed to include attributes that store average_domain_length and stddev_domain_length.

These AlignmentSummary objects are created by AlignmentSummaryRunner (ie a process that generates an alignment summary for each STOCKHOLM alignment).

We would need to calculate these values and add them to the summary object within that runner:

def run(self):

Making changes

General approach to making changes:

  1. clone this repo
  2. create a new branch (eg called feature/new_alignment_metrics)
  3. add a test to check that your feature is working
    def test_alignment_summary_file(self):
    runner = AlignmentSummaryRunner(
    aln_file=self.merge_sto_file)
    entries = runner.run()
    self.assertEqual(len(entries), 1)
    summary = entries[0]
    self.assertEqual(summary.aln_length, 92)
    self.assertEqual(summary.dops, 88.422)
    self.assertEqual(summary.gap_count, 25228)
    self.assertEqual(summary.total_positions, 64492)
    self.assertEqual(summary.seq_count, 701)
    self.assertEqual(round(summary.gap_per, 2), round(39.12, 2))
  4. add the code to make your new test pass
  5. make sure your changes have not broken anything else (ie run pytest)
  6. commit your changes, push back to origin (GitHub)
  7. make sure your changes have not broken anything else
  8. create a pull request (PR)
  9. someone else (me) reviews the code
  10. code is merged into master branch
  11. we add your name as an official contributor to cathpy :)
@sillitoe sillitoe added the enhancement New feature or request label Jun 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants