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 8 years ago.
Improve this question
I am trying to trim out this particular file and need just the highlighted portion as it contains the data. I have looked at some other scripts but they are written to remove columns of constant value.
The data is:
id=69 rna=**5_8S_rRNA** ntax=61
id=58 rna=**U1** ntax=100
id=56 rna=**U2** ntax=211
id=37 rna=**tRNA** ntax=967
id=75 rna=**Vault** ntax=75
id=53 rna=**RNaseP_nuc** ntax=117
id=57 rna=**RNaseP_bact_a** ntax=306
id=62 rna=**RNaseP_bact_b** ntax=114
id=41 rna=**U3** ntax=26
id=50 rna=**6S** ntax=154
id=84 rna=**DsrA** ntax=5
id=48 rna=**U4** ntax=178
id=46 rna=**SRP_euk_arch** ntax=102
id=46 rna=**U5** ntax=181
id=65 rna=**GcvB** ntax=26
id=71 rna=**Telomerase-vert** ntax=37
id=50 rna=**Telomerase-cil** ntax=20
id=49 rna=**U6** ntax=200
id=43 rna=**Intron_gpI** ntax=30
id=51 rna=**RNase_MRP** ntax=67
id=33 rna=**SECIS** ntax=61
id=90 rna=**Histone3** ntax=64
id=86 rna=**OxyS** ntax=5
id=98 rna=**RRE** ntax=65
id=54 rna=**IRE** ntax=39
id=73 rna=**rne5** ntax=6
id=88 rna=**snoR9** ntax=5
id=91 rna=**GlmZ_SraJ** ntax=21
id=77 rna=**HDV_ribozyme** ntax=33
id=72 rna=**U8** ntax=49
id=87 rna=**7SK** ntax=45
id=78 rna=**VA** ntax=54
id=79 rna=**RNAI** ntax=10
id=98 rna=**FinP** ntax=6
id=82 rna=**Vimentin3** ntax=19
id=74 rna=**S15** ntax=79
I simply wish to keep the items in asterisks, everything else has to go.
If this is on a Linux system, this Perl one-liner will produce the result you require.
perl -ne '/rna=(\S+)/ and print "$1\n"' myfile
If you are on Windows, use
perl -ne "/rna=(\S+)/ and print qq($1\n)" myfile
output
5_8S_rRNA
U1
U2
tRNA
Vault
RNaseP_nuc
RNaseP_bact_a
RNaseP_bact_b
U3
6S
DsrA
U4
SRP_euk_arch
U5
GcvB
Telomerase-vert
Telomerase-cil
U6
Intron_gpI
RNase_MRP
SECIS
Histone3
OxyS
RRE
IRE
rne5
snoR9
GlmZ_SraJ
HDV_ribozyme
U8
7SK
VA
RNAI
FinP
Vimentin3
S15
Related
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
I want to compute the square of mean-square for each element of l
l=[0.02817088, -0.74100320, -0.54062120, -0.24612808, 0.06945337, -0.58415690, -0.51238549,
-0.07862326, -0.42417337, -0.33482340, -0.21339753, -0.03890844, -0.59325371, 0.28154593,
-0.32133359,-0.13534792, 0.14060645, 0.32204972, 0.44438052, -0.21750973,-0.59107599,
-0.60809913]'
k= -0.2224834
sum(l-k)^2/22
I am not sure if sum(l-k)^2/22 is the sum of each (l[j]-k) for j=1,2,...,22?
ans = 2.4223e-14
I guess what you need might be
>> mean((l-k).^2)
ans = 0.10945
Data (You need ... for line continuation if you have data in different lines for l)
l=[0.02817088, -0.74100320, -0.54062120, -0.24612808, 0.06945337, -0.58415690, -0.51238549, ...
-0.07862326, -0.42417337, -0.33482340, -0.21339753, -0.03890844, -0.59325371, 0.28154593, ...
-0.32133359,-0.13534792, 0.14060645, 0.32204972, 0.44438052, -0.21750973,-0.59107599, ...
-0.60809913]'
k= -0.2224834
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
let players = ["Greg", "Jenn", "Steve", "Anthony", "Krista", "Marti", "Erin", "Brandon",].shuffled()
I want to loop over the array and have it print out all pairs after being shuffled... so if the above was the outcome after being shuffled... it would print out
Greg, Jenn
Steve, Anthony
Krista, Marti
Erin, Brandon
you could use this:
if !players.isEmpty {
let arrTpl = stride(from: 1, to: players.count, by: 2).map { (players[$0-1], players[$0]) }
print("\(arrTpl)")
}
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 my while statement, I cannot understand why my output is printed twice ?
I would like to print i only one time, where is my error ?
func fetch2(){
var i: Int = 0
while i <= (self.returned-1) {
let itemLookUp = "https://shopping.yahooapis.jp/ShoppingWebService/V1/json/itemLookup?appid=\(self.appId)&itemcode=\(self.arrayCodeProduct[i])&responsegroup=large"
print(i)
i = i+1
}
}
Here is the output that I obtain :
0
1
2
3
0
1
2
3
Thank you in advance.
It looks like fetch2() is called twice.
Add a print(#function) before you var i and check that fetch2() is not called several times.
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 5 years ago.
Improve this question
I have the vector below:
v={'T','AT','AS','C'};
I would like to see all the possible permutations for this vector. To do so I can use the command below:
p=perms(v)
But I want to go one step further as each of the elements has sub index of 1 to 4, for example, T1,T2,T3,T4 .....C1,C2,C3,C4. I would like to have all the possible permutations with its sub index as see such results
T1,AT1,AS1,C1
C3,AT3,AS3,t3
AS2,AT2,C2,T2
.
.
.
Could you please help me how to do that?
Thanks
You can do this by first using ndgrid to generate a set of indices for all your possible combinations:
v = {'T1', 'AT1', 'AS1', 'C1'; ...
'T2', 'AT2', 'AS2', 'C2'; ...
'T3', 'AT3', 'AS3', 'C3'; ...
'T4', 'AT4', 'AS4', 'C4'};
[ind1, ind2, ind3, ind4] = ndgrid(1:4);
c = [v(ind1(:), 1) v(ind2(:), 2) v(ind3(:), 3) v(ind4(:), 4)];
And c will be a 256-by-4 cell array, as expected (44 combinations). Now you can expand each row by it's total number of permutations using perms like so:
p = perms(1:4);
p = reshape(c(:, p.').', 4, []).';
And p will be a 6144-by-4 cell array, also as expected (24 permutations times 256 combinations).
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 8 years ago.
Improve this question
How many elements have a name longer than 10 characters in xlsx matlab?
I tried this.
[number cities] = xlsread('weather.xlsx', 'city')
if cities{1}<=char(10);
x+1=x;
Your code above only checks to see if the first city has less than 10 characters. Also, char(10) does not make any sense. You are checking to see if the string contained in cities{1} is less than or equal to the character array containing 10.
Because cities is in a cell array, I would use cellfun to first return the length of each city. Then you can use a sum as well as a Boolean condition to help you figure out how many there are that have more than 10 characters.
As such, here is the code:
A = cellfun(#length, cities);
numCitiesMoreThan10 = sum(A > 10);
Here is an example (simulated):
cities = {'New York', 'Los Angeles', 'Toronto', 'Ottawa', 'Sydney', 'Melbourne', ...
'Timbuktu', 'Singapore', 'Mississippi'};
A = cellfun(#length, cities);
numCitiesMoreThan10 = sum(A > 10);
>> numCitiesMoreThan10 =
2
This makes sense, as the only two cities with more than 10 characters (including spaces) are Los Angeles and Mississippi.
Aside
Just learned that cellfun has something built-in that can do this. You can also do:
A = cellfun('size', cities, 2);
This accesses each element in the cell array (cities), and returns the size of whatever dimension you specify in the last parameter of cellfun when you call it with the size parameter. You can also chain more than one cell array together. The reason why you are choosing the third parameter as 2 is because each string in the cell array is a 1 x N array. As such, we need to read how many columns there are so that this equates to the length of each string.