Break DNA in pieces using Matlab

Ok, the idea here is to try to unite the bits later.

% Copyright 2014 Érico Porto

% Licensed under the Apache License, Version 2.0 (the "License");
% you may not use this file except in compliance with the License.
% You may obtain a copy of the License at

%     http://www.apache.org/licenses/LICENSE-2.0

% Unless required by applicable law or agreed to in writing, software
% distributed under the License is distributed on an "AS IS" BASIS,
% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
% See the License for the specific language governing permissions and
% limitations under the License.

npont = 10000;
sizeofpiece = 300;
dnastr = textread('acetobacterpasteurianus.txt', '%s', 'delimiter', '\n','bufsize', 4000005);
rdnastr = cat(2,dnastr{:}) ;
tamanhoRd = length(rdnastr);
stringsd = randi(tamanhoRd,npont,1);

rstringsd=cell(npont,1);
rstringsd(:) = {''};

for i=1:npont
    maxed = min(stringsd(i)+sizeofpiece,tamanhoRd);
    rstringsd{i} = rdnastr(stringsd(i):maxed);
end

disp('Monte Carlo successfully applied to the DNA');
disp(sprintf('%d strings of %d chars created',npont,sizeofpiece));

QRCodes are the easy way to transfer websites to phone


At least if you are not in your computer.

If I want to pass a web site from computer to WhatsApp or other text to my phone world, I use this website to generate a Qrcode for it: http://qrcode.kaywa.com/

If the website is to big use a URL shortener to make the Qrcode more readable through your cellphone camera.

Update:

Just found out today that there is a way to make it better...

https://chart.googleapis.com/chart?chs=400x400&cht=qr&source=qrcode&chl=https://www.ericonotes.blogspot.com

modify the end of the url on top, and you can exchange it for any website.

QR code for Ericonotes on Blogger  

DIY Spectrometer



Some time ago I had some time, a spare webcam, Matlab and some Legos lying around, so I began building a Spectrometer from it. Now, to the hardware, you just need a dark box, with no light infusing in it, and a piece of dvd to use as diffraction grid. This website will help to answer most questions: http://publiclaboratory.org/tool/spectrometer

At the time, their software didn't ran on my computer so I started prototyping my own in matlab. The code is below:

% Copyright 2014 Érico Porto

% Licensed under the Apache License, Version 2.0 (the "License");
% you may not use this file except in compliance with the License.
% You may obtain a copy of the License at

%     http://www.apache.org/licenses/LICENSE-2.0

% Unless required by applicable law or agreed to in writing, software
% distributed under the License is distributed on an "AS IS" BASIS,
% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
% See the License for the specific language governing permissions and
% limitations under the License.

vid = videoinput('winvideo', 1, 'YUY2_640x480');
preview(vid);
pause(4);
color_spectrum = ycbcr2rgb(getsnapshot(vid));

%correct the orientation
binImg = im2bw(color_spectrum,0.24);
I = bwlabel(binImg);
a= regionprops(I,'MajorAxisLength','Area','Orientation');
[areaMaxArea, indexMaxArea]= max([a(:).Area]);
angle = a(indexMaxArea).Orientation;
color_spectrum = imrotate(color_spectrum,-angle,'bilinear','crop');
%now I want to get the main rectangle
binImg = im2bw(color_spectrum,0.08);
I = bwlabel(binImg);
a= regionprops(I,'BoundingBox','Area');
[areaMaxArea, iMA]= max([a(:).Area]);
subImage = imcrop(color_spectrum,round(a(iMA).BoundingBox));

%here I'm guessing the light wavelength!
%I think I need to use 380nm and 750nm as my bounding
XAxis=zeros(size(subImage,2),1);
XAxis(1)=380.0;
XAxis(length(XAxis))=750.0;

%find blue - 472nm
[intensity, blueI] = max(mean(subImage(:,:,3)));
XAxis(blueI)=472.0;

%find green - 532nm
[intensity, greenI] = max(mean(subImage(:,:,2)));
XAxis(greenI)=532.0;

%find red - 685nm
[intensity, redI] = max(mean(subImage(:,:,1)));
XAxis(redI)=685.0;

%Now I will run and fill the zeros...
beginI=1; endI=blueI; 
for i = (beginI+1):(endI-1)
    XAxis(i)= XAxis(beginI) + ((XAxis(endI)-XAxis(beginI))/(endI-beginI)) * (i-beginI);
end
beginI=blueI; endI=greenI; 
for i = (beginI+1):(endI-1)
    XAxis(i)= XAxis(beginI) + ((XAxis(endI)-XAxis(beginI))/(endI-beginI)) * (i-beginI);
end
beginI=greenI; endI=redI;
for i = (beginI+1):(endI-1)
    XAxis(i)= XAxis(beginI) + ((XAxis(endI)-XAxis(beginI))/(endI-beginI)) * (i-beginI);
end
beginI=redI; endI=length(XAxis); 
for i = (beginI+1):(endI-1)
    XAxis(i)= XAxis(beginI) + ((XAxis(endI)-XAxis(beginI))/(endI-beginI)) * (i-beginI);
end
%this ends, the wavelength vector is ready for use!

figure(2);
colormap(gray(256));
gray_spectrum=((double(subImage(:,:,1))+double(subImage(:,:,2))+double(subImage(:,:,3)))/3.0);
image(gray_spectrum);
figure(3);
colormap(gray(256));
Grayimg_reversed=flipud(gray_spectrum);
graph=mean( Grayimg_reversed ,1);

%Finally I can plot a nice graph with meaningfull axis
plot(XAxis,graph);
pause(3);
delete(vid);

For improvement, I would suggest being able to save the resulting vector with easy to some sort of table, to later use this big table to guess what I have in front of it - using Hungarian or other solver method.

Virtualbox and old Windows



I think it's always cool to once in a while boot your old computer inside your new one, just to keep track of the old stuff you've done.

So here is a tip on how to run Windows XP for free inside Virtual Box.

Import Windows XP Mode into VirtualBox #while maintaining product activation:
  1. Download Windows XP Mode (WindowsXPMode_en-us.exe | MD5: bf3726d684d3acb98185665123c9efcf)
  2. Extract xpm from WindowsXPMode_en-us.exe with a file archiver like PeaZip Portable.
  3. Add .rar extension to xpm
  4. Extract VirtualXPVHD from xpm.rar
  5. Add .vdi extension to VirtualXPVHD
  6. Create new machine in VirtualBox, specifying VirtualXPVHD.vdi as the hard disk
  7. Once initial setup is complete, uninstall Virtual PC Integration Components from Add/Remove Control Panel
  8. Install Guest Additions (Devices > Install Guest Additions...)
  9. Shut down virtual machine
  10. Download pcbios.bin (MD5: 12ccdc652b30c6d1e307c6f7deff5d24) from VMLite and copy to a directory on host computer (e.g., C:\vm\)
  11. "C:\Program Files\Oracle\VirtualBox\VBoxMange.exe" setextradata vm-name "VBoxInternal/Devices/pcbios/0/Config/BiosRom" "c:\vm\pcbios.bin"


If your games start bugging, activate the Stretch after the Guest Addition installation, and everything will run fine.

If you are looking onto Windows 3.11 and MS-DOS, well, just download those from the web and install them in a clean machine. On my case I couldn't get Windows 3.11 to auto boot after the installation, so when my machine start, I type win [enter].
Powered by Blogger.