convert-annotation 0.5.0.1 → 0.5.1.0
raw patch · 6 files changed
+29/−21 lines, 6 files
Files
- README.org +2/−2
- app/Main.hs +9/−8
- convert-annotation.cabal +2/−2
- src/MSigDBRDataConvert.hs +9/−2
- src/RGeneConvert.hs +5/−5
- src/Types.hs +2/−2
README.org view
@@ -1,7 +1,7 @@ * convert-annotation -Very early stages. Mix between =HTTP= and =wreq= libraries, need to fully-convert to =wreq= in the future.+Very early stages. Mix between =HTTP= and =req= libraries, need to fully+convert to =req= in the future. Each mode, =info= or =annotation=, has its own help.
app/Main.hs view
@@ -49,8 +49,8 @@ -- | Command line arguments data Options = Info { delimiter :: Maybe String <?> "([,] | CHAR) The delimiter of the CSV file."- , database :: String- <?> "(Ensembl | HUGO TYPE | UniProt | RGene (TYPE, TYPE) | MSigDBRdata (FILE, RDATA, TYPE)) Which database to convert with. TYPE is the type of the original gene symbol. The compatible list for TYPE with HUGO is in http://www.genenames.org/help/rest-web-service-help. HUGO is only supported for Annotation. RGene (Annotation only) takes in a type of (FROM, TO) for the gene symbol origin and destination. MSigDBRdata (Info only) takes an rdata file (tested with http://bioinf.wehi.edu.au/software/MSigDB/), the name of the rdata object containing the named list, and the TYPE of symbol (compatable list at http://bioconductor.org/packages/release/bioc/manuals/biomaRt/man/biomaRt.pdf in getGene) which returns pathways separated by \"/\"."+ , database :: String+ <?> "(Ensembl | HUGO TYPE | UniProt | RGene (SPECIES, TYPE, TYPE) | MSigDBRdata (FILE, RDATA, TYPE)) Which database to convert with. TYPE is the type of the original gene symbol. The compatible list for TYPE with HUGO is in http://www.genenames.org/help/rest-web-service-help. HUGO is only supported for Annotation. RGene (Annotation only) takes in a type of (SPECIES, FROM, TO) for the gene symbol origin and destination, where species is generally \"hsapiens_gene_ensembl\" or \"mmusculus_gene_ensembl\". MSigDBRdata (Info only) takes an rdata file (tested with http://bioinf.wehi.edu.au/software/MSigDB/), the name of the rdata object containing the named list, and the TYPE of symbol (compatible list at http://bioconductor.org/packages/release/bioc/manuals/biomaRt/man/biomaRt.pdf in getGene) which returns pathways separated by \"/\"." , descriptionField :: Maybe String <?> "(Other TEXT | Description | Synonyms) The info to retrieve about the identifier. Description provides information about the identifier while synonyms provides alternate identifiers for the same entity. Returns a list of information (delimited by '/') for each match to Ensembl's cross references. For UniProt, enter a valid column (http://www.uniprot.org/help/programmatic_access)." , column :: T.Text@@ -65,7 +65,7 @@ | Annotation { delimiter :: Maybe String <?> "([,] | CHAR) The delimiter of the CSV file." , database :: String- <?> "(Ensembl | HUGO TYPE | UniProt | RGene (TYPE, TYPE) | MSigDBRdata (FILE, RDATA, TYPE)) Which database to convert with. TYPE is the type of the original gene symbol. The compatible list for TYPE with HUGO is in http://www.genenames.org/help/rest-web-service-help. HUGO is only supported for Annotation. RGene (Annotation only) takes in a type of (FROM, TO) for the gene symbol origin and destination. MSigDBRdata (Info only) takes an rdata file (tested with http://bioinf.wehi.edu.au/software/MSigDB/), the name of the rdata object containing the named list, and the TYPE of symbol (compatable list at http://bioconductor.org/packages/release/bioc/manuals/biomaRt/man/biomaRt.pdf in getGene) which returns pathways separated by \"/\"."+ <?> "(Ensembl | HUGO TYPE | UniProt | RGene (SPECIES, TYPE, TYPE) | MSigDBRdata (FILE, RDATA, TYPE)) Which database to convert with. TYPE is the type of the original gene symbol. The compatible list for TYPE with HUGO is in http://www.genenames.org/help/rest-web-service-help. HUGO is only supported for Annotation. RGene (Annotation only) takes in a type of (SPECIES, FROM, TO) for the gene symbol origin and destination, where species is generally \"hsapiens_gene_ensembl\" or \"mmusculus_gene_ensembl\". MSigDBRdata (Info only) takes an rdata file (tested with http://bioinf.wehi.edu.au/software/MSigDB/), the name of the rdata object containing the named list, and the TYPE of symbol (compatible list at http://bioconductor.org/packages/release/bioc/manuals/biomaRt/man/biomaRt.pdf in getGene) which returns pathways separated by \"/\"." , column :: T.Text <?> "(COLUMN) The column containing the identifier. Must be a valid id for info." , newColumn :: Maybe T.Text@@ -115,12 +115,13 @@ -> Maybe (RData s) -> [[T.Text]] -> IO ()+strictConvert _ _ _ [] = error "Empty file."+strictConvert _ _ _ (_:[]) = error "Empty file." strictConvert opts rMart rData (h:body) = do let c = col opts h newCol = unHelpful . newColumn $ opts-- let newH = maybe h (\x -> h <> [x]) $ newCol- xs = fmap (!! c) body+ newH = maybe h (\x -> h <> [x]) $ newCol+ xs = fmap (!! c) body newXS <- convertMultiple opts rMart rData $ xs @@ -237,8 +238,8 @@ R.withEmbeddedR R.defaultConfig $ R.runRegion $ do rMart <- case read . unHelpful . database $ opts of- (RGene _) -> fmap Just getRMart- (MSigDBRData _) -> fmap Just getRMart+ (RGene (species, _, _)) -> fmap Just $ getRMart species+ (MSigDBRData _) -> fmap Just $ getRMart "hsapiens_gene_ensembl" _ -> return Nothing rData <- case read . unHelpful . database $ opts of (MSigDBRData (!file, !object, _)) ->
convert-annotation.cabal view
@@ -1,5 +1,5 @@ name: convert-annotation-version: 0.5.0.1+version: 0.5.1.0 synopsis: Convert the annotation of a gene to another in a delimited file using a variety of different databases. description: Please see README.org homepage: http://github.com/GregorySchwartz/convert-annotation#readme@@ -40,7 +40,7 @@ executable convert-annotation hs-source-dirs: app main-is: Main.hs- ghc-options: -threaded -rtsopts -with-rtsopts=-N -O2+ ghc-options: -threaded -rtsopts -O2 build-depends: base , convert-annotation , optparse-generic
src/MSigDBRDataConvert.hs view
@@ -63,7 +63,11 @@ -> IO (Maybe Desc) toMSigDBPathways _ _ _ (UnknownAnn "") = return Nothing toMSigDBPathways rData rMart (MSigDBType (_, _, !from)) query = R.runRegion $ do- entrez <- io . toRGeneAnn rMart (RType (from, "entrezgene")) $ query+ entrez <- io+ . toRGeneAnn+ rMart+ (RType ("hsapiens_gene_ensembl", from, "entrezgene"))+ $ query maybe (return Nothing) (io . getPathway rData) $ entrez -- | Get the R mapping of multiple genes to pathways.@@ -74,5 +78,8 @@ -> [UnknownAnn] -> IO [Maybe Desc] toMSigDBPathwaysMultiple rData rMart (MSigDBType (_, _, !from)) queries = do- entrez <- toRGeneAnnMultiple rMart (RType (from, "entrezgene")) $ queries+ entrez <- toRGeneAnnMultiple+ rMart+ (RType ("hsapiens_gene_ensembl", from, "entrezgene"))+ $ queries mapM (maybe (return Nothing) (getPathway rData)) entrez
src/RGeneConvert.hs view
@@ -32,16 +32,16 @@ import Types -- | Get the R mapping of gene to gene.-getRMart :: R s (RMart s)-getRMart = fmap RMart+getRMart :: String -> R s (RMart s)+getRMart species = fmap RMart $ [r| library(biomaRt)- mart = useMart("ensembl", dataset="hsapiens_gene_ensembl")+ mart = useMart("ensembl", dataset=species_hs) |] -- | Get the R mapping of gene to gene. toRGeneAnn :: RMart s -> RType -> UnknownAnn -> IO (Maybe Ann) toRGeneAnn _ _ (UnknownAnn "") = return Nothing-toRGeneAnn rMart (RType (!from, !to)) (UnknownAnn textQuery) =+toRGeneAnn rMart (RType (_, !from, !to)) (UnknownAnn textQuery) = (fmap . fmap) Ann $ R.runRegion $ do let query = T.unpack textQuery mart = unRMart rMart@@ -60,7 +60,7 @@ -- | Get the R mapping of a list of genes to genes. toRGeneAnnMultiple :: RMart s -> RType -> [UnknownAnn] -> IO [Maybe Ann]-toRGeneAnnMultiple rMart (RType (!from, !to)) textQueries = R.runRegion $ do+toRGeneAnnMultiple rMart (RType (_, !from, !to)) textQueries = R.runRegion $ do let queries = fmap (T.unpack . unUnknownAnn) textQueries mart = unRMart rMart res <- [r| getBM( attributes = c(from_hs, to_hs)
src/Types.hs view
@@ -30,7 +30,7 @@ = Ensembl | HUGO T.Text | UniProt- | RGene (String, String)+ | RGene (String, String, String) | MSigDBRData (String, String, String) deriving (Read,Show) data DescFields = UniProtOther T.Text@@ -46,7 +46,7 @@ newtype Desc = Desc { unDesc :: T.Text } deriving (NFData) newtype HUGOType = HUGOType { unHUGOType :: T.Text }-newtype RType = RType { unRType :: (String, String) }+newtype RType = RType { unRType :: (String, String, String) } newtype MSigDBType = MSigDBType { unMSigDBType :: (String, String, String) } newtype RMart s = RMart { unRMart :: (R.SomeSEXP s) } newtype RData s = RData { unRData :: (R.SomeSEXP s) }