This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Pull Alignment Character Position

Hi,

I use pairwise align to get the following:

> alignment <-pairwiseAlignment(pattern = canonical.protein, subject=protein.extracted)
> alignment
Global PairwiseAlignedFixedSubject (1 of 1)
pattern: [448]          DDWEIPDGQITVGQRIGSGSFGTVYKGKWHGDVAVKMLNVTAPTPQQLQAFKNEVGV...FMVGRGYLSPDLSKVRSNCPKAMKRLMAE  CLKKKRDERPLFPQILASIELLARSLPK 
subject:   [1]     DDWEIPDGQITVGQRIGSGSFGTVYKGKWHGDVAVKMLNVTAPTPQQLQAFKNEVGV...FMVGRGYLSPDLSKVRSNCPKAMKRLMAECLKKKRDERPLFPQILASIELLARSLPK 
score: -912.3752

I can then use as.character(pattern(alignment)) and as.character(subject(alignment)) to get the full string sequence. However, how do I ge tthe number 448 and 1 out of the object as an integer?? Thanks!

r bioconductor

1 answer

In your question on stackoverflow you say you can make them to string. If you make a string out of the alignments you can use R's string functions: you can do substr(toString(pattern(alignment)), 448, 448) to get the 448th character. I'm not familiar with that library so there might be an inbuilt way that I don't know of. See http://www.statmethods.net/management/functions.html for string functions in R.

Log in to answer this question.