#!/bin/tcsh
#v3.0

# select_node_annotations <node_num> <tree method>
# creates node.$node.$tree.annotations
# Example:  select_node_annotations 58 ML
# results in node.58.ML.annotations

set node=$1
set tree=$2


if  ($node == ""  )  then
    echo "Usage: select_node_annotations <node> <tree method>\n\nCreates node.NODE.treeType.annotations containing the SNP_annotations for just the indicated node.\n\nnode is the number of the node you want or the strain name for leaf nodes, ascertained from the \ntree_AlleleCounts.(ML|NJ|parsimony|core|majority0.5).NodeLabel.tre file or the \nNode_SNP_counts file, and the tree method is ML, NJ, parsimony, core, or majority0.5.\n\nExample1:  select_node_annotations 59 ML\nExample2:  select_node_annotations EcoW parsimony\n"
    exit
endif 


grep -w Node.$node ClusterInfo.$tree | awk '{print  "^" $1}' | sort >! node.$node.$tree.loci

head -1  SNP_annotations >! node.$node.$tree.annotations
grep -w -f node.$node.$tree.loci SNP_annotations >> node.$node.$tree.annotations

