Skip to content

Instantly share code, notes, and snippets.

View Swarchal's full-sized avatar

Scott Warchal Swarchal

View GitHub Profile
#include <string>
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cassert>
using namespace std;
//////////////////////////////////////////////////////
// Finding restriction sites (reverse palindromes) //
#include <string>
#include <iostream>
#include <cassert>
using namespace std;
string complement(string s)
{
string n;
string out_string;
// loop through s in reverse order
@Swarchal
Swarchal / insertion_sort.cpp
Last active July 17, 2016 22:46
insertion sort algorithm
#include <vector>
#include <iostream>
using namespace std;
// insertion-sort integers given from stdin
int main()
{
// create vector of integers
vector<signed int> v;
signed int input, tmp, idx;
import os
import pandas as pd
# get the file paths
my_path = "path/to/output"
# stolen from stack overflow
def get_filepaths(directory):
"""Get full filepaths of all files in a directory, including sub-directories"""
@Swarchal
Swarchal / hamming.cpp
Last active July 7, 2016 09:16
Hamming distance, c++ and bash
#include <iostream>
using namespace std;
// hamming distance between two strings
int main()
{
string s1, s2;
cin >> s1;
cin >> s2;
#include <string>
#include <algorithm>
#include <iostream>
using namespace std;
// reverse complement of a DNA string
int main()
{
string s;
cin >> s; // input from stdin
@Swarchal
Swarchal / just_files.py
Created June 28, 2016 10:02
get file names from path name
out_file = open("/home/scott/just_files.txt", "w")
for line in open("out_test.txt", "r").readlines():
out_file.write(line.split("/")[-1])
@Swarchal
Swarchal / .sh
Last active June 27, 2016 17:42
submit consecutively named qsub scripts
for i in {1..100}; do "qsub script_$i"; done
# can specify intervals in braces
# e.g {1..100..2} for 1,3,5...100 and so on.
@Swarchal
Swarchal / find_files.sh
Last active June 28, 2016 10:01
find all files in directory
find . -type f
@Swarchal
Swarchal / remove_line.sh
Last active June 27, 2016 16:44
remove lines containing string
sed '/string to match/d' ./file_to_remove_from.txt > output_file.txt