Understanding DESeq2
Vultr trip
Recently I found that geph is getting less and less useful, such as frequent disconnection, or unable to connect to the main server, or complaining about too many logins. Seriously, the experience was terrible. Once upon a time, I was also a person who surfed the sea of the Internet. Now, starting to miss the days of shadowsocks.
One or two, I decided to start using shadowsocks again.
Buy vps
First, I shoud to buy a virtual machine which can run a linux system and host a shadowsocks service. There is no doublt, I choose vultr.
Check server’s port is OK
To be honest, thank my little brother Michael Pacman so much for helping me to figure out the port issue.
# install nc on server and client site sudo pacman -S openbsd-netcat # server: open port <port> on server sudo nc -lv -p <port> # client: check whether the client network can access it nc -nv <server_ip_v4> <port> <input something> # If we can see <input something> from server, that means the network of server is accessible. # If not, change port or contact the staff of vultr to know your server better.
Ok, port is not OK
That was true. I meet it. So, two thousand years later.
# Change game rule sudo iptables -A INPUT -p tcp --dport <ss_port> -j ACCEPT sudo iptables -A INPUT -p udp --dport <ss_port> -j ACCEPT sudo iptables -A INPUT -p tcp --dport <ssh_port> -j ACCEPT # Save it sudo iptables-save -f /etc/iptables/iptables.rules # Run systemd iptables service sudo systemctl start iptables.service sudo systemctl status iptables.service # OK sudo systemctl enable iptables.service
For details, you can refer the documentation here. Just like vultr’s staff saied, We do not recommend disabling your firewall.
Configure shadowsocks
pacman -S shadowsocks-rust-opt pacman -S shadowsocks-v2ray-plugin # client configuration cat /etc/shadowsocks-rust/config.json { "server": "<server_ip>", "server_port": <ss_port>, "local_address": "127.0.0.1", "local_port": 1080, "password": "<passwd>", "timeout": 600, "method": "chacha20-ietf-poly1305", "plugin": "v2ray-plugin", } # server configuration cat /etc/shadowsocks-rust/config.json { "server": "::", "server_port": <ss_port>, "password": "<passwd>", "timeout": 600, "method": "chacha20-ietf-poly1305", "plugin": "v2ray-plugin", "plugin_opts": "server" } # on client and server, keep time sudo timedatectl set-ntp true sudo hwclock --systohc # server systemctl start shadowsocks-rust-server@config.service # client systemctl start shadowsocks-rust@config.service # OK systemctl enable shadowsocks-rust-server@config.service systemctl enable shadowsocks-rust@config.service
Thank my little brother Michael Pacman again for helping me figure the fault of server configuration. We should use :: for server address, not 127.0.0.1 for server address.
Hope for a free web.
Rosalind DNA
Problem
A string is simply an ordered collection of symbols selected from some alphabet and formed into a word; the length of a string is the number of symbols that it contains. An example of a length 21 DNA string (whose alphabet contains the symbols ’A’, ’C’, ’G’, and ’T’) is “ATGCTTCAGAAAGGTCTTACG.” Given: A DNA string s of length at most 1000 nt. Return: Four integers (separated by spaces) counting the respective number of times that the symbols ’A’, ’C’, ’G’, and ’T’ occur in s.
Sample Dataset
AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC
Sample Output
20 12 17 21
Attempts
Rust
use std::env; use std::fs::File; use std::io::prelude::*; fn count_nucleotides(dna: String) -> [u64; 5] { let mut counts: [u64; 5] = [0; 5]; for nucleotide in dna.chars() { match nucleotide { 'A' => counts[0] += 1, 'C' => counts[1] += 1, 'G' => counts[2] += 1, 'T' => counts[3] += 1, _ => counts[4] += 1, } } counts } fn main() { let args: Vec<String> = env::args().collect(); let filename = &args[1]; let mut f = File::open(filename).expect("file not found"); let mut dna = String::new(); f.read_to_string(&mut dna).expect("unable to read file"); let counts: [u64; 5] = count_nucleotides(dna); println!("A: {}", counts[0]); println!("C: {}", counts[1]); println!("G: {}", counts[2]); println!("T: {}", counts[3]); println!("Other: {}", counts[4]); }
Concurrent
Today, I learn python concurrent from python3 cookbook.
Bellow is some exampels using concurrent.
submit
import concurrent.futures # Some function do = [[1, 2, 3], [4, 5, 6]] def work(x): print(f"x: {x}") return x with concurrent.futures.ProcessPoolExecutor() as pool: # Example of submitting work to the pool future_result = pool.submit(work, do) # Obtaining the result (blocks until done) r = future_result.result() print(f"r: {r}")
x: [[1, 2, 3], [4, 5, 6]] r: [[1, 2, 3], [4, 5, 6]]
map
with concurrent.futures.ProcessPoolExecutor() as pool: # Example of submitting work to the pool future_result = [] for i in pool.map(work, do): future_result.append(i) # Obtaining the result (blocks until done) print(f"r: {future_result}")
x: [1, 2, 3] x: [4, 5, 6] r: [[1, 2, 3], [4, 5, 6]]