<commit_before>#!/bin/bash

# <NAME>
# Solgenomics@BTI
# Purpose: Find reciprocal blast hit orthologs when given protein GIs or accessions. Use with ortholog files created using create_RBH_orthologs.sh

# Input ortholog format
#gi|662182960|ref|XP_008470658.1| FBpp0301195
#gi|662182962|ref|XP_008480455.1| FBpp0087031
#gi|662182964|ref|XP_008487638.1| FBpp0291925
#gi|662182972|ref|XP_008470659.1| FBpp0311427

usage(){
	echo "usage:
	$0 <GI or accession list> <80perc orthologs> <60perc orthologs> <50perc orthologs>
	exit 1
}

if [ "$#" -ne 4 ]
then
	usage
fi

printf "ARG 1 : %s \n" "$1"
printf "ARG 2 : %s \n" "$2"
printf "ARG 3 : %s \n" "$3"
printf "ARG 4 : %s \n" "$4"


grep -f "$1" "$2" > "${1}"."${2}".orthologs

awk -F"|" '{print $2}' "${1}"."${2}".orthologs | grep -f - -v "$1"| grep -f - "$3" > "${1}"."${3}".orthologs

awk -F"|" '{print $2}' <(cat "${1}"."${2}".orthologs "${1}"."${3}".orthologs) | grep -f - -v "$1"| grep -f - "$4" > "${1}"."${4}".orthologs

awk -F"|" '{print $2}' <(cat "${1}"."${2}".orthologs "${1}"."${3}".orthologs "${1}"."${4}".orthologs) | grep -f - -v "$1"| grep -f - "$5" > "${1}"."${5}".orthologs

awk -F"|" '{print $2}' <(cat "${1}"."${2}".orthologs "${1}"."${3}".orthologs "${1}"."${4}".orthologs "${1}"."${5}".orthologs) | grep -f - -v "$1"| grep -f - "$" > "${1}"."${6}".orthologs

awk -F"|" '{print $2}' <(cat "${1}"."${2}".orthologs "${1}"."${3}".orthologs "${1}"."${4}".orthologs "${1}"."${5}".orthologs "${1}"."${6}".orthologs) | grep -f - -v "$1"| grep -f - "$" > "${1}"."${7}".orthologs

awk -F"|" '{print $2}' <(cat "${1}"."${2}".orthologs "${1}"."${3}".orthologs "${1}"."${4}".orthologs "${1}"."${5}".orthologs "${1}"."${6}".orthologs "${1}"."${7}".orthologs) | grep -f - -v "$1"| grep -f - "$" > "${1}"."${8}".orthologs
<commit_msg>using sensible var names<commit_after>#!/bin/bash

# <NAME>
# Solgenomics@BTI
# Purpose: Find reciprocal blast hit orthologs when given protein GIs or accessions. Use with ortholog files created using create_RBH_orthologs.sh

# Input ortholog format
#gi|662182960|ref|XP_008470658.1| FBpp0301195
#gi|662182962|ref|XP_008480455.1| FBpp0087031
#gi|662182964|ref|XP_008487638.1| FBpp0291925
#gi|662182972|ref|XP_008470659.1| FBpp0311427

# NOTE 
# NOT TESTED

usage(){
	echo "usage:
	$0 <GI or accession list> <90perc orthologs> <80perc orthologs> <70perc orthologs>"
	exit 1
}

if [ "$#" -ne 4 ]
then
	usage
fi

printf "GI or accession list : %s \n" "$1"
printf "90perc orthologs : %s \n" "$2"
printf "80perc orthologs : %s \n" "$3"
printf "70perc orthologs : %s \n" "$4"

LIST="$1"
PERC90="$2"
PERC80="$3"
PERC70="$4"

grep -f "$LIST" "$PERC90" > "${1}"."${2}".orthologs

awk -F"|" '{print $PERC90}' "${1}"."${2}".orthologs | grep -f - -v "$LIST"| grep -f - "$PERC80" > "${1}"."${PERC80}".orthologs

awk -F"|" '{print $PERC90}' <(cat "${1}"."${2}".orthologs "${1}"."${PERC80}".orthologs) | grep -f - -v "$LIST"| grep -f - "$4" > "${1}"."${PERC70}".orthologs

awk -F"|" '{print $PERC90}' <(cat "${1}"."${2}".orthologs "${1}"."${PERC80}".orthologs "${1}"."${PERC70}".orthologs) | grep -f - -v "$LIST"| grep -f - "$5" > "${1}"."${5}".orthologs

awk -F"|" '{print $PERC90}' <(cat "${1}"."${2}".orthologs "${1}"."${PERC80}".orthologs "${1}"."${PERC70}".orthologs "${1}"."${5}".orthologs) | grep -f - -v "$LIST"| grep -f - "$" > "${1}"."${6}".orthologs

awk -F"|" '{print $PERC90}' <(cat "${1}"."${2}".orthologs "${1}"."${PERC80}".orthologs "${1}"."${PERC70}".orthologs "${1}"."${5}".orthologs "${1}"."${6}".orthologs) | grep -f - -v "$LIST"| grep -f - "$" > "${1}"."${7}".orthologs

awk -F"|" '{print $PERC90}' <(cat "${1}"."${2}".orthologs "${1}"."${PERC80}".orthologs "${1}"."${PERC70}".orthologs "${1}"."${5}".orthologs "${1}"."${6}".orthologs "${1}"."${7}".orthologs) | grep -f - -v "$LIST"| grep -f - "$" > "${1}"."${8}".orthologs
{'fraction_non_alphanumeric': 0.31533420707732635, 'fraction_numerical': 0.10799475753604194, 'mean_word_length': 4.451428571428571, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2091516', 'n_tokens_mistral': 1953, 'n_tokens_neox': 1706, 'n_words': 370}