Question: Splitting a fasta file based on specific Amino acid for plotting
gravatar for Assa Yeroslaviz
16 months ago by
Assa Yeroslaviz1.3k
Munich, Germany
Assa Yeroslaviz1.3k wrote:

Hi all after a few days of searching and trial & error I would like to ask for your help.

I have a protein sequence, let's say this one (one line):


I would like to split the protein after each occurrence of a specific AA, let's say "K" ( the cleavage point of trypsin) so that I will get a list or an IRanges object with the start and end positions) with these elements:


Using IRanges and matchPattern(), I was only able to create an object of the pattern I'm looking for, but not of the sub-sequence.

Than I would like to plot these subsequences onto the complete sequence of the protein

The end goal of my analysis is to plot the protein sequence (x-axis) against all cleavage patterns (Y-axis)

which should then looks like the attached image

the bottom line represents the protein, each of rows above stands for one specific peptide. The Idea is to calculate which protease or combination of proteases gives the highest coverage of the protein in question. 

I would really like to know if there are any packages out there dealing with this kind of questions/problems as I have not found any. 

Hope I have made myself clear enough and of course for any help I can get. Thanks a lot in advance



ADD COMMENTlink modified 16 months ago by Michael Lawrence9.9k • written 16 months ago by Assa Yeroslaviz1.3k
gravatar for Michael Lawrence
16 months ago by
United States
Michael Lawrence9.9k wrote:

matchPattern() returns a Views object, which is the combination of the underlying sequence and the matching ranges. We need to convert the ranges so that the sequence is partitioned, where the position of the match is the end of each partition.

hits <- matchPattern("K", protein1)
subseqs <- PartitioningByEnd(end(hits))

As for visualizing it, I don't have any good solutions. I tried using ggbio and Gviz but both are pretty disappointing.


ADD COMMENTlink written 16 months ago by Michael Lawrence9.9k

thanks for the response. That works very nicely. I do have though a follow-up question. 

Is it possible to use multiple pattern in this case?

I have tried this code, but I get NONE as a result:

>toMatch <-c("K", "R")
>hits <- matchPattern(pattern=paste(toMatch,collapse="|"), protein1)
  Views on a 119-letter AAString subject
views: NONE

I have also tried to convert the two letters into a AAStringSet object, the matchpattern() takes only XString object and not a set.

Is there a different way to do it?

thanks again


ADD REPLYlink written 16 months ago by Assa Yeroslaviz1.3k

Do you want to know where each individual pattern matches, or is there actual ambiguity? It looks like Biostrings does not have a lot of support for matching amino acid strings. For example, neither matchPDict() nor matchPattern(fixed=FALSE) support AAStringSet. I think the latter would be easy to support?

ADD REPLYlink written 16 months ago by Michael Lawrence9.9k

Some protease cleave the sequence after two different AA, in my case these two are "K" and "R". So I basically want to find all the positions where either K or R are and cut there. 

Is there a way to also extract the sequences themselves when doing it (for now for one pattern)? I would like to have not only the IRanges object with the positions, but also the sub-sequences if possible.

ADD REPLYlink written 16 months ago by Assa Yeroslaviz1.3k

Getting the subsequences is just:

extractList(protein1, subseqs)
ADD REPLYlink written 16 months ago by Michael Lawrence9.9k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.2.0
Traffic: 160 users visited in the last hour