frequency of letters at position in string [closed] - string

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want to count the frequency of 4 letters at every position across strings. The letters are A, T, G, C
TGAGGTAGTAGTTTGTGCTGTTAT
TAGTAGTTTGTGCTGTTA
TGAGGTAGTAGTTTGTAC
TGAGAACTGAATTCCATAGG
desired output:
Pos1 Pos2 Pos3 and so on.
A 0 1
T 4 0
C 0 0
G 0 3
So far I have used an R package called Biostrings, which works, but I wonder if perl would do this?

For the record, for
x = "TGAGGTAGTAGTTTGTGCTGTTAT
TAGTAGTTTGTGCTGTTA
TGAGGTAGTAGTTTGTAC
TGAGAACTGAATTCCATAGG"
a Biostrings solution is
library(Biostrings)
consensusMatrix(DNAStringSet(strsplit(x, "\n")[[1]]))
which will be fast for millions of sequences.

Related

I could not understand this question for practicing python [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 10 months ago.
Improve this question
Could anyone please help me in understanding the question for this.
I got this from https://www.geeksforgeeks.org/python-program-for-nth-multiple-of-a-number-in-fibonacci-series/
Given two integers n and k. Find position the n\’th multiple of K in the Fibonacci series.
Examples:
Input : k = 2, n = 3
Output : 9
3'rd multiple of 2 in Fibonacci Series is 34
which appears at position 9.
Input : k = 4, n = 5
Output : 30
5'th multiple of 5 in Fibonacci Series is 832040
which appears at position 30.
You are interested in the numbers that are divisible by k in the fibonacci sequence. Among these numbers, you seek the index of the nth, that is, the index i such that the ith fibonacci number is divisible by k, and such that there are exactly n-1 fibonacci numbers before that one that are also divisible by k.

How Do I Calculate The Difference of Each Element in A List (Python) [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I'm new to Python and I wanted to know that how can I subtract All the Elements in A List in Python
For Eg -
list [5,6,7,8,9]
I want to subtract it like this = 5 - 6 - 7 - 8 - 9
Use reduce, which expands out to subtracting all elements.
>>> from functools import reduce
>>> reduce(lambda x, y: x - y, [5,6,7,8,9])
-25
To subtract each number from the first one, you can subtract the sum of them:
>>> mylist = [5,6,7,8,9]
>>> print(mylist[0] - sum(mylist[1:]))
-25

How to convert column entries to binary (0 or 1) from dates? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
In the date_died column of the dataset, I want to convert the column into a column with the heading 'Survived' where: if date_died is 9999-99-99 then survived = 1 else survived = 0 [1]. I want to use that column as my output data frame. I am an absolute beginner at ML and python.
You can use np.where for this,
df['Survived'] = np.where(df['date_died'].eq("9999-99-99"), 1, 0)
See a dummy example below,
df['date_died'] = ['9999-99-99', '9999-99-99', '2020-02-14', '2020-03-10', np.nan]
df['Survived'] = np.where(df['date_died'].eq("9999-99-99"), 1, 0)
df
date_died Survived
0 9999-99-99 1
1 9999-99-99 1
2 2020-02-14 0
3 2020-03-10 0
4 NaN 0
If you want to make Survived as 1 when date_died is np.nan, then you can change the code slightly as shown below,
df['Survived'] = np.where((df['date_died'].eq("9999-99-99")) | (df['date_died'].isna()), 1, 0)

I want to make a loop checking for pairs VBA [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I have a project involving checking for pairs in a column. I´m a beginner so I tried
If a = b Then
Par = Par + 1
End If
If a = c Then
Par = Par + 1
End If
If a = d Then
Par = Par + 1
End If
etc etc but if I want this to work I´ll have to repeat this code 36 times...
Is there an easy loop for this?
Here is a simple way that might meet your needs.
Imagine a simple table in range A1:B5
A B
1 aa aa
2 cc bb
3 ee cc
4 gg dd
5 hh ee
Here we have three pairs aa & aa, cc & cc, ee & ee.
This formula will count the number of pairs:
=SUMPRODUCT(COUNTIF(A1:A5,B1:B5)) // = 3

how much string that length is n can we create from A and B that string will not contain two A consecutively [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
how much string that length is n can we create from A and B that string will not contain two A consecutively.
For example;
if n=1 , strings are A ve B => it has 2 solutions
if n=2 , strings are AB, BA, BB => it has 3 solutions
in n=3 , strings are ABB, ABA, BAB, BBA, BBB => it has 5 solutions ... etc.
I need a decrease and conquer algorithm , can you help me please ?
if n=1, result[1] = 2
if n=2, result[2] = 3
if n=3, result[3] = 5
if n=4, result[4] = 8
if n=5, result[5] = 13
so, this generates a Fibonacci sequence.
result[1] = 2
result[2] = 3
result[n] = result[n-1]+result[n-2];
Closed form of Fibonacci sequence:

Resources