txt-sushi 0.1 → 0.2
raw patch · 95 files changed
+386/−59 lines, 95 filesdep +regex-posixbinary-added
Dependencies added: regex-posix
Files
- TxtSushi/IO.hs +0/−13
- TxtSushi/SQLExecution.hs +60/−26
- TxtSushi/SQLParser.hs +83/−12
- _darcs/format +2/−0
- _darcs/hashed_inventory +8/−0
- _darcs/inventories/0000001260-8f8e2c077c4bae8cc2094386214bd292379b1ee72540673d89e1514e binary
- _darcs/inventories/0000006394-dd21a7fa69cce91d38242dda31118e5085023e7aecfddff8f8da0cac binary
- _darcs/patches/0000000191-2c40a8181d0d6b42236bb2abe2767fc51ffa6d2188cf0021d18edd89ab9d binary
- _darcs/patches/0000000191-69a041fd53c8f7e5b11f835e60b49daed29b88b43b0883d94275efaa2c69 binary
- _darcs/patches/0000000201-d27210175d1d081a056238cd9769a42c7ff50dede48181fa8f1b903bc379 binary
- _darcs/patches/0000000274-fb6ae1f888a0ae95c79a8c88327e34b133890b754cef6ab3a1c9f87f6795 binary
- _darcs/patches/0000000378-118496eba00c44a2334983e28a06cfaed256bd373079edef16ec469d3e36 binary
- _darcs/patches/0000000454-837c722676d15daf644fe71a0071838789d7b496db348af85374cad4650e binary
- _darcs/patches/0000000474-3e80349a7a5f8eaabc8813f1144636e87e9b781f5b4013942a6cdc2046db binary
- _darcs/patches/0000000504-d7bfdb8aa7370ef5916acda9945f1ad0a2f00320a5f04072ea57058e68ce binary
- _darcs/patches/0000000505-7003ad42b1c6a26ab34ed80b54cfa6fab8f2c81bda2dbcccb6725525ac2d binary
- _darcs/patches/0000000609-f1b0b1a03c3d8421d17dc15a39609949c9e5960e3f7b6ceb8f7292053975 binary
- _darcs/patches/0000000628-16a1c0e32bda87c79248cd7435ce6da9f7a0ce7de475ef25132a7423d79c binary
- _darcs/patches/0000000757-19220ad0f4ad47d4e83a893e999066eccf7579e1b9527b1606806cd4e48e binary
- _darcs/patches/0000000773-b36b71d0a85a717f6642b9f04da20921fb1e3d4e2044508833e676d09404 binary
- _darcs/patches/0000000983-b4088fe2ce96d588b9a854e5e200c66e66b107bab5ef3dd0c1b06e52817e binary
- _darcs/patches/0000001149-31511fe20855eacbdbd6a435e1d33e136f5a811802e793e3316dff1b9a41 binary
- _darcs/patches/0000001733-08c8318da1c4bc1e961bb9eba067af69d50dfaebc73818cf327054466c0a binary
- _darcs/patches/0000001787-e542485f9074ec93d1fa924c68d8bad1d597af6c0fd6bf4a333f6e5ed702 binary
- _darcs/patches/0000001970-2037710eb055cda2b6fd3c21e3ff1388bfbad784523153362591a3067741 binary
- _darcs/patches/0000002001-1c05b971133432912d672cab5b5b7a742b3cf7971b6ae8116c6b67b3a13f binary
- _darcs/patches/0000002026-882079cdc55867c7febe504e9a79e5232b0ed543139844442cbf937734bb binary
- _darcs/patches/0000002333-48fdb810a3d1f4e24e501e30113fc0ce3faed45db34a0a0d01d985dbdbe8 binary
- _darcs/patches/0000002339-7a3bb3fc3e515f5cd742bb3ab1e575a149fbd01a477ab5630f99112635e5 binary
- _darcs/patches/0000002642-864c4d8b2d200fe4b4dc9c36a4bfcd72642cb975ac81634a8ddc8d0d7d10 binary
- _darcs/patches/0000002674-0dfb35863da7e573bf060c4fdb93a6f352005a256afea55ecfc69f812a59 binary
- _darcs/patches/0000002734-114e244d4026f048f8328ff09f306774b285630374b19867f259253fdc67 binary
- _darcs/patches/0000003029-267c6668ee3b23a1873b81bf13bf94ad4357cfc056c31412f2eec8ad0025 binary
- _darcs/patches/0000003945-20edbc0e6ba404e934b2e40c37cf2199d3eb19811bceb5c6e5e1a54dd7d7 binary
- _darcs/patches/0000003958-40c17a6c5e486cb4fd2fc0381898ef942a799ee662d7066466090cba7eb0 binary
- _darcs/patches/0000004103-1efcde4b404484b6d87566c4a32d6a0eae29af6dbe1b5576a833b35909b7 binary
- _darcs/patches/0000004761-5308225b40ae211903a8f2f822b3b42bed9f89393ea40e53b18e97ae0358 binary
- _darcs/patches/0000005281-3dc871668663e6efe214646a8bd241142807c859729b591f8d1c082fbb88 binary
- _darcs/patches/0000006021-64a3588aba279ddb985f7b324489c7964545079137eeebfdbbbc9ec57039 binary
- _darcs/patches/0000006540-e909d3a393f7f1bde11301fe78f45c9ca0f9d8dbc819cef0ef9b0ff87961 binary
- _darcs/patches/0000007338-d61110b41ba3dba61ede97ee514dbeea0170d6bf68685f1aefb20d3edbaf binary
- _darcs/patches/0000007357-6f774098abed7937b6ceff17f852d2fc9103fd67f563c8eaeeffffaa5236 binary
- _darcs/patches/0000018238-8b063fa0fab2a4a3aa27fe91a2ef6bc5d72b88ba0aac7e41f94b115806c8 binary
- _darcs/patches/0000036783-1d29937d76c9599242f1c2d9ce139111ef108d4635119e4d74a686950f6d binary
- _darcs/patches/0000070374-475515c8f051c8c3f01a02e1bd957749267881da8f7a853a7b9be4efac61 binary
- _darcs/patches/pending.tentative +2/−0
- _darcs/prefs/binaries +59/−0
- _darcs/prefs/boring +113/−0
- _darcs/prefs/defaultrepo +1/−0
- _darcs/prefs/motd +0/−0
- _darcs/prefs/prefs +1/−0
- _darcs/prefs/repos +1/−0
- _darcs/prefs/sources +3/−0
- _darcs/pristine.hashed/0000000088-2061bfc1d7e7ec5e518faee92edbbe7e4472e558cbae9ce84fc8 binary
- _darcs/pristine.hashed/0000000111-2eb4b905deb944c0862657c882064532176f86535181e46e7bce binary
- _darcs/pristine.hashed/0000000200-e7e4b45569ce239f362a5c76d649eaf15813287b9030345c7a74 binary
- _darcs/pristine.hashed/0000000286-f5df68519401593190ddd743563beb6fc0323da0bfe27784109a binary
- _darcs/pristine.hashed/0000000291-9f5e432df6f1bc2d706d98e6d03e3863223f8fef6398a859e712 binary
- _darcs/pristine.hashed/0000000376-5b92e0d16d8aacbf288cedc6ec477ba4cf43017327a542362992 binary
- _darcs/pristine.hashed/0000000445-2956c382ba76682981c52ac0b823a1498c3b985f0f0248c0bbac binary
- _darcs/pristine.hashed/0000000522-4aceb8d853e003efc12f16b82875a9d151e9263a62d6a523a5cb binary
- _darcs/pristine.hashed/0000000523-682613113249839d8ce475b8ac48d760a593eb9cba6c07e7f998 binary
- _darcs/pristine.hashed/0000000608-50982335dfb9bdaf3468db64cc53839e5a552bc928ac9c153459 binary
- _darcs/pristine.hashed/0000000626-7b94f2ad9b5ddaa9d78c1bbbbc1bf24404122c1c9415239316fd binary
- _darcs/pristine.hashed/0000000650-4d5fa370e5a998b4346e9c2df2e81ddf09bc6435c0f7dbca0afd binary
- _darcs/pristine.hashed/0000000733-b497d395fe2a8d6f42e771045322ae663ac67d81db8ace0eaba4 binary
- _darcs/pristine.hashed/0000000853-5c22e0c03f2bd51e17dab53bd12d109965be878b6ec35636aa88 binary
- _darcs/pristine.hashed/0000000854-ca1995790b7158e896bfd840685e52837e55fb75f21f1910f197 binary
- _darcs/pristine.hashed/0000000929-42e83abfbfc514fbce439a61f955f3e73c2676647266dab06da2 binary
- _darcs/pristine.hashed/0000001118-0d6474967277971e0f30b93baf1a90e52db1ceb04de1157261b6 binary
- _darcs/pristine.hashed/0000001207-bc201d58790f04a515cdecf786a94812b0b7644b50b76c7f1eed binary
- _darcs/pristine.hashed/0000001225-d85bae845f150051981654adb19422822721931022f5efac3dc1 binary
- _darcs/pristine.hashed/0000001352-f4b63f1a6fe106adc86e8b58af29d4a078755ee01322d887f6e1 binary
- _darcs/pristine.hashed/0000001382-0fe562a03070b1c03130d81917674ad6b950cc0ce9f314731994 binary
- _darcs/pristine.hashed/0000001500-6297c5727d10ee993de16a5b475efb3c35bb0ba9a301a2f2aa23 binary
- _darcs/pristine.hashed/0000001506-5eac01f7311f45389d1fc10325ff7b83a4cdd71d1532f04f0780 binary
- _darcs/pristine.hashed/0000001710-9ede27ebfdd59187303a5aae1b2cda57b3e2284b295d6d24e850 binary
- _darcs/pristine.hashed/0000002042-31f05b2de17e2cafc6e292556cad02125548830edbf55da03032 binary
- _darcs/pristine.hashed/0000002342-06e125d86b412c96aeb7f856ff7bdaf7d8e70f455499fbf8d834 binary
- _darcs/pristine.hashed/0000004451-04d981a18f7e94e1461cb7235d19608ce25b741ed9085fe5b9c9 binary
- _darcs/pristine.hashed/0000004624-52cac272f443c622f640299a179e984932582f60479117a477c8 binary
- _darcs/pristine.hashed/0000006425-16c0f4848f8e361361d200395b98d895385e5f90f61a636b7432 binary
- _darcs/pristine.hashed/0000007422-d76d386b471ecbf7126236116e30d46a193a39f5eee11c93086a binary
- _darcs/pristine.hashed/0000007530-baac5ef4de73ccb7c3a3c5ed104932bbc7d99c5c332b16df3b39 binary
- _darcs/pristine.hashed/0000012267-af3a69b0dc65220116215bbf886f1c42a112640b3ecce2b454ad binary
- _darcs/pristine.hashed/0000018571-53e87b4f3da210d9ce301522df0cb4217ef69efa54424246ffc3 binary
- _darcs/pristine.hashed/0000025902-7e39012f7884c9eaae8c5462329524b9cc60eb55b77abd12f411 binary
- _darcs/pristine.hashed/0000035147-8ceb4b9ee5adedde47b31e975c1d90c73ad27b6b165a1dcd80c7 binary
- _darcs/pristine.hashed/da39a3ee5e6b4b0d3255bfef95601890afd80709 +0/−0
- _darcs/tentative_hashed_inventory +8/−0
- _darcs/tentative_pristine +1/−0
- examples/query-imputed-SNPs-regex.bash +15/−0
- examples/query-imputed-SNPs.bash +15/−0
- examples/query-mgi-markers.bash +11/−5
- txt-sushi.cabal +3/−3
@@ -73,19 +73,6 @@ maxRowFieldWidths :: [String] -> [Int] -> [Int] maxRowFieldWidths row prevMaxValues = zipWithD max (map length row) prevMaxValues-{-- let colLengths = map length row- lengthOfRow = length row- lengthOfPrevMax = length prevMaxValues- maxPrefixList = zipWith max colLengths prevMaxValues- in- if lengthOfRow == lengthOfPrevMax then- maxPrefixList- else if lengthOfRow > lengthOfPrevMax then- maxPrefixList ++ (drop lengthOfPrevMax colLengths)- else- maxPrefixList ++ (drop lengthOfRow prevMaxValues)--} zipWithD :: (a -> a -> a) -> [a] -> [a] -> [a] zipWithD f (x:xt) (y:yt) = (f x y):(zipWithD f xt yt)
@@ -19,6 +19,7 @@ import Data.Char import Data.List import qualified Data.Map as Map+import Text.Regex.Posix import TxtSushi.SQLParser import TxtSushi.Transform@@ -62,8 +63,8 @@ boolExpression bool = EvaluatedExpression { preferredType = BoolType,- maybeIntValue = Just $ if bool then 1 else 0,- maybeRealValue = Just $ if bool then 1.0 else 0.0,+ maybeIntValue = Nothing,+ maybeRealValue = Nothing, stringValue = show bool, maybeBoolValue = Just bool} @@ -71,21 +72,21 @@ intValue evalExpr = case maybeIntValue evalExpr of Just int -> int Nothing ->- error $ "failed to parse \"" ++ (stringValue evalExpr) ++- "\" as an integer value"+ error $ "could not convert \"" ++ (stringValue evalExpr) +++ "\" to an integer value" realValue :: EvaluatedExpression -> Double realValue evalExpr = case maybeRealValue evalExpr of Just real -> real Nothing ->- error $ "failed to parse \"" ++ (stringValue evalExpr) +++ error $ "could not convert \"" ++ (stringValue evalExpr) ++ "\" to a numeric value" boolValue :: EvaluatedExpression -> Bool boolValue evalExpr = case maybeBoolValue evalExpr of Just bool -> bool Nothing ->- error $ "failed to parse \"" ++ (stringValue evalExpr) +++ error $ "could not convert \"" ++ (stringValue evalExpr) ++ "\" to a boolean value" data ExpressionType = StringType | RealType | IntType | BoolType deriving Eq@@ -112,21 +113,30 @@ expr1 == expr2 = compare expr1 expr2 == EQ instance Ord EvaluatedExpression where- -- compare on bool based on preferred type- compare (EvaluatedExpression BoolType _ _ _ (Just b1)) (EvaluatedExpression _ _ _ _ (Just b2)) = compare b1 b2- compare (EvaluatedExpression _ _ _ _ (Just b1)) (EvaluatedExpression BoolType _ _ _ (Just b2)) = compare b1 b2- - -- compare on int based on preferred type- compare (EvaluatedExpression IntType _ _ (Just i1) _) (EvaluatedExpression _ _ _ (Just i2) _) = compare i1 i2- compare (EvaluatedExpression _ _ _ (Just i1) _) (EvaluatedExpression IntType _ _ (Just i2) _) = compare i1 i2+ compare expr1 expr2+ | type1 == RealType || type2 == RealType = realCompare expr1 expr2+ | type1 == IntType || type2 == IntType = intCompare expr1 expr2+ | type1 == BoolType || type2 == BoolType = boolCompare expr1 expr2+ | otherwise = stringCompare expr1 expr2+ + where+ type1 = preferredType expr1+ type2 = preferredType expr2 - -- compare on real based on preferred type- compare (EvaluatedExpression RealType _ (Just r1) _ _) (EvaluatedExpression _ _ (Just r2) _ _) = compare r1 r2- compare (EvaluatedExpression _ _ (Just r1) _ _) (EvaluatedExpression RealType _ (Just r2) _ _) = compare r1 r2- - -- fall back on string type- compare expr1 expr2 = compare (stringValue expr1) (stringValue expr2)+realCompare (EvaluatedExpression _ _ (Just r1) _ _) (EvaluatedExpression _ _ (Just r2) _ _) =+ compare r1 r2+realCompare expr1 expr2 = stringCompare expr1 expr2 +intCompare (EvaluatedExpression _ _ _ (Just i1) _) (EvaluatedExpression _ _ _ (Just i2) _) =+ compare i1 i2+intCompare expr1 expr2 = realCompare expr1 expr2++boolCompare (EvaluatedExpression _ _ _ _ (Just b1)) (EvaluatedExpression _ _ _ _ (Just b2)) =+ compare b1 b2+boolCompare expr1 expr2 = stringCompare expr1 expr2++stringCompare expr1 expr2 = stringValue expr1 `compare` stringValue expr2+ -- convert a text table to a database table by using the 1st row as column IDs textTableToDatabaseTable :: String -> [[String]] -> DatabaseTable textTableToDatabaseTable tableName (headerNames:tblRows) =@@ -363,17 +373,35 @@ -- this is where the action is. evaluate a function evalExpression (FunctionExpression sqlFun funArgs) columnIds tblRow -- String functions- | sqlFun == upperFunction = stringExpression $ map toUpper (stringValue (head evaluatedArgs))- | sqlFun == lowerFunction = stringExpression $ map toLower (stringValue (head evaluatedArgs))- | sqlFun == trimFunction = stringExpression $ trimSpace (stringValue (head evaluatedArgs))+ | sqlFun == upperFunction = stringExpression $ map toUpper (stringValue arg1)+ | sqlFun == lowerFunction = stringExpression $ map toLower (stringValue arg1)+ | sqlFun == trimFunction = stringExpression $ trimSpace (stringValue arg1)+ | sqlFun == concatenateFunction = stringExpression $ concat (map stringValue evaluatedArgs)+ | sqlFun == substringFromToFunction =+ stringExpression $ take (intValue arg3) (drop (intValue arg2 - 1) (stringValue arg1))+ | sqlFun == substringFromFunction =+ stringExpression $ drop (intValue arg2 - 1) (stringValue arg1)+ | sqlFun == regexMatchFunction = boolExpression $ (stringValue arg1) =~ (stringValue arg2) - -- algebraic infix functions+ -- negate+ | sqlFun == negateFunction =+ if length evaluatedArgs /= 1 then+ error "internal error: found a negate function with multiple args"+ else+ let evaldArg = head evaluatedArgs+ in+ if useRealAlgebra evaldArg then+ realExpression $ negate (realValue evaldArg)+ else+ intExpression $ negate (intValue evaldArg)+ + -- algebraic | sqlFun == multiplyFunction = algebraWithCoercion (*) (*) evaluatedArgs | sqlFun == divideFunction = realExpression $ foldl1' (/) (map realValue evaluatedArgs) | sqlFun == plusFunction = algebraWithCoercion (+) (+) evaluatedArgs | sqlFun == minusFunction = algebraWithCoercion (-) (-) evaluatedArgs - -- boolean infix functions+ -- boolean | sqlFun == isFunction = boolExpression (arg1 == arg2) | sqlFun == isNotFunction = boolExpression (arg1 /= arg2) | sqlFun == lessThanFunction = boolExpression (arg1 < arg2)@@ -382,10 +410,13 @@ | sqlFun == greaterThanOrEqualToFunction = boolExpression (arg1 >= arg2) | sqlFun == andFunction = boolExpression $ (boolValue arg1) && (boolValue arg2) | sqlFun == orFunction = boolExpression $ (boolValue arg1) || (boolValue arg2)+ | sqlFun == notFunction = boolExpression $ not (boolValue arg1) where arg1 = head evaluatedArgs arg2 = evaluatedArgs !! 1+ arg3 = evaluatedArgs !! 2+ subStringF start extent string = take extent (drop start string) evaluatedArgs = map evalArgExpr funArgs evalArgExpr expr = evalExpression expr columnIds tblRow algebraWithCoercion intFunc realFunc args =@@ -395,8 +426,11 @@ intExpression $ foldl1' intFunc (map intValue args) useRealAlgebra expr =- let prefType = preferredType expr- in prefType == StringType || prefType == RealType+ let+ prefType = preferredType expr+ maybeInt = maybeIntValue expr+ in+ prefType == RealType || maybeInt == Nothing -- | trims leading and trailing spaces trimSpace :: String -> String
@@ -25,18 +25,22 @@ prettyFormatWithArgs, SQLFunction(..), - -- SQL functions with "normal" syntax+ -- String SQL function+ concatenateFunction, upperFunction, lowerFunction, trimFunction,+ substringFromFunction,+ substringFromToFunction, - -- Algebraic infix SQL functions+ -- Algebraic SQL functions multiplyFunction, divideFunction, plusFunction, minusFunction,+ negateFunction, - -- Boolean infix SQL functions+ -- Boolean SQL functions isFunction, isNotFunction, lessThanFunction,@@ -45,6 +49,8 @@ greaterThanOrEqualToFunction, andFunction, orFunction,+ notFunction,+ regexMatchFunction, -- Etc... maybeReadInt,@@ -154,6 +160,11 @@ prettyFormatWithArgs sqlFunc funcArgs | sqlFunc `elem` normalSyntaxFunctions = prettyFormatNormalFunctionExpression sqlFunc funcArgs | or (map (sqlFunc `elem`) infixFunctions) = prettyFormatInfixFunctionExpression sqlFunc funcArgs+ | sqlFunc == negateFunction = "-" ++ toArgString (head funcArgs)+ | sqlFunc == substringFromToFunction ||+ sqlFunc == substringFromFunction ||+ sqlFunc == notFunction =+ prettyFormatNormalFunctionExpression sqlFunc funcArgs prettyFormatInfixFunctionExpression :: SQLFunction -> [Expression] -> String prettyFormatInfixFunctionExpression sqlFunc funcArgs =@@ -364,13 +375,17 @@ parenthesize parseExpression <|> parseStringConstant <|> try parseRealConstant <|>- parseIntConstant <|>+ try parseIntConstant <|> parseAnyNormalFunction <|>+ parseNegateFunction <|>+ parseSubstringFunction <|>+ parseNotFunction <|> (parseColumnId >>= (\colId -> return $ ColumnExpression colId)) parseStringConstant :: GenParser Char st Expression parseStringConstant =- quotedText True '"' >>= (\txt -> return $ StringConstantExpression txt)+ (quotedText True '"' <|> quotedText True '\'') >>=+ (\txt -> return $ StringConstantExpression txt) parseIntConstant :: GenParser Char st Expression parseIntConstant =@@ -458,9 +473,11 @@ infixFunctions = [[multiplyFunction, divideFunction], [plusFunction, minusFunction],+ [concatenateFunction], [isFunction, isNotFunction, lessThanFunction, lessThanOrEqualToFunction,- greaterThanFunction, greaterThanOrEqualToFunction],- [andFunction, orFunction]]+ greaterThanFunction, greaterThanOrEqualToFunction, regexMatchFunction],+ [andFunction],+ [orFunction]] -- | This function parses the operator part of the infix function and returns -- a function that excepts a left expression and right expression to form@@ -482,9 +499,10 @@ sqlFunction = infixFunc, functionArguments = [leftSubExpr, rightSubExpr]} funcIsAlphaNum = any isAlphaNum (functionName infixFunc)- notOpChar =- notFollowedBy $ oneOf "*/+-=<>^" +notOpChar =+ notFollowedBy $ oneOf "*/+-=<>^|~"+ -- Algebraic multiplyFunction = SQLFunction { functionName = "*",@@ -547,15 +565,25 @@ minArgCount = 2, argCountIsFixed = True} +concatenateFunction = SQLFunction {+ functionName = "||",+ minArgCount = 2,+ argCountIsFixed = True} +regexMatchFunction = SQLFunction {+ functionName = "=~",+ minArgCount = 2,+ argCountIsFixed = True} -- Functions with special syntax -- specialFunctions = [substringFromFunction,- substringFromToFunction]+ substringFromToFunction,+ negateFunction,+ notFunction] -- | SUBSTRING(extraction_string FROM starting_position [FOR length] -- [COLLATE collation_name])--- TODO implement these+-- TODO implement COLLATE part substringFromFunction = SQLFunction { functionName = "SUBSTRING", minArgCount = 2,@@ -565,6 +593,47 @@ minArgCount = 3, argCountIsFixed = True} +parseSubstringFunction :: GenParser Char st Expression+parseSubstringFunction = do+ try $ upperOrLower (functionName substringFromFunction) >> spaces >> char '('+ spaces+ strExpr <- parseExpression+ spaces1+ upperOrLower "FROM"+ spaces1+ startExpr <- parseExpression+ -- TODO doesn't need to be spaces. it can just be '('+ maybeLength <- maybeParse $ spaces1 >> upperOrLower "FOR" >> spaces1 >> parseExpression+ spaces+ char ')'+ + return $ case maybeLength of+ Nothing -> FunctionExpression substringFromFunction [strExpr, startExpr]+ Just len -> FunctionExpression substringFromToFunction [strExpr, startExpr, len]++negateFunction = SQLFunction {+ functionName = "-",+ minArgCount = 1,+ argCountIsFixed = True}++parseNegateFunction :: GenParser Char st Expression+parseNegateFunction = do+ try $ char '-' >> notOpChar+ expr <- parseAnyNonInfixExpression+ return $ FunctionExpression negateFunction [expr]++notFunction = SQLFunction {+ functionName = "NOT",+ minArgCount = 1,+ argCountIsFixed = True}++parseNotFunction = do+ try $ upperOrLower (functionName notFunction) >>+ genNotFollowedBy (anyChar `exceptChar` (space <|> char '('))+ spaces+ expr <- parseAnyNonInfixExpression+ return $ FunctionExpression notFunction [expr]+ -------------------------------------------------------------------------------- -- Parse utility functions --------------------------------------------------------------------------------@@ -577,6 +646,8 @@ quotedText False '`' <|> many1 idChar (parseId `genExcept` parseReservedWord) <?> "identifier" +-- | quoted text which allows escaping by doubling the quote char+-- like "escaped quote char here:""" quotedText allowEmpty quoteChar = do let quote = char quoteChar manyFunc = if allowEmpty then many else many1@@ -644,7 +715,7 @@ map functionName normalSyntaxFunctions ++ map functionName (concat infixFunctions) ++ map functionName specialFunctions ++- ["BY","CROSS", "FROM", "GROUP", "HAVING", "INNER", "JOIN", "ON", "ORDER", "SELECT", "WHERE"]+ ["BY","CROSS", "FROM", "FOR", "GROUP", "HAVING", "INNER", "JOIN", "ON", "ORDER", "SELECT", "WHERE"] -- | tries parsing both the upper and lower case versions of the given string upperOrLower :: String -> GenParser Char st String
@@ -0,0 +1,2 @@+hashed+darcs-2
@@ -0,0 +1,8 @@+pristine:0000001506-5eac01f7311f45389d1fc10325ff7b83a4cdd71d1532f04f07800936c5acb260+Starting with inventory:+0000001260-8f8e2c077c4bae8cc2094386214bd292379b1ee72540673d89e1514e19f69207+[TAG release 0.2+keithshep@gmail.com**20090521033210+ Ignore-this: b0ed58fccf2f95a610521713d9c1a499+] +hash: 0000000773-b36b71d0a85a717f6642b9f04da20921fb1e3d4e2044508833e676d094046526
binary file changed (absent → 686 bytes)
binary file changed (absent → 2957 bytes)
binary file changed (absent → 155 bytes)
binary file changed (absent → 161 bytes)
binary file changed (absent → 184 bytes)
binary file changed (absent → 225 bytes)
binary file changed (absent → 242 bytes)
binary file changed (absent → 274 bytes)
binary file changed (absent → 219 bytes)
binary file changed (absent → 312 bytes)
binary file changed (absent → 233 bytes)
binary file changed (absent → 418 bytes)
binary file changed (absent → 364 bytes)
binary file changed (absent → 459 bytes)
binary file changed (absent → 387 bytes)
binary file changed (absent → 359 bytes)
binary file changed (absent → 685 bytes)
binary file changed (absent → 654 bytes)
binary file changed (absent → 527 bytes)
binary file changed (absent → 579 bytes)
binary file changed (absent → 699 bytes)
binary file changed (absent → 507 bytes)
binary file changed (absent → 1225 bytes)
binary file changed (absent → 715 bytes)
binary file changed (absent → 901 bytes)
binary file changed (absent → 681 bytes)
binary file changed (absent → 980 bytes)
binary file changed (absent → 1047 bytes)
binary file changed (absent → 1079 bytes)
binary file changed (absent → 1616 bytes)
binary file changed (absent → 1126 bytes)
binary file changed (absent → 949 bytes)
binary file changed (absent → 1277 bytes)
binary file changed (absent → 1538 bytes)
binary file changed (absent → 1567 bytes)
binary file changed (absent → 1998 bytes)
binary file changed (absent → 2268 bytes)
binary file changed (absent → 3817 bytes)
binary file changed (absent → 12773 bytes)
binary file changed (absent → 16259 bytes)
@@ -0,0 +1,2 @@+{+}
@@ -0,0 +1,59 @@+# Binary file regexps:+\.png$+\.PNG$+\.gz$+\.GZ$+\.pdf$+\.PDF$+\.jpg$+\.JPG$+\.jpeg$+\.JPEG$+\.gif$+\.GIF$+\.tif$+\.TIF$+\.tiff$+\.TIFF$+\.pnm$+\.PNM$+\.pbm$+\.PBM$+\.pgm$+\.PGM$+\.ppm$+\.PPM$+\.bmp$+\.BMP$+\.mng$+\.MNG$+\.tar$+\.TAR$+\.bz2$+\.BZ2$+\.z$+\.Z$+\.zip$+\.ZIP$+\.jar$+\.JAR$+\.so$+\.SO$+\.a$+\.A$+\.tgz$+\.TGZ$+\.mpg$+\.MPG$+\.mpeg$+\.MPEG$+\.iso$+\.ISO$+\.exe$+\.EXE$+\.doc$+\.DOC$+\.elc$+\.ELC$+\.pyc$+\.PYC$
@@ -0,0 +1,113 @@+# Boring file regexps:++### compiler and interpreter intermediate files+# haskell (ghc) interfaces+\.hi$+\.hi-boot$+\.o-boot$+# object files+\.o$+\.o\.cmd$+# profiling haskell+\.p_hi$+\.p_o$+# haskell program coverage resp. profiling info+\.tix$+\.prof$+# fortran module files+\.mod$+# linux kernel+\.ko\.cmd$+\.mod\.c$+(^|/)\.tmp_versions($|/)+# *.ko files aren't boring by default because they might+# be Korean translations rather than kernel modules+# \.ko$+# python, emacs, java byte code+\.py[co]$+\.elc$+\.class$+# objects and libraries; lo and la are libtool things+\.(obj|a|exe|so|lo|la)$+# compiled zsh configuration files+\.zwc$+# Common LISP output files for CLISP and CMUCL+\.(fas|fasl|sparcf|x86f)$++### build and packaging systems+# cabal intermediates+\.installed-pkg-config+\.setup-config+# standard cabal build dir, might not be boring for everybody+# ^dist(/|$)+# autotools+(^|/)autom4te\.cache($|/)+(^|/)config\.(log|status)$+# microsoft web expression, visual studio metadata directories+\_vti_cnf$+\_vti_pvt$+# gentoo tools+\.revdep-rebuild.*+# generated dependencies+^\.depend$++### version control systems+# cvs+(^|/)CVS($|/)+\.cvsignore$+# cvs, emacs locks+^\.#+# rcs+(^|/)RCS($|/)+,v$+# subversion+(^|/)\.svn($|/)+# mercurial+(^|/)\.hg($|/)+# git+(^|/)\.git($|/)+# bzr+\.bzr$+# sccs+(^|/)SCCS($|/)+# darcs+(^|/)_darcs($|/)+(^|/)\.darcsrepo($|/)+^\.darcs-temp-mail$+-darcs-backup[[:digit:]]+$+# gnu arch+(^|/)(\+|,)+(^|/)vssver\.scc$+\.swp$+(^|/)MT($|/)+(^|/)\{arch\}($|/)+(^|/).arch-ids($|/)+# bitkeeper+(^|/)BitKeeper($|/)+(^|/)ChangeSet($|/)++### miscellaneous+# backup files+~$+\.bak$+\.BAK$+# patch originals and rejects+\.orig$+\.rej$+# X server+\..serverauth.*+# image spam+\#+(^|/)Thumbs\.db$+# vi, emacs tags+(^|/)(tags|TAGS)$+#(^|/)\.[^/]+# core dumps+(^|/|\.)core$+# partial broken files (KIO copy operations)+\.part$+# waf files, see http://code.google.com/p/waf/+(^|/)\.waf-[[:digit:].]+-[[:digit:]]+($|/)+(^|/)\.lock-wscript$+# mac os finder+(^|/)\.DS_Store$
@@ -0,0 +1,1 @@+http://patch-tag.com/r/txt-sushi/pullrepo
@@ -0,0 +1,1 @@+boringfile .boring
@@ -0,0 +1,1 @@+http://patch-tag.com/r/txt-sushi/pullrepo
@@ -0,0 +1,3 @@+repo:http://patch-tag.com/r/txt-sushi/pullrepo+thisrepo:/Users/keith/temp/txt-sushi-0.2+cache:/Users/keith/.darcs/cache
binary file changed (absent → 106 bytes)
binary file changed (absent → 104 bytes)
binary file changed (absent → 133 bytes)
binary file changed (absent → 213 bytes)
binary file changed (absent → 215 bytes)
binary file changed (absent → 259 bytes)
binary file changed (absent → 277 bytes)
binary file changed (absent → 349 bytes)
binary file changed (absent → 325 bytes)
binary file changed (absent → 319 bytes)
binary file changed (absent → 321 bytes)
binary file changed (absent → 424 bytes)
binary file changed (absent → 448 bytes)
binary file changed (absent → 483 bytes)
binary file changed (absent → 386 bytes)
binary file changed (absent → 419 bytes)
binary file changed (absent → 623 bytes)
binary file changed (absent → 479 bytes)
binary file changed (absent → 483 bytes)
binary file changed (absent → 534 bytes)
binary file changed (absent → 560 bytes)
binary file changed (absent → 595 bytes)
binary file changed (absent → 856 bytes)
binary file changed (absent → 693 bytes)
binary file changed (absent → 1092 bytes)
binary file changed (absent → 743 bytes)
binary file changed (absent → 1244 bytes)
binary file changed (absent → 1477 bytes)
binary file changed (absent → 1752 bytes)
binary file changed (absent → 1933 bytes)
binary file changed (absent → 2074 bytes)
binary file changed (absent → 1261 bytes)
binary file changed (absent → 4750 bytes)
binary file changed (absent → 6144 bytes)
binary file changed (absent → 12137 bytes)
@@ -0,0 +1,8 @@+pristine:0000001506-5eac01f7311f45389d1fc10325ff7b83a4cdd71d1532f04f07800936c5acb260+Starting with inventory:+0000001260-8f8e2c077c4bae8cc2094386214bd292379b1ee72540673d89e1514e19f69207+[TAG release 0.2+keithshep@gmail.com**20090521033210+ Ignore-this: b0ed58fccf2f95a610521713d9c1a499+] +hash: 0000000773-b36b71d0a85a717f6642b9f04da20921fb1e3d4e2044508833e676d094046526
@@ -0,0 +1,1 @@+pristine:0000001506-5eac01f7311f45389d1fc10325ff7b83a4cdd71d1532f04f07800936c5acb260
@@ -0,0 +1,15 @@+#!/bin/bash++# An example of using TxtSushi to query one of the CGD (center for genome dynamics)+# datasets+# +# Selects chromosome, base pair position, data source and a couple of strains.+# Filters out any rows from perlegen and any rows where A/J and BPH/2J differ++curl -s http://cgd.jax.org/ImputedSNPData/v1.1/PBupdatedv1.1_HMM_filleddata/PBupdatedv1.1_SNP_genoData_chr4.csv.gz \+| zcat \+| ../dist/build/tssql/tssql -table cgd - \+'select ChrID, `build 36 bp Position`, Source, `BPH/2J`, `A/J`, (Source =~ "Celera2"), (Source =~ "^Celera2"), not (Source =~ "^Celera2") from cgd+where not (Source =~ "^Perlegen36_b03$") and `A/J` = `BPH/2J`+order by `build 36 bp Position` + 0 desc' \+| ../dist/build/csvtopretty/csvtopretty -
@@ -0,0 +1,15 @@+#!/bin/bash++# An example of using TxtSushi to query one of the CGD (center for genome dynamics)+# datasets+# +# Selects chromosome, base pair position, data source and a couple of strains.+# Filters out any rows from perlegen and any rows where A/J and BPH/2J differ++curl -s http://cgd.jax.org/ImputedSNPData/v1.1/PBupdatedv1.1_HMM_filleddata/PBupdatedv1.1_SNP_genoData_chr4.csv.gz \+| zcat \+| ../dist/build/tssql/tssql -table cgd - \+'select ChrID, `build 36 bp Position`, Source, `BPH/2J`, `A/J` from cgd+where Source <> "Perlegen36_b03" and `A/J` = `BPH/2J`+order by `build 36 bp Position` + 0 desc' \+| ../dist/build/csvtopretty/csvtopretty -
@@ -2,11 +2,17 @@ # An example of using TxtSushi to query one of the MGI (mouse genome informatics) # database reports+#+# Selects accession ID, Symbol, chromosome, ID and centimorgan position (without+# the "trim" we end up with extra spaces).+# Only select chromosomes 1, 8 and 19 and look for "N/A" positions+# Sort the rows by chromosome (the "+0" coerces the chromosome from text to an+# integer) then symbol -wget -q -O - ftp://ftp.informatics.jax.org/pub/reports/MRK_List2.rpt | tabtocsv - \-| tssql -table mgi - \-'select `MGI Accession ID`, Symbol, Chr, trim(`cM Position`)+wget -q -O - ftp://ftp.informatics.jax.org/pub/reports/MRK_List2.rpt \+| ../dist/build/tabtocsv/tabtocsv - \+| ../dist/build/tssql/tssql -table mgi - \+'select substring(`MGI Accession ID` from 5), substring(`MGI Accession ID` from 5 for 3), `MGI Accession ID`, Symbol, Chr, trim(`cM Position`) from mgi where (Chr = 1 or Chr = 8 or Chr = 19) and trim(`cM Position`) = "N/A" order by Chr+0, Symbol' \-| csvtopretty --+| ../dist/build/csvtopretty/csvtopretty -
@@ -1,6 +1,6 @@ Name: txt-sushi-Version: 0.1-Synopsis: A collection of command line utilities for processing text tables+Version: 0.2+Synopsis: Spreadsheets are databases! Description: TxtSushi is a collection of command line utilities for processing comma-separated and tab-delimited files (AKA flat files, spreadsheets).@@ -18,7 +18,7 @@ Executable tssql Main-Is: tssql.hs- Build-Depends: base,haskell98,directory,containers,parsec+ Build-Depends: base,haskell98,directory,containers,parsec,regex-posix -- creates highly optimized code (slow compile) GHC-Options: -O2 -fvia-C