Showing posts with label Biology. Show all posts
Showing posts with label Biology. Show all posts

Wednesday, June 17, 2015

UniPirate: Downloading and Sorting Big Data(Protein Database)

I started to download more of the protein codes, but rather than make a regex script to mess with them after(delete HTML, JS, and bank data) I decided to just use regex while the file is in the prog RAM(ha) and delete it then using Replace(string,"X","Y").

Here I am just checking the packets from the server in the background (to look for the signatures of this mess:
which appears when the p# or http://www.(baseurl)/P99314 does not exist in the data base, it has a distinct error code in the html though note <title>Error</title> so, a

if(WebBrowser.DocumentText.Contains("Error")=True){
main()
}

is a simple way to just jump over empty slots. The database is so huge that we really don't need to systematically go through, in fact the empty slots are not all at large numbers they appear to vary throughout, and a shotgun blast(i.e. bad aim, through a random number generator) is the easisest method as it contains the fairest distribution from multiple organism types. See downloading the .fasta provides this info along with some other information about the string:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=windows-1252" http-equiv=Content-Type></HEAD>
<BODY><PRE>&gt;sp|P42889|COL_MYOCO Colipase OS=Myocastor coypus GN=CLPS PE=1 SV=1
MEKVLALVLLTLAVAYAAPDPRGLIINLDNGELCLNSAQCKSQCCQHDSPLGLARCADKA
RENSGCSPQTIYGIYYLCPCERGLTCDGDKSIIGAITNTNYGICQDPQSKK
</PRE></BODY></HTML>

So basically we have to remove all this nonsense(the Html to begin with) which is simple enough.

       
        rtf.Text = Replace(rtf.Text, "bothersometext", "")
so on and so forth for whatever might be in the way. Then we need to organize them based on animal, super easy, the likely hood of the genetic code spelling MOUSE, is pretty low there are some 20 amino acids so that's .05^5 or about 0.00000003125,and since probabilities don't really matter since it doesn't limit it from happening, just take my word that it is unlikely(the strings are small too so each time is a new instance so it is really unlikely). Now you can avoid this problem all together if you set the Regex(this is default in vb,C# etc) so that capitalization is ignored as the majority of the OS names(organism) are spelt like:

Mouse
Human

and ussually latin names are included so you can really cover your bases if you like or truly guarantee by using a different alphabet and by that I mean numbers(the organism identifier number string).


In order to sort the files:



Now for performance, it may be best to take each findstr instance and use it as its own separate program or process so as to maximize distribution over the multiple cores of the cpu. It truly depends on the list of OS's and the size of the data.

I will be writing up a renaming program at some point so that:

|P42889|COL_MYOCO Colipase OS=Myocastor coypus GN=CLPS PE=1 SV=1
MEKVLALVLLTLAVAYAAPDPRGLIINLDNGELCLNSAQCKSQCCQHDSPLGLARCADKA
RENSGCSPQTIYGIYYLCPCERGLTCDGDKSIIGAITNTNYGICQDPQSKK

is saved as Colipase in C:\Myocastor_coypus ( the latter of the two operations is already performed by doghunter.bat which is the program shown above in the Gvim window.



Oh, and to answer questions before they present themselves. Yes, the operation above is a copy operation and not a cut. I do this so as to preserve originals of the files to have a fall back in case something goes terrible wrong <program|original|end> is better than <download|program|original> and then an<program|original|end>. Just for safety, good practice when working with a database the size of all the proteins ever sequenced and publicly stored.

Saturday, May 2, 2015

Neural Synchronizer Application



Meant to follow the idea that the waves can be synced (right and left hemispheres of the brain) through stimuli, using audio and visual. Going to add a physical piece for the palms with a high speed solenoid. I used VB because of the libs for audio(.Beep())
Vis with Processing:
void setup() {
  size(600,600);
}
void draw(){
  noCursor();
background(random(0,255));

}
The rest is using VB:
Auditory:
1
2
3
4
5
6
Public Class Form2

    Private Sub audodd_Click(sender As Object, e As EventArgs) Handles audodd.Click
        Console.Beep(250, 900000000)
    End Sub
End Class
The auditory is emmitting at 250Hz and the 900000000 is for timing.

Visual:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Public Class Form1
    Dim I As Integer

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Sync_Click(sender As Object, e As EventArgs) Handles Sync.Click
        vis.Visible = True
        Dim SecondForm As New Form2
        SecondForm.Show()
        visual.Enabled = True
        visualone.Enabled = True



    End Sub

    Private Sub visual_Tick(sender As Object, e As EventArgs) Handles visual.Tick
        vis.Visible = True


    End Sub

    Private Sub visualone_Tick(sender As Object, e As EventArgs) Handles visualone.Tick
        vis.Visible = False
    End Sub
End Class

Monday, April 6, 2015

UniPirate

Grabs Uniprot Data from Online( 1 every 100ms) and separates by species:


Wednesday, April 1, 2015

Warm and Fuzzy Electroencephalography Setup Hat


Yes, those are the audio-video cables which were so popular in the 90's, and they are wired directly into the hat. I will be posting more of the details on finished product later, I need to pick up some op amps for the final wires, the signal fidelity is obviously always a problem, especially at such low power. Anyway, if you choose to just go ahead with it, then ground thyself to prevent uncomfortable metal-skin contact if you wire your intake up with a ground(microchip side).

In the meantime though, the code, but before I begin, there is background noise(cyclic) on the Analog INPUT pins, but if we use the op amp we won't have to mess with this in the software. So, we will follow the old Russian R&D method and make better hardware and not do the American software approach,although we may make a nice and fancy GUI for it. But for now:



int sensorPin = A0;        
float sensorValue = 0;

void setup() {
 Serial.begin(9600); 
}
void loop() {
  sensorValue = analogRead(sensorPin);
  sensorValue=(sensorValue+analogRead(sensorPin));
   sensorValue=(sensorValue+analogRead(sensorPin));
  sensorValue=(sensorValue+analogRead(sensorPin));
    sensorValue=(sensorValue+analogRead(sensorPin));
   sensorValue=(sensorValue+analogRead(sensorPin));
  sensorValue=(sensorValue+analogRead(sensorPin));
if(sensorValue!=0.00){
  delay(22);
  

  if((sensorValue/22)>300){
  
    Serial.println(("10"));
  }else{
      sensorValue = analogRead(sensorPin);
  sensorValue=(sensorValue+analogRead(sensorPin));
   sensorValue=(sensorValue+analogRead(sensorPin));
  sensorValue=(sensorValue+analogRead(sensorPin));
    sensorValue=(sensorValue+analogRead(sensorPin));
   sensorValue=(sensorValue+analogRead(sensorPin));
  sensorValue=(sensorValue+analogRead(sensorPin));
    if(sensorValue/22>300){
    
    Serial.println("70");
  }
  }
sensorValue=0;
}
}

Okay, this is the Computer(display) side:


int a=1; 
 import processing.serial.*;
 
 Serial myPort;        // The serial port
 int xPos = 1;         // horizontal position of the graph
 
 void setup () {
 // set the window size:
 size(600, 600);        
 
 // List all the available serial ports
 println(Serial.list());
 // I know that the first port in the serial list on my mac
 // is always my  Arduino, so I open Serial.list()[0].
 // Open whatever port is the one you're using.
 myPort = new Serial(this, Serial.list()[0], 9600);
 // don't generate a serialEvent() unless you get a newline character:
 myPort.bufferUntil('\n');
 // set inital background:
 background(0);
 }
 void draw () {
 // everything happens in the serialEvent()
 }
 
 void serialEvent (Serial myPort) {
 // get the ASCII string:
 String inString = myPort.readStringUntil('\n');
 
 if (inString != null) {
 // trim off any whitespace:
 inString = trim(inString);
 // convert to an int and map to the screen height:
 float inByte = float(inString); 
 inByte = map(inByte, 0, 1023, 0, height);
 
 // draw the line:
 stroke(127,34,255);
 line(xPos, height, xPos, height - inByte);
 
 // at the edge of the screen, go back to the beginning:
 if (xPos &rt;= width) {
  //save(a+".png");
 a=a+1;
 xPos = 0;
 background(0); 

 } 
 else {
 // increment the horizontal position:
 xPos=xPos+2;
 
 }
 }
 }

Friday, March 27, 2015

Muscular Contractions w/ microphone



Microphone wired up to graph changes in skin surface potential as changes in muscle contraction. Using Audacity(an audio editor that I use for all of my "sick dubstep beats")  one can use the amplifier at about X57dB and then use the noise removal tool. Be sure to take a sample of empty electrodes or in other words, electrodes not in contact with a contracting muscle. This will give plenty of noise sampling space for algorithm. The longer incipit section the better.

One can also take an EKG, now remember that you should place the electrodes on the opposite side of the body for each pair, so across whichever line of symmetry, so:
should be wired in the following pattern(same colors means each is an element of the same pair of electrodes):
There are multiples for the black set which is symmetric across the transverse, but that is okay, the resistance of one side should be equal to the other if the path is the same(one cannot use displacement obviously).

Now for the actual measurement system:


The microphone is used only because it has an op amp and USB converter built directly in, which is quite useful, because the data can be easily stored and manipulated. Now I recommend using well insulated cables for the electrodes, perhaps even negative feedback(to a control sample ground) however this is unnecessary if one uses the standard av cables which were all the rage in the 1990's. I then coated the majority of the head in wax leaving only a small point exposed. I recommend keeping the wax at the melting threshold, that way it quickly solidifies on contact with the electrode and then we can build up multiple layers.


Now if you already looked at the eeg project, you could use those wet electrodes, made with a sponge,solution(salt),and wires. For a gel, you could use something with a glycerol like viscosity possibly mixed with an ionic or make conductivity an innate property of the substance a thick polar substance like the mucilage of plants, but very conductive. Any who, this gel issue can be avoided by using these dry electrodes.
One could also modify the electrodes but be careful because the more surface area exposed the more noise. However these electrodes easily mount to the wrists and arm for measuring contractions of the forearm muscle region.