Sponsored Content
Full Discussion: Venn Data Maker
Homework and Emergencies Emergency UNIX and Linux Support Venn Data Maker Post 302979750 by jacobs.smith on Thursday 18th of August 2016 01:06:09 PM
Old 08-18-2016
Venn Data Maker

Hi,

My input is like this

Code:
head input.txt
Set1,Set2,Set3
g1,g2,g3
g2,g1,g3,
g4,g5,g5
g1,g1,g1,
g2,g1,g1,
g6,g7,g8
,g7,g8
,,g8


My output file should be

Code:
Name,Set1,Set2,Set3
g1,1,1,1
g2,1,1,0
g3,0,0,1
g4,1,0,0
g5,0,1,1
g6,1,0,0
g7,0,1,0
g8,0,0,1

Logic
1. First get all unique genenames (g1,g2.....g8).
2. Then look if that particular gene is present in any of the columns in the input file.
3. If it is present, print 1. If absent, print 0.

Special Notes
1. Please note that the each of the columns (Set1,Set2,Set3) in input.txt can have missing values(last two records in input.txt).
2. The columns are not always three. My actual input file has 7. So I want the column counts to be dynamic.

Thanks
This User Gave Thanks to jacobs.smith For This Post:
 

2 More Discussions You Might Find Interesting

1. Programming

maker

how can i remake a program to crash a harddrive using unix:rolleyes: (2 Replies)
Discussion started by: flomper
2 Replies

2. Shell Programming and Scripting

Venn diagram results using awk

Hi, I have the following files 1.txt a 10 b 11 c 12 d 13 e 14 f 15 g 16 h 17 i 18 j 19 k 20 2.txt a 21 b 22 (15 Replies)
Discussion started by: jacobs.smith
15 Replies
sets(3erl)						     Erlang Module Definition							sets(3erl)

NAME
sets - Functions for Set Manipulation DESCRIPTION
Sets are collections of elements with no duplicate elements. The representation of a set is not defined. This module provides exactly the same interface as the module ordsets but with a defined representation. One difference is that while this module considers two elements as different if they do not match ( =:= ), ordsets considers two elements as different if and only if they do not compare equal ( == ). DATA TYPES
set() as returned by new/0 EXPORTS
new() -> Set Types Set = set() Returns a new empty set. is_set(Set) -> bool() Types Set = term() Returns true if Set is a set of elements, otherwise false . size(Set) -> int() Types Set = term() Returns the number of elements in Set . to_list(Set) -> List Types Set = set() List = [term()] Returns the elements of Set as a list. from_list(List) -> Set Types List = [term()] Set = set() Returns an set of the elements in List . is_element(Element, Set) -> bool() Types Element = term() Set = set() Returns true if Element is an element of Set , otherwise false . add_element(Element, Set1) -> Set2 Types Element = term() Set1 = Set2 = set() Returns a new set formed from Set1 with Element inserted. del_element(Element, Set1) -> Set2 Types Element = term() Set1 = Set2 = set() Returns Set1 , but with Element removed. union(Set1, Set2) -> Set3 Types Set1 = Set2 = Set3 = set() Returns the merged (union) set of Set1 and Set2 . union(SetList) -> Set Types SetList = [set()] Set = set() Returns the merged (union) set of the list of sets. intersection(Set1, Set2) -> Set3 Types Set1 = Set2 = Set3 = set() Returns the intersection of Set1 and Set2 . intersection(SetList) -> Set Types SetList = [set()] Set = set() Returns the intersection of the non-empty list of sets. is_disjoint(Set1, Set2) -> bool() Types Set1 = Set2 = set() Returns true if Set1 and Set2 are disjoint (have no elements in common), and false otherwise. subtract(Set1, Set2) -> Set3 Types Set1 = Set2 = Set3 = set() Returns only the elements of Set1 which are not also elements of Set2 . is_subset(Set1, Set2) -> bool() Types Set1 = Set2 = set() Returns true when every element of Set 1 is also a member of Set2 , otherwise false . fold(Function, Acc0, Set) -> Acc1 Types Function = fun (E, AccIn) -> AccOut Acc0 = Acc1 = AccIn = AccOut = term() Set = set() Fold Function over every element in Set returning the final value of the accumulator. filter(Pred, Set1) -> Set2 Types Pred = fun (E) -> bool() Set1 = Set2 = set() Filter elements in Set1 with boolean function Fun . SEE ALSO
ordsets(3erl) , gb_sets(3erl) Ericsson AB stdlib 1.17.3 sets(3erl)
All times are GMT -4. The time now is 06:19 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy