You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Calculate the Number of Gap Positions in a Sequence Alignment (and Coverage) #491
I have not found a way to easily calculate the number of gap positions in a sequence alignment. I was using the function AlignedSequence.getNumGaps(), which is said to return the number of gaps in the sequence, but actually returns the number of gap openings (without taking the length of the gap into account), which I found it a bit confusing.
I think it could be useful to have a function AlignedSequence.getNumGapPositions() that returns the total number of gaps (with symbol -) in the aligned sequence and documents properly the differences with the other function.
The applications of such a function would be to calculate the coverage of the sequence alignment on one of the aligned sequences. I also could not find a function to calculate coverage, but it should be easily calculated from the original sequence length, the alignment length and the number of gap positions:
Coverage = ( alignment length - number of gap positions ) / sequence length
Here some code to calculate alignment overlaps and over scores. It would be good to add a couple of utility methods for this. In particular the replaceAll("-",""); on the aligned sequence representation is rather ugly...
Thanks @andreasprlic. I ended up using the method AlignedSequence.getSequenceAsString() and counting the number of "-" positions, which is similar to what you proposed here, but it would be nicer (and optimal) to have a method that counts internally the number of gap positions (and maybe others that calculate coverage and sequence identity from AlignedSequence directly).
Another concern in using the getSequenceAsString and counting "-" is that there might be an implementation of AlignedSequence where gaps are represented by another symbol, so it is not completely safe. Internally the CompoundGAP is used, so this is safe to count those.
I will make a pull request with the new methods and create some tests.
Activity
andreasprlic commentedon May 23, 2016
Here some code to calculate alignment overlaps and over scores. It would be good to add a couple of utility methods for this. In particular the
replaceAll("-","");on the aligned sequence representation is rather ugly...lafita commentedon May 24, 2016
Thanks @andreasprlic. I ended up using the method
AlignedSequence.getSequenceAsString()and counting the number of "-" positions, which is similar to what you proposed here, but it would be nicer (and optimal) to have a method that counts internally the number of gap positions (and maybe others that calculate coverage and sequence identity fromAlignedSequencedirectly).Another concern in using the
getSequenceAsStringand counting "-" is that there might be an implementation ofAlignedSequencewhere gaps are represented by another symbol, so it is not completely safe. Internally theCompoundGAP is used, so this is safe to count those.I will make a pull request with the new methods and create some tests.
Method for percentage of identity of a sequence pair biojava#491
Method for total gapped positions and coverage in aligned sequences
Implement tests for new utility methods in sequence objects biojava#491
Merge branch 'master' of github.com:biojava/biojava