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
ordsets(3erl)						     Erlang Module Definition						     ordsets(3erl)

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